Extended Music Script

Extended Music Script
Edited by Mooshykris
Original Script by Andreas21 and Guillaume777
This Thread is SeporithSpawn Approved

UPDATE 3/6/2007: Script Now Allows In_Cube


I. Introduction:
As some of you may have seen, I have a distinct interest in Emulated Music aka USF, PSF, GSF ect.

When you use this script, it will allow you to play the following music extensions: .XM, .IT, .S3M, .MOD, .MTM, .UMX, .MO3, .psf, .minipsf, .psf2, .minipsf2, .spc, .gym, .cym, .usf, .miniusf, and all in_cube files.

The extensions hilighted in blue were part of the original "Audio Formats Extension Script" made by Andreas21 and Guillaume777. The red extensions were added by me. I expanded this script to allow it to run a USF and miniUSF file extension, as well as PSF/miniPSF, PSF2/miniPSF2, SPC, GYM, AND CYM.


II. The Script:
1. Insert a new Script above "Main" and call it "Extended Music" or just "Music"
2. Paste this script.
3. Create a folder called "DLL" in your game folder. Download These and place them there.
4. Your ready to go.


Note: This script does not require SDK. But is compatible with it.


Version 1
#==============================================================================
# Extended Music Script Version 1.0
#------------------------------------------------------------------------------
# Edited by Mooshykris
# February 7, 2007
#==============================================================================
# Version 1.0 Features:
# The Ability to play USF and MINIUSF Files
#==============================================================================
#Original Script:
#------------------------------------------------------------------------------
#Audio formats extension script
#------------------------------------------------------------------------------
# Guillaume777
# 3.1
# 2006/04/28
#==============================================================================
# Version 3.0 :
# -New support for in_bass dll ! You can now play those formats :
# '.XM', '.IT', '.S3M', '.MOD', '.MTM', '.UMX', '.MO3'
# -New support for fading !
# -Improved code, now script is really fast
#
#
# Great improvement of Andreas21 'WimAmp plugins', by Guillaume777 ( 2005 )
# Script allows you to play unusual formats ( .psf, .gym, .spc, it, mod, etc. ) if there is a winamp dll for it
# Script works with multiple format/dlls and doesn't require a 'call script' ( just make it play like any BGM )
# Script won't give error unless there is a music file requiring dll and dll is not there

# Instructions
#
# Make sure Winamp.dll, out_wave.dll and the music dlls are in a folder called 'DLL' in your game folder
# If you use in_bass.dll you need to have bass.dll in your game folder.
# Copy your music files to the BGM folder ( you can't import them via RPG XP )
# If you use .minipsf don't forget to include the psflib !!
# Just use an event to play the music like any regular BGM
# The music files won't play in Sound Test, only in the real game
# If you want loop music files you need to edit dlls in winamp and copy the configure files to the DLL folder
#
#
#
#
#
#
# Credits for Winamp class and Winamp.dll to Andreas21 (C) 2004

module G7_AFES_MOD
BGM_DIRECTORY = 'Audio/BGM/' # directory of BGMs
DLL_DIRECTORY = 'DLL/' #directory of dll

OUT_DLL = 'out_wave.dll' #output dll, default = 'out_wave.dll'
WIN_DLL = 'WinAmp.dll' #winamp dll, default = 'winamp.dll'

BGM_EXT = ['.mp3', '.mid', '.ogg', '.wma', '.wave'] #normal extension
PSF_EXT = ['.psf', '.minipsf', '.psf2', '.minipsf2']
USF_EXT = ['.usf', '.miniusf']
SNES_EXT = ['.spc']
GEN_EXT = ['.gym', '.cym']
MOD_EXT = ['.XM', '.IT', '.S3M', '.MOD', '.MTM', '.UMX', '.MO3']


PSF_DLL = 'in_psf.dll'
USF_DLL = 'in_usf.dll'
SNES_DLL= 'in_snes.dll'
GEN_DLL = 'in_ym.dll'
MOD_DLL = 'in_bass.dll'

end

module RPG
class AudioFile
attr_accessor :file_extension #stores the extension of file
attr_accessor :file_name #stores the real file name
attr_accessor :file_dll #store dll required to play it
end
end

module Audio
@winamp = nil #stores audio player
@winamp_volume = nil #stores volume value
@winamp_playing_bgm = nil #stores music played by winamp
@winamp_bgm_fading = nil #stores if bgm is currently fading or not
@winamp_current_dll = nil # stores current dll used by winamp
@fade_dec = nil #stores how much the volume decrease per frame while fading

def Audio.winamp_bgm_fading
return @winamp_bgm_fading
end

#==============================================================================
# Create winamp system, play music file with winamp, set volume
#==============================================================================
def self.winamp_bgm_play(file_name, volume = 100.0, dll = nil)
if @winamp_current_dll != dll then
@winamp_current_dll = dll
@winamp = WinAmp_Plugin_System.new(dll) #new winamp with new dll
end
volume = 255 #convert volume from rmxp to winamp
if volume > 255.0 then volume = 255.0 end
@winamp_playing_bgm = file_name
@winamp.play(file_name)
@winamp_volume = volume
@winamp.setvolume(volume)
end #end def


