03-03-2008, 06:49 AM
Winamp PSF files script
by Selwyn
by Selwyn
INTRODUCTION
Selwyn @ RMXP.Org Sun Apr 09, 2006 Wrote:This script allows you to play .psf .psf2 .minipsf and .minipsf2 files with RMXP.
To make this script work you'll need a few things :
- create a folder within your game's folder and name it 'DLL'.
- download the following files in it :
* in_psf.dll
* out_wave.dll
* Winamp.dll
Create a new section above main and paste the following script in it.
SCRIPT
The Script
[code]#==============================================================================
# ? Audio
#------------------------------------------------------------------------------
# Credits to Andreas21 © 2004 for the Winamp.dll
#
# Credits to Selwyn/Squall
#==============================================================================
module Audio
#==========================================================================
# ? Winamp
#==========================================================================
class Winamp
#------------------------------------------------------------------------
# ? initialize
#------------------------------------------------------------------------
def initialize
in_dll = 'DLL\in_psf.dll'
out_dll = 'DLL\out_wave.dll'
winamp_dll = 'DLL\Winamp.dll'
@ReadIni = Win32API.new('kernel32', 'GetPrivateProfileStringA', 'PPPPLP', 'L')
@FindWindow = Win32API.new('user32', 'FindWindowA', 'PP', 'L')
@Init_Winamp = Win32API.new(winamp_dll, 'Init_Winamp', 'PPL', 'L')
@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_IsPlaying = Win32API.new(winamp_dll, 'Winamp_IsPlaying', '', 'L')
@Winamp_GetFileInfo = Win32API.new(winamp_dll, 'Winamp_GetFileInfo', 'PL', 'P')
@Winamp_SetVolume = Win32API.new(winamp_dll, 'Winamp_SetVolume', 'L', '')
@Winamp_IsPaused = Win32API.new(winamp_dll, 'Winamp_IsPaused', '', 'L')
@Init_Winamp.call(in_dll, out_dll, setup)
end
def play(file)
return @Winamp_Play.call(file)
end
def pause
@Winamp_Pause.call()
end
def stop
return @Winamp_Stop.call()
end
def is_playing?
return @Winamp_IsPlaying.call()
end
def get_file_info(playfile, length_adr)
return @Winamp_GetFileInfo.call(playfile, length_adr)
end
def set_volume(volume)
@Winamp_SetVolume.call(volume)
end
def is_paused?
return @Winamp_IsPaused.call()
end
def setup
game_name = 0.chr * 255
v = @ReadIni.call('Game', 'Title', '', game_name, 255, ".\\Game.ini")
return @FindWindow.call('RGSS Player', game_name.slice!(0, v))
end
end
#--------------------------------------------------------------------------
# ? define constant
#--------------------------------------------------------------------------
WINAMP = Winamp.new
#--------------------------------------------------------------------------
# ? Audio.psf_play(filename, [volume])
#--------------------------------------------------------------------------
def self.psf_play(filename, volume = 255)
for extension in ['.psf', '.minipsf', '.psf2', '.minipsf2']
if FileTest.exist?(filename + extension)
filename = filename + extension
break
end
end
WINAMP.play(filename)
WINAMP.set_volume(volume)
end
#--------------------------------------------------------------------------
# ? Audio.psf_playing?
#--------------------------------------------------------------------------
def self.psf_playing?
if WINAMP.is_playing? == 0
return false
else
return true
end
end
#--------------------------------------------------------------------------
# ? Audio.psf_pause
#--------------------------------------------------------------------------
def self.psf_pause
WINAMP.pause
end
#--------------------------------------------------------------------------
# ? Audio.psf_paused?
#--------------------------------------------------------------------------
def self.psf_paused?
if WINAMP.is_paused? == 0
return false
else
return true
end
end
#--------------------------------------------------------------------------
# ? Audio.psf_stop
#--------------------------------------------------------------------------
def self.psf_stop
WINAMP.stop
end
end
#==============================================================================
# ? Game_System
#------------------------------------------------------------------------------
# Changes added to the bgm_play and bgm_stop functions.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# ? Play Back Ground Music
#--------------------------------------------------------------------------
def bgm_play(bgm)
@playing_bgm = bgm
if bgm != nil and bgm.name != ""
Audio.bgm_play("Audio/BGM/" + bgm.name, bgm.volume, bgm.pitch)
Audio.psf_play("Audio/BGM/" + bgm.name, bgm.volume)
else
Audio.bgm_stop
Audio.psf_stop
end
Graphics.frame_reset
end
#--------------------------------------------------------------------------
# ? Stop playing BGM
#--------------------------------------------------------------------------
def bgm_stop
Audio.bgm_stop
Audio.psf_stop
end
end[code]
# ? Audio
#------------------------------------------------------------------------------
# Credits to Andreas21 © 2004 for the Winamp.dll
#
# Credits to Selwyn/Squall
#==============================================================================
module Audio
#==========================================================================
# ? Winamp
#==========================================================================
class Winamp
#------------------------------------------------------------------------
# ? initialize
#------------------------------------------------------------------------
def initialize
in_dll = 'DLL\in_psf.dll'
out_dll = 'DLL\out_wave.dll'
winamp_dll = 'DLL\Winamp.dll'
@ReadIni = Win32API.new('kernel32', 'GetPrivateProfileStringA', 'PPPPLP', 'L')
@FindWindow = Win32API.new('user32', 'FindWindowA', 'PP', 'L')
@Init_Winamp = Win32API.new(winamp_dll, 'Init_Winamp', 'PPL', 'L')
@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_IsPlaying = Win32API.new(winamp_dll, 'Winamp_IsPlaying', '', 'L')
@Winamp_GetFileInfo = Win32API.new(winamp_dll, 'Winamp_GetFileInfo', 'PL', 'P')
@Winamp_SetVolume = Win32API.new(winamp_dll, 'Winamp_SetVolume', 'L', '')
@Winamp_IsPaused = Win32API.new(winamp_dll, 'Winamp_IsPaused', '', 'L')
@Init_Winamp.call(in_dll, out_dll, setup)
end
def play(file)
return @Winamp_Play.call(file)
end
def pause
@Winamp_Pause.call()
end
def stop
return @Winamp_Stop.call()
end
def is_playing?
return @Winamp_IsPlaying.call()
end
def get_file_info(playfile, length_adr)
return @Winamp_GetFileInfo.call(playfile, length_adr)
end
def set_volume(volume)
@Winamp_SetVolume.call(volume)
end
def is_paused?
return @Winamp_IsPaused.call()
end
def setup
game_name = 0.chr * 255
v = @ReadIni.call('Game', 'Title', '', game_name, 255, ".\\Game.ini")
return @FindWindow.call('RGSS Player', game_name.slice!(0, v))
end
end
#--------------------------------------------------------------------------
# ? define constant
#--------------------------------------------------------------------------
WINAMP = Winamp.new
#--------------------------------------------------------------------------
# ? Audio.psf_play(filename, [volume])
#--------------------------------------------------------------------------
def self.psf_play(filename, volume = 255)
for extension in ['.psf', '.minipsf', '.psf2', '.minipsf2']
if FileTest.exist?(filename + extension)
filename = filename + extension
break
end
end
WINAMP.play(filename)
WINAMP.set_volume(volume)
end
#--------------------------------------------------------------------------
# ? Audio.psf_playing?
#--------------------------------------------------------------------------
def self.psf_playing?
if WINAMP.is_playing? == 0
return false
else
return true
end
end
#--------------------------------------------------------------------------
# ? Audio.psf_pause
#--------------------------------------------------------------------------
def self.psf_pause
WINAMP.pause
end
#--------------------------------------------------------------------------
# ? Audio.psf_paused?
#--------------------------------------------------------------------------
def self.psf_paused?
if WINAMP.is_paused? == 0
return false
else
return true
end
end
#--------------------------------------------------------------------------
# ? Audio.psf_stop
#--------------------------------------------------------------------------
def self.psf_stop
WINAMP.stop
end
end
#==============================================================================
# ? Game_System
#------------------------------------------------------------------------------
# Changes added to the bgm_play and bgm_stop functions.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# ? Play Back Ground Music
#--------------------------------------------------------------------------
def bgm_play(bgm)
@playing_bgm = bgm
if bgm != nil and bgm.name != ""
Audio.bgm_play("Audio/BGM/" + bgm.name, bgm.volume, bgm.pitch)
Audio.psf_play("Audio/BGM/" + bgm.name, bgm.volume)
else
Audio.bgm_stop
Audio.psf_stop
end
Graphics.frame_reset
end
#--------------------------------------------------------------------------
# ? Stop playing BGM
#--------------------------------------------------------------------------
def bgm_stop
Audio.bgm_stop
Audio.psf_stop
end
end[code]
THE .DLL RESOURCES
in_psf.dll
out_wave.dll
Winamp.dll
TO USE IT
Download your psf files in the Audio/BGM folder and use them as you normally would for any other audio file.
Note that the files will only play in-game.
TERMS AND CONDITIONS
Give credit, enjoy!