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 script problem

I have the script that lets you play psf files with RPG Maker XP but the musci dosent loop. It plays through once and stops. Here's the script:
Code:
#==============================================================================
# â–  Audio
#------------------------------------------------------------------------------
# Credits for Winamp class and Winamp.dll to Andreas21 (C) 2004
# 
# Credits to Squall for Audio module and Game_system functions.
# squall@loeher.zzn.com
#
#==============================================================================
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', %w(p p p p l p), 'l')
     @FindWindow = Win32API.new('user32', 'FindWindowA', %w(p p), 'l')
     @Init_Winamp = Win32API.new(winamp_dll, 'Init_Winamp', %w(p p l), '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', %w(p l), '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
     zeichen = @ReadIni.call('Game', 'Title', '', game_name, 255, ".\\Game.ini")
     return @FindWindow.call('RGSS Player', game_name.slice!(0, zeichen))
   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
 
It's not script problem. you should configure your psf plugin to loop infinitely. find your plugin.ini from your project\DLL, and change ForceIndefinite value to 1.(if it doesn't have this line, just add it)
 
Now i have a new problem. As long as i have the DLL files in the folder, i get an error saying: "Game.exe has encountered a problem and needs to close, we are sorry for any inconvience.". This just started happing. Before, the only problem was that the files dident loop. Now, i can't even play or testplay a game that has the DLLs required to make the script work. Is there any way to fix this?
 
Hmm, not sure on that one. I think (think!) the problem may be your .dll, based on the fact that changing it caused the problem.

Try this one I've attached, it has the looping and works perfectly fine on my project. Hopefully it can work for yours too.
 
When i open it up with WinRAR, it won't let me extract the file. It says that the file is of an unknown type or is damaged. Could you attach the file itself with out zipping it? Oh, was i supposed to change the DLL or the INI file?
 

ranzu

Member

When i place this script above the main script, it makes the game crash. I have the required .dll files in the DLL/ directory, but it just crashes. I haven't modified the other scripts. I just added this. So if anyone knows what i'm doing wrong, please tell me.

I've also tried the multi audio demo, and i can play the game in it untill i try to play music files other then .mid, .mp3, .wav, or .ogg.

And i can play the .psf files and etc. on my winamp.

FIXED!!!!
 

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