#==============================================================================
# Initiate the fading, calculates @fade_dec
#==============================================================================
def self.winamp_bgm_fade_init(frames)
if @winamp_playing_bgm != nil then
@fade_dec = @winamp_volume / frames
@winamp_bgm_fading = true
self.winamp_bgm_fade
end
end

#==============================================================================
# Fade volume by @fade_dec
#==============================================================================
def self.winamp_bgm_fade
@winamp_volume += -@fade_dec
@winamp.setvolume(@winamp_volume) #drop in volume for a fade
if @winamp_volume <= 0
self.winamp_bgm_stop
end
end

#==============================================================================
# Stops playing music
#==============================================================================
def self.winamp_bgm_stop
if @winamp_playing_bgm != nil then
@winamp.setvolume(255)
@winamp.stop #stop winamp
end
@winamp_bgm_fading = false
@fade_dec = false
@winamp_volume = nil
@winamp_playing_bgm = nil
end

#==============================================================================
# Uses Win32API and WinAmp.dll to add winamp functions
#==============================================================================
class WinAmp_Plugin_System #This part was done by Andreas21
def initialize(in_dll)
# DLL Pfaht festlegen
dll_directory = G7_AFES_MOD::DLL_DIRECTORY
in_dll = dll_directory + in_dll
out_dll = dll_directory + G7_AFES_MOD::OUT_DLL
winamp_dll = dll_directory + G7_AFES_MOD::WIN_DLL
# 2 API Funktionen die gebraucht werden fÃÂÂ ¼r das Fenster Handel
@ReadIni = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l'
@FindWindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
# BenÃÂÂ ¶tigte DLL Funktionen Laden
@Init_Winamp = Win32API.new winamp_dll, 'Init_Winamp', %w(p p l), 'l'
@Quit_Winamp = Win32API.new winamp_dll, 'Quit_Winamp', '', ''
@Winamp_Play = Win32API.new winamp_dll, 'Winamp_Play', 'p', 'l'
@Winamp_Pause = Win32API.new winamp_dll, 'Winamp_Pause', '', ''
@Winamp_Stop = Win32API.new winamp_dll, 'Winamp_Stop', '', 'l'
@Winamp_OnlyExtensions = Win32API.new winamp_dll, 'Winamp_OnlyExtensions', '', 'p'
@Winamp_OutName = Win32API.new winamp_dll, 'Winamp_OutName', '', 'p'
@Winamp_OutConfig = Win32API.new winamp_dll, 'Winamp_OutConfig', 'l', ''
@Winamp_OutAbout = Win32API.new winamp_dll, 'Winamp_OutAbout', 'l', ''
@Winamp_IsPlaying = Win32API.new winamp_dll, 'Winamp_IsPlaying', '', 'l'
@Winamp_InName = Win32API.new winamp_dll, 'Winamp_InName', '', 'p'
@Winamp_Extensions = Win32API.new winamp_dll, 'Winamp_Extensions', '', 'p'
@Winamp_InConfig = Win32API.new winamp_dll, 'Winamp_InConfig', 'l', ''
@Winamp_InAbout = Win32API.new winamp_dll, 'Winamp_InAbout', 'l', ''
@Winamp_GetFileInfo = Win32API.new winamp_dll, 'Winamp_GetFileInfo', %w(p l), 'p'
@Winamp_InfoBox = Win32API.new winamp_dll, 'Winamp_InfoBox', %w(p l), 'l'
@Winamp_GetLength = Win32API.new winamp_dll, 'Winamp_GetLength', '', 'l'
@Winamp_LengthStr = Win32API.new winamp_dll, 'Winamp_LengthStr', 'l', 'p'
@Winamp_GetOutputTime = Win32API.new winamp_dll, 'Winamp_GetOutputTime', '', 'l'
@Winamp_SetVolume = Win32API.new winamp_dll, 'Winamp_SetVolume', 'l', ''
@Winamp_SetPan = Win32API.new winamp_dll, 'Winamp_SetPan', 'l', ''
@Winamp_setoutputtime = Win32API.new winamp_dll, 'winamp_setoutputtime', 'l', ''
@Winamp_IsPaused = Win32API.new winamp_dll, 'Winamp_IsPaused', '', 'l'

# Winamp Plugin Systen Start
@Init_Winamp.call(in_dll, out_dll, handel)
end
# Play the file. Return 0 if no error happend.
def play(file)
return @Winamp_Play.call(file)
end
# First call pause the sound and the second call unpause it.
def pause
@Winamp_Pause.call()
end
# Stop playing.
def stop
return @Winamp_Stop.call()
end
# Quit WinAmp
def quit
@Quit_Winamp.call()
end
# Return all the supported mediafiles.
def onlyextensions
return @Winamp_OnlyExtensions.call()
end
# Out_DLL Infos
def outname
return @Winamp_OutName.call()
end
# Open the config-dialog of the out-plugin.
def outconfig
@Winamp_OutConfig.call(handel)
end
# Open the about-dialog of the out-plugin
def outabout
@Winamp_OutAbout.call(handel)
end
# Return <>0 if a sound is playing, but doesn't work if in-plugin don't need the out-plugin
def isplaying
return @Winamp_IsPlaying.call()
end
# Return the name of the in-plugin.
def inname
return @Winamp_InName.call()
end
# Return the extentions and the type name of all supported mediafiles
def extensions
return @Winamp_Extensions.call()
end
# Open the config-dialog of the in-plugin.
def inconfig
@Winamp_InConfig.call(handel)
end
# Open the about-dialog of the in-plugin.
def inabout
@Winamp_InAbout.call(handel)
end
# return the title of a file and the length in ms.
def getfileinfo(playfile,length_adr)
return @Winamp_GetFileInfo.call(playfile,length_adr)
end
# Open the file-info-dialog of the in-plugin. Not supported of all pluggins (=the will do nothing)
def infobox(playfile)
return @Winamp_InfoBox.call(playfile,handel)
end
# Returns the length of the playing file in ms.
def getlength
return @Winamp_GetLength.call()
end
# Convert the length to a string. Format: "h:mm:ss".
def lengthstr(length)
return @Winamp_LengthStr.call(length)
end
# Return the current playing position.
def getoutputtime
return @Winamp_GetOutputTime.call()
end
# Set the volume (0 to 255)
def setvolume(volume)
@Winamp_SetVolume.call(volume)
end
# Set the pan (left=-127 to 127=right)
def setpan(pan)
@Winamp_SetPan.call(pan)
end
# Set the playing position position. Not supported of all in-plugins. Can be very slow.
def setoutputtime(time)
@Winamp_setoutputtime.call(time)
end
# Return <>0 if paused.
def ispaused
return @Winamp_IsPaused.call()
end
def handel
game_name = 0.chr * 255
zeichen = @ReadIni.call('Game','Title','',game_name,255,'.\\Game.ini')
return @FindWindow.call('RGSS Player',game_name.slice!(0,zeichen))
end #end of init
end #end of class
end #end of module




#==============================================================================
# â–  Game_System
#------------------------------------------------------------------------------
# Changes added to the bgm_play, bgm_stop and bgm_fade functions.
#==============================================================================

class Game_System
#--------------------------------------------------------------------------
# ● Play BGM either normally or by using winamp plugin
#--------------------------------------------------------------------------
def bgm_play(bgm)
@playing_bgm = bgm
if bgm !=nil and bgm.name != ""
if bgm.file_extension == nil then #stores extension of file
bgm.file_extension = self.get_file_extension(bgm.name)
end
if bgm.file_name == nil then #stores path and name of file
bgm.file_name = G7_AFES_MOD::BGM_DIRECTORY + bgm.name + bgm.file_extension
end
end

if bgm != nil and bgm.name != ""
if bgm.file_extension == "" or G7_AFES_MOD::BGM_EXT.include?(bgm.file_extension) #normal music file
Audio.winamp_bgm_stop
Audio.bgm_play( bgm.file_name, bgm.volume, bgm.pitch)
else #if file required winamp plugin to play
Audio.winamp_bgm_stop
Audio.bgm_stop
if bgm.file_dll == nil then
bgm.file_dll = self.get_dll(bgm.file_extension) # get dll required to play file
end
Audio.winamp_bgm_play(bgm.file_name, bgm.volume, bgm.file_dll) #Play the new audio format
end
else #if playing nothing
Audio.winamp_bgm_stop
Audio.bgm_stop
end
Graphics.frame_reset
end

def bgm_fade(time)
@playing_bgm = nil
Audio.bgm_fade(time * 1000)
Audio.winamp_bgm_fade_init(time * 41.0) #line added
end


def bgm_stop
Audio.bgm_stop
Audio.winamp_bgm_stop #line added
end

#--------------------------------------------------------------------------
# ● Update the sound level if fading
#--------------------------------------------------------------------------
alias g7_afes_game_system_update update
def update
g7_afes_game_system_update #update normally
if Audio.winamp_bgm_fading
Audio.winamp_bgm_fade #lower volume for the frame
end
end

#--------------------------------------------------------------------------
# ● Returns correct extension of file
#--------------------------------------------------------------------------
def get_file_extension(bgm_name)
file_name= G7_AFES_MOD::BGM_DIRECTORY + bgm_name
extensions = G7_AFES_MOD::BGM_EXT + G7_AFES_MOD::PSF_EXT + G7_AFES_MOD::USF_EXT + G7_AFES_MOD::SNES_EXT + G7_AFES_MOD::GEN_EXT + G7_AFES_MOD::MOD_EXT
file_extension = "" #nil by default

for extension in extensions
if FileTest.exist?(file_name + extension) #if it found extension
file_extension = extension # remember extension
break
end
end
return file_extension
end

#--------------------------------------------------------------------------
# ● Returns dll required to play file with winamp system
#--------------------------------------------------------------------------
def get_dll(file_extension)
if G7_AFES_MOD::PSF_EXT.include?(file_extension)
dll = G7_AFES_MOD::PSF_DLL
elsif G7_AFES_MOD::USF_EXT.include?(file_extension)
dll = G7_AFES_MOD::USF_DLL
elsif G7_AFES_MOD::MOD_EXT.include?(file_extension)
dll = G7_AFES_MOD::MOD_DLL
elsif G7_AFES_MOD::SNES_EXT.include?(file_extension)
dll = G7_AFES_MOD::SNES_DLL
elsif G7_AFES_MOD::GEN_EXT.include?(file_extension)
dll = G7_AFES_MOD::GEN_DLL
else
dll = nil
end

return dll
end
end #end class
Expand to see the code.


Version 2
#==============================================================================
# Extended Music Script Version 2.0
#------------------------------------------------------------------------------
# Edited by Mooshykris
# March 6, 2007
#==============================================================================
# Version 2.0 Features:
# The Ability to play USF, MINIUSF, and all In_Cube Files
#==============================================================================
#Original Script:
#------------------------------------------------------------------------------
#Audio formats extension script
#------------------------------------------------------------------------------
# Guillaume777
# 3.1
# 2006/04/28
#==============================================================================
# Version 3.0 :
# -New support for in_bass dll ! You can now play those formats :
# '.XM', '.IT', '.S3M', '.MOD', '.MTM', '.UMX', '.MO3'
# -New support for fading !
# -Improved code, now script is really fast
#
#
# Great improvement of Andreas21 'WimAmp plugins', by Guillaume777 ( 2005 )
# Script allows you to play unusual formats ( .psf, .gym, .spc, it, mod, etc. ) if there is a winamp dll for it
# Script works with multiple format/dlls and doesn't require a 'call script' ( just make it play like any BGM )
# Script won't give error unless there is a music file requiring dll and dll is not there

# Instructions
#
# Make sure Winamp.dll, out_wave.dll and the music dlls are in a folder called 'DLL' in your game folder
# If you use in_bass.dll you need to have bass.dll in your game folder.
# Copy your music files to the BGM folder ( you can't import them via RPG XP )
# If you use .minipsf don't forget to include the psflib !!
# Just use an event to play the music like any regular BGM
# The music files won't play in Sound Test, only in the real game
# If you want loop music files you need to edit dlls in winamp and copy the configure files to the DLL folder
#
#
#
#
#
#
# Credits for Winamp class and Winamp.dll to Andreas21 (C) 2004

module G7_AFES_MOD
BGM_DIRECTORY = 'Audio/BGM/' # directory of BGMs
DLL_DIRECTORY = 'DLL/' #directory of dll

OUT_DLL = 'out_wave.dll' #output dll, default = 'out_wave.dll'
WIN_DLL = 'WinAmp.dll' #winamp dll, default = 'winamp.dll'

BGM_EXT = ['.mp3', '.mid', '.ogg', '.wma', '.wave'] #normal extension
PSF_EXT = ['.psf', '.minipsf', '.psf2', '.minipsf2']
GSF_EXT = ['.gsf', '.minigsf']
USF_EXT = ['.usf', '.miniusf']
CUBE_EXT = ['.hps', '.dsp']
SNES_EXT = ['.spc']
GEN_EXT = ['.gym', '.cym']
MOD_EXT = ['.XM', '.IT', '.S3M', '.MOD', '.MTM', '.UMX', '.MO3']


PSF_DLL = 'in_psf.dll'
GSF_DLL = 'in_gsf.dll'
USF_DLL = 'in_usf.dll'
CUBE_DLL = 'in_cube.dll'
SNES_DLL= 'in_snes.dll'
GEN_DLL = 'in_ym.dll'
MOD_DLL = 'in_bass.dll'

end

module RPG
class AudioFile
attr_accessor :file_extension #stores the extension of file
attr_accessor :file_name #stores the real file name
attr_accessor :file_dll #store dll required to play it
end
end

module Audio
@winamp = nil #stores audio player
@winamp_volume = nil #stores volume value
@winamp_playing_bgm = nil #stores music played by winamp
@winamp_bgm_fading = nil #stores if bgm is currently fading or not
@winamp_current_dll = nil # stores current dll used by winamp
@fade_dec = nil #stores how much the volume decrease per frame while fading

def Audio.winamp_bgm_fading
return @winamp_bgm_fading
end

#==============================================================================
# Create winamp system, play music file with winamp, set volume
#==============================================================================
def self.winamp_bgm_play(file_name, volume = 100.0, dll = nil)
if @winamp_current_dll != dll then
@winamp_current_dll = dll
@winamp = WinAmp_Plugin_System.new(dll) #new winamp with new dll
end
volume = 255 #convert volume from rmxp to winamp
if volume > 255.0 then volume = 255.0 end
@winamp_playing_bgm = file_name
@winamp.play(file_name)
@winamp_volume = volume
@winamp.setvolume(volume)
end #end def


#==============================================================================
# Initiate the fading, calculates @fade_dec
#==============================================================================
def self.winamp_bgm_fade_init(frames)
if @winamp_playing_bgm != nil then
@fade_dec = @winamp_volume / frames
@winamp_bgm_fading = true
self.winamp_bgm_fade
end
end

#==============================================================================
# Fade volume by @fade_dec
#==============================================================================
def self.winamp_bgm_fade
@winamp_volume += -@fade_dec
@winamp.setvolume(@winamp_volume) #drop in volume for a fade
if @winamp_volume <= 0
self.winamp_bgm_stop
end
end

#==============================================================================
# Stops playing music
#==============================================================================
def self.winamp_bgm_stop
if @winamp_playing_bgm != nil then
@winamp.setvolume(255)
@winamp.stop #stop winamp
end
@winamp_bgm_fading = false
@fade_dec = false
@winamp_volume = nil
@winamp_playing_bgm = nil
end

#==============================================================================
# Uses Win32API and WinAmp.dll to add winamp functions
#==============================================================================
class WinAmp_Plugin_System #This part was done by Andreas21
def initialize(in_dll)
# DLL Pfaht festlegen
dll_directory = G7_AFES_MOD::DLL_DIRECTORY
in_dll = dll_directory + in_dll
out_dll = dll_directory + G7_AFES_MOD::OUT_DLL
winamp_dll = dll_directory + G7_AFES_MOD::WIN_DLL
# 2 API Funktionen die gebraucht werden fÃÂÂ ¼r das Fenster Handel
@ReadIni = Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l p), 'l'
@FindWindow = Win32API.new 'user32', 'FindWindowA', %w(p p), 'l'
# BenÃÂÂ ¶tigte DLL Funktionen Laden
@Init_Winamp = Win32API.new winamp_dll, 'Init_Winamp', %w(p p l), 'l'
@Quit_Winamp = Win32API.new winamp_dll, 'Quit_Winamp', '', ''
@Winamp_Play = Win32API.new winamp_dll, 'Winamp_Play', 'p', 'l'
@Winamp_Pause = Win32API.new winamp_dll, 'Winamp_Pause', '', ''
@Winamp_Stop = Win32API.new winamp_dll, 'Winamp_Stop', '', 'l'
@Winamp_OnlyExtensions = Win32API.new winamp_dll, 'Winamp_OnlyExtensions', '', 'p'
@Winamp_OutName = Win32API.new winamp_dll, 'Winamp_OutName', '', 'p'
@Winamp_OutConfig = Win32API.new winamp_dll, 'Winamp_OutConfig', 'l', ''
@Winamp_OutAbout = Win32API.new winamp_dll, 'Winamp_OutAbout', 'l', ''
@Winamp_IsPlaying = Win32API.new winamp_dll, 'Winamp_IsPlaying', '', 'l'
@Winamp_InName = Win32API.new winamp_dll, 'Winamp_InName', '', 'p'
@Winamp_Extensions = Win32API.new winamp_dll, 'Winamp_Extensions', '', 'p'
@Winamp_InConfig = Win32API.new winamp_dll, 'Winamp_InConfig', 'l', ''
@Winamp_InAbout = Win32API.new winamp_dll, 'Winamp_InAbout', 'l', ''
@Winamp_GetFileInfo = Win32API.new winamp_dll, 'Winamp_GetFileInfo', %w(p l), 'p'
@Winamp_InfoBox = Win32API.new winamp_dll, 'Winamp_InfoBox', %w(p l), 'l'
@Winamp_GetLength = Win32API.new winamp_dll, 'Winamp_GetLength', '', 'l'
@Winamp_LengthStr = Win32API.new winamp_dll, 'Winamp_LengthStr', 'l', 'p'
@Winamp_GetOutputTime = Win32API.new winamp_dll, 'Winamp_GetOutputTime', '', 'l'
@Winamp_SetVolume = Win32API.new winamp_dll, 'Winamp_SetVolume', 'l', ''
@Winamp_SetPan = Win32API.new winamp_dll, 'Winamp_SetPan', 'l', ''
@Winamp_setoutputtime = Win32API.new winamp_dll, 'winamp_setoutputtime', 'l', ''
@Winamp_IsPaused = Win32API.new winamp_dll, 'Winamp_IsPaused', '', 'l'

# Winamp Plugin Systen Start
@Init_Winamp.call(in_dll, out_dll, handel)
end
# Play the file. Return 0 if no error happend.
def play(file)
return @Winamp_Play.call(file)
end
# First call pause the sound and the second call unpause it.
def pause
@Winamp_Pause.call()
end
# Stop playing.
def stop
return @Winamp_Stop.call()
end
# Quit WinAmp
def quit
@Quit_Winamp.call()
end
# Return all the supported mediafiles.
def onlyextensions
return @Winamp_OnlyExtensions.call()
end
# Out_DLL Infos
def outname
return @Winamp_OutName.call()
end
# Open the config-dialog of the out-plugin.
def outconfig
@Winamp_OutConfig.call(handel)
end
# Open the about-dialog of the out-plugin
def outabout
@Winamp_OutAbout.call(handel)
end
# Return <>0 if a sound is playing, but doesn't work if in-plugin don't need the out-plugin
def isplaying
return @Winamp_IsPlaying.call()
end
# Return the name of the in-plugin.
def inname
return @Winamp_InName.call()
end
# Return the extentions and the type name of all supported mediafiles
def extensions
return @Winamp_Extensions.call()
end
# Open the config-dialog of the in-plugin.
def inconfig
@Winamp_InConfig.call(handel)
end
# Open the about-dialog of the in-plugin.
def inabout
@Winamp_InAbout.call(handel)
end
# return the title of a file and the length in ms.
def getfileinfo(playfile,length_adr)
return @Winamp_GetFileInfo.call(playfile,length_adr)
end
# Open the file-info-dialog of the in-plugin. Not supported of all pluggins (=the will do nothing)
def infobox(playfile)
return @Winamp_InfoBox.call(playfile,handel)
end
# Returns the length of the playing file in ms.
def getlength
return @Winamp_GetLength.call()
end
# Convert the length to a string. Format: "h:mm:ss".
def lengthstr(length)
return @Winamp_LengthStr.call(length)
end
# Return the current playing position.
def getoutputtime
return @Winamp_GetOutputTime.call()
end
# Set the volume (0 to 255)
def setvolume(volume)
@Winamp_SetVolume.call(volume)
end
# Set the pan (left=-127 to 127=right)
def setpan(pan)
@Winamp_SetPan.call(pan)
end
# Set the playing position position. Not supported of all in-plugins. Can be very slow.
def setoutputtime(time)
@Winamp_setoutputtime.call(time)
end
# Return <>0 if paused.
def ispaused
return @Winamp_IsPaused.call()
end
def handel
game_name = 0.chr * 255
zeichen = @ReadIni.call('Game','Title','',game_name,255,'.\\Game.ini')
return @FindWindow.call('RGSS Player',game_name.slice!(0,zeichen))
end #end of init
end #end of class
end #end of module




#==============================================================================
# â–  Game_System
#------------------------------------------------------------------------------
# Changes added to the bgm_play, bgm_stop and bgm_fade functions.
#==============================================================================

class Game_System
#--------------------------------------------------------------------------
# ● Play BGM either normally or by using winamp plugin
#--------------------------------------------------------------------------
def bgm_play(bgm)
@playing_bgm = bgm
if bgm !=nil and bgm.name != ""
if bgm.file_extension == nil then #stores extension of file
bgm.file_extension = self.get_file_extension(bgm.name)
end
if bgm.file_name == nil then #stores path and name of file
bgm.file_name = G7_AFES_MOD::BGM_DIRECTORY + bgm.name + bgm.file_extension
end
end

if bgm != nil and bgm.name != ""
if bgm.file_extension == "" or G7_AFES_MOD::BGM_EXT.include?(bgm.file_extension) #normal music file
Audio.winamp_bgm_stop
Audio.bgm_play( bgm.file_name, bgm.volume, bgm.pitch)
else #if file required winamp plugin to play
Audio.winamp_bgm_stop
Audio.bgm_stop
if bgm.file_dll == nil then
bgm.file_dll = self.get_dll(bgm.file_extension) # get dll required to play file
end
Audio.winamp_bgm_play(bgm.file_name, bgm.volume, bgm.file_dll) #Play the new audio format
end
else #if playing nothing
Audio.winamp_bgm_stop
Audio.bgm_stop
end
Graphics.frame_reset
end

def bgm_fade(time)
@playing_bgm = nil
Audio.bgm_fade(time * 1000)
Audio.winamp_bgm_fade_init(time * 41.0) #line added
end


def bgm_stop
Audio.bgm_stop
Audio.winamp_bgm_stop #line added
end

#--------------------------------------------------------------------------
# ● Update the sound level if fading
#--------------------------------------------------------------------------
alias g7_afes_game_system_update update
def update
g7_afes_game_system_update #update normally
if Audio.winamp_bgm_fading
Audio.winamp_bgm_fade #lower volume for the frame
end
end

#--------------------------------------------------------------------------
# ● Returns correct extension of file
#--------------------------------------------------------------------------
def get_file_extension(bgm_name)
file_name= G7_AFES_MOD::BGM_DIRECTORY + bgm_name
extensions = G7_AFES_MOD::BGM_EXT + G7_AFES_MOD::PSF_EXT + G7_AFES_MOD::GSF_EXT + G7_AFES_MOD::USF_EXT + G7_AFES_MOD::CUBE_EXT + G7_AFES_MOD::SNES_EXT + G7_AFES_MOD::GEN_EXT + G7_AFES_MOD::MOD_EXT
file_extension = "" #nil by default

for extension in extensions
if FileTest.exist?(file_name + extension) #if it found extension
file_extension = extension # remember extension
break
end
end
return file_extension
end

#--------------------------------------------------------------------------
# ● Returns dll required to play file with winamp system
#--------------------------------------------------------------------------
def get_dll(file_extension)
if G7_AFES_MOD::PSF_EXT.include?(file_extension)
dll = G7_AFES_MOD::PSF_DLL
elsif G7_AFES_MOD::GSF_EXT.include?(file_extension)
dll = G7_AFES_MOD::GSF_DLL 
elsif G7_AFES_MOD::USF_EXT.include?(file_extension)
dll = G7_AFES_MOD::USF_DLL
elsif G7_AFES_MOD::CUBE_EXT.include?(file_extension)
dll = G7_AFES_MOD::CUBE_DLL
elsif G7_AFES_MOD::MOD_EXT.include?(file_extension)
dll = G7_AFES_MOD::MOD_DLL
elsif G7_AFES_MOD::SNES_EXT.include?(file_extension)
dll = G7_AFES_MOD::SNES_DLL
elsif G7_AFES_MOD::GEN_EXT.include?(file_extension)
dll = G7_AFES_MOD::GEN_DLL
else
dll = nil
end

return dll
end
end #end class
Expand to see the code.


III. Instructions
There are none, just play the music as you would normally.

IMPORTANT: do not, I repeat, DO NOT play any "emulated" music with the "Map BGM" option in Map Options. It will restart every other second! Use a Paralell Progress event, Play BGM, and immedietly, Erase Event.


IV. Screenshots
None needed.


V. In_Cube
In_Cube, is a new plugin that supports Game Cube Formats. However, unlike the other formats, In_Cube uses many file types.

From Halley's Comet Software, the creators of In_Cube
Quote:
in_cube is a winamp plugin intended to play streamed audio formats found in Nintendo Gamecube games.

Currently it supports:

* ADX (with looping for "03" and "04" versions)
* ADP a.k.a. DTK (only playback at 48KHz Stereo) - note that some games (Battalion Wars) have the ADP extension for DSP files, these will be recognized as DSP
* DSP variants:
o standard (including simultaneous playback of left and right channel files as stereo)
o "RS03" (Metroid Prime 2)
o SPT/SPD (Bust-a-Move 3000, Hello Kitty Roller Rescue) (only for single songs, not banks)
o "Cstr" (Star Fox Assault, Donkey Konga)
o STM (Paper Mario 2, Fire Emblem) - must be renamed DSP to not interfere with winamp's support for another format called STM
o HPS (HALPST) (Super Smash Bros. Melee, Kirby's Air Ride, Killer7, etc.)
o IDSP (Super Mario Strikers)
o MSS (Second Sight)
o GCM (Lego Star Wars)
o Monopoly Party's screwy single header stereo - must be renamed .MPDSP
o ISH/ISD (Pokemon XD)
o YMF (WWE Wrestlemania X8) - most files work
o RSD (RSD3GADP type)
o IDSP (Harvest Moon)
o GCub (.wav) (NHL Hitz Pro) - must be renamed .dsp
o WAM/WAA/WAC/WAD (Beyond Good & Evil), a RIFF variant
o WVS (Metal Arms)
* 16-bit big endian PCM
o RSD (RSD2PCMB and RSD3PCMB)
o AST (Mario Kart: Double Dash)
o WHD/WAV (Hitman 2)
* AFC
o "standard" (Wind Waker)
o AST (Twilight Princess, files must be renamed to .AFC)
* RSF (Metroid Prime) - experimental
* Playstation ADPCM (not used on GC, but...)
o VAG
o ADS

Additionally, ADX has been used for a number of systems besides Gamecube, to the best of my knowledge they are also supported.
If you were using in_dsp or in_adx you should remove them before installing in_cube.


In_Cube DLL: http://www.hcs64.com/files/in_cube023b2.zip


VI. Demo
Coming Soon


VII. Credits and Other

Things I plan to do with this script:

1. Find a way for it to play .NSF, .GBS, ect.
2. Find a bug-free way for it to play .GSF/.miniGSF.

Credits: Give credits to Andreas21 and Guillaume777, as they created this script. I don't need credit, since I just edited it for use in my game, but I would appreciate it.


VII. Conclusion

Well, that's my edited , script. I hope you like it.

If you have a problem, post it in this thread.

Mooshykris
What about the DLL's ?
[QUOTE=Meâ„¢;156805]What about the DLL's ?[/QUOTE]

*Edit's Post* Sorry, I forgot. I already have winamp, so I didn't need them.

Edit: They're up!
This will be perfect for my game! Thankyou so much!
:thumbsup02:
[QUOTE=Kururu;156846]This will be perfect for my game! Thankyou so much!
:thumbsup02:[/QUOTE]

Your welcome. ;)
can you rewrite the script, so i can play .imk Files too?


imk is the music file format of the Game "CHAOS LEGION"

i tried to convert it to mp3 or wav... but i canÂÂ ´t...
[QUOTE=Sir Lord Biowulve;163997]can you rewrite the script, so i can play .imk Files too?


imk is the music file format of the Game "CHAOS LEGION"

i tried to convert it to mp3 or wav... but i canÂÂ ´t...[/QUOTE]

That script uses winamp plug-ins to play additional sound files. So you have to get winamp plug-ins for certain sound format, but I doubt you can find such.
[QUOTE=Sir Lord Biowulve;163997]can you rewrite the script, so i can play .imk Files too?


imk is the music file format of the Game "CHAOS LEGION"

i tried to convert it to mp3 or wav... but i canÂÂ ´t...[/QUOTE]

As Landarma, you'd need a winamp plugin DLL for it to work.

On a sidenote, I can't 'rewrite' the script, only edit it within my RGSS knowledge. I am not a scripter, just a poor (poor, as in not very good) script editor, I can'r rewrite it. That's why I still can't make it run .gsf or .minigsf.

Once again: Can someone help me solve this problem?

Mooshykris
UPDATE 3/6/2007
Version 2 is up.


I am happy to say that I have just released version 2 of this script, which now allows the "In_Cube" extension.

Read my main post for more info.


Mooshykris

(ps: mods, am I allowed to double post to add information.)
I love this script...Almost infinite songs, and low-sized!

However
I've pasted the four DLL's and, although I can play .psf,
.psf2 files seem unable to be played. Is this a DLL problem
or script's?
[QUOTE=daigotsu;169163]I love this script...Almost infinite songs, and low-sized![/QUOTE]

Amlost true, in_cube formats aren't that tiny.

Quote:
However
I've pasted the four DLL's and, although I can play .psf,
.psf2 files seem unable to be played. Is this a DLL problem
or script's?


Hmmmmm... I'm not exactly sure, as I am not a scripter, I'll contact Selwyn, who created the simmilar "PSF Files Script" and get back to you about that.

Anyways,

I've recently noticed that I don't have all of the music formats for In_Cube within the script, I will add them and update it shortly.


Mooshykris
I get this error when I try to use the script that that says 'script line 161: runtimeError occured.' and under it 'LoadLibrary: DLL/WinAmp.dll'. I have winamp and Runtime. Both work normally, I also have a needed DLLs, is there anything else you can tell me that I may be doing wrong?
Are they in the DLL folder?
[QUOTE=Kururu;171066]Are they in the DLL folder?[/QUOTE]

Yes.
[QUOTE=Breakman;171423]Yes.[/QUOTE]

I see, I am still waiting for Selwyn to get back to me about if there are any script problems.

Mooshykris
My only question is do some mediums such as in_cube allow for perfect loop back? I know .ogg works great for this, but if there is any way to make smaller file formats for music and such, that would be amazing and I'd definitely use this.
[QUOTE=Axerax;173843]My only question is do some mediums such as in_cube allow for perfect loop back? I know .ogg works great for this, but if there is any way to make smaller file formats for music and such, that would be amazing and I'd definitely use this.[/QUOTE]

All in_cube supports looping.

And one thing In_Cube is not small!

One Soundtrack in these files can be as big as MP3 Soundtracks but they are better quality and they loop.

And I've spoken with the creator of In_Cube/USF via AIM, so I know what I'm talking about when it comes to In_Cube/USF, that's why I decided to create this script.

Mooshykris
Game just crashes upon an attempt to play a .mod file... i cant even seem to pinpoint an error, just a plain old windows needs to close this application.
[QUOTE=Port3M5;177090]Game just crashes upon an attempt to play a .mod file... i cant even seem to pinpoint an error, just a plain old windows needs to close this application.[/QUOTE]
This script uses in_bass.dll to play module sound. So you have to put bass.dll in your project directory(not \dll). To get BASS library, visit here:
http://www.un4seen.com/
thanks landarma but i still get the crash when i try to play the mod file in-game...
A different script would probably need to be created, but does anyone here know of 'Wingroove'? It's an ANCIENT midi player that makes midis sound alot better. I can't post the file here because of copyright (I... think), but I'm sure this script could be altered to have a game use Wingroove's data files instead of RMXP's default MIDI playing capabilities.
I mainly want this because most midis don't sound too good under RMXP, but better in Wingroove (or even just out of RMXP.)

I tried adding:
MID_EXT = ['.mid']
MID_DLL = 'WGMFP.DLL'
Although I'm probably using the wrong file or something so I'm asking for help from anyone who knows about dlls or in_midi.
(Note I actually replaced other file type definitions I'd never use but you get the idea.)

Thanks if anyone can help.
Well, that means someone have to write a script(mostly API call?) for Wingroove midi driver(yep, it has its own midi device driver). This script is for winamp.dll and winamp plug-ins, so you cannot use other dlls without editing, or rewriting the script.
[QUOTE=Landarma;181598]Well, that means someone have to write a script(mostly API call?) for Wingroove midi driver(yep, it has its own midi device driver). This script is for winamp.dll and winamp plug-ins, so you cannot use other dlls without editing, or rewriting the script.[/QUOTE]


Yup, and I'm already pushing her to the limit. It already errors when MODs and GSFs are played. (I've recently tryed out a few MODs I can't make them work!)

So, trying to rewrite MIDIs = very bad.

Mooshykris
Hmm i have a question about SPC files like the music from the SNES that uses that format.

When i uzip one of the rar files with it i seem to get PCKS certificates. is this the SPC file.

And i'm curious do you put those files in the BGS folder?
If you don't have winamp yourself or haven't reset the default program, yes you may see them as certificates.
Yes they go in the BGM folder.
So what is the default program so i don't have to see them as certificates.
Just set them to play with winamp (if you have it)

That's what I did, so I don't know anything more.
Of course, you'll need plugin for SPC...........
Crap.

I got to download winamp.. Isn't that owned by AOHell and full of viruses.
If you don't like it, you can use foobar2000 and its components.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=15204