Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

PSF error

kiku

Member

I tried running Guillamue777's audio extension script:

#==============================================================================
# Audio formats extension script
#------------------------------------------------------------------------------
# Guillaume777
# 3.1.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']
SNES_EXT = ['.spc']
GEN_EXT = ['.gym', '.cym']
MOD_EXT = ['.XM', '.IT', '.S3M', '.MOD', '.MTM', '.UMX', '.MO3']


PSF_DLL = 'in_psf.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 = volume * 2.55 #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)
if bgm == nil then #if not playing anything
Audio.winamp_bgm_stop
Audio.bgm_stop
return
end


@playing_bgm = bgm
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

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::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::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__________________

I have Winamp.dll, in_psf.dll, out_wave.dll and plugini.ini inside my DLL folder.
I also tried running Andreas21's PSF script but for both scripts I end up with the same runtime error when I run the game: "GetProcAddress: Init_Winamp or InitWinampA". I don't understand. Are there some files I missed to have in my DLL folder?
 
That strikingly uninformative error message is what Ruby's Win32API library produces when it can't find the function you're trying to call. In this case, it wants to find a piece of code called Init_Winamp in winamp.dll, but can't. Most likely your winamp.dll is corrupt or wrong.

The problem is, there are several things called winamp.dll on the net which are actually libraries for talking to a running winamp instance. Those will not do what you want. Try this one instead.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top