Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SPC Script
#1
SPC Script
Plays SPC (Snes Format Sound)
HappyDragon
Apr 3 2006

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


I found this script a while ago , its not in the archives so i thout i'd post it here.

I did not make this script and also I don't know who did.
Code:
#================================================= =============================
# ■ Audio
#------------------------------------------------------------------------------
# Please note that this will play .SPC files ONLY IN GAME, not in the player.
#
#================================================= =============================
module Audio
#================================================= =========================
# ■ Winamp
#================================================= =========================
class Winamp
#------------------------------------------------------------------------
# ● initialize
#------------------------------------------------------------------------
def initialize
in_dll = 'DLL\in_snes.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.wow * 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.spc_play(filename, [volume])
#--------------------------------------------------------------------------
def self.spc_play(filename, volume = 255)
for extension in ['.spc']
if FileTest.exist?(filename + extension)
filename = filename + extension
break
end
end
WINAMP.play(filename)
WINAMP.set_volume(volume)
end
#--------------------------------------------------------------------------
# ● Audio.spc_playing?
#--------------------------------------------------------------------------
def self.spc_playing?
if WINAMP.is_playing? == 0
return false
else
return true
end
end
#--------------------------------------------------------------------------
# ● Audio.spc_pause
#--------------------------------------------------------------------------
def self.spc_pause
WINAMP.pause
end
#--------------------------------------------------------------------------
# ● Audio.spc_paused?
#--------------------------------------------------------------------------
def self.spc_paused?
if WINAMP.is_paused? == 0
return false
else
return true
end
end
#--------------------------------------------------------------------------
# ● Audio.spc_stop
#--------------------------------------------------------------------------
def self.spc_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.spc_play("Audio/BGM/" + bgm.name, bgm.volume)
else
Audio.bgm_stop
Audio.spc_stop
end
Graphics.frame_reset
end
#--------------------------------------------------------------------------
# ● Stop playing BGM
#--------------------------------------------------------------------------
def bgm_stop
Audio.bgm_stop
Audio.spc_stop
end
end

Script Notes
QUOTEAs I was checking the RMXP.net forums for scripts, I stumbled upon a script that allowed the use of .PSF files and the like in RMXP games. I thought, what a great idea, but it doesn't allow the use of the best format, .SPC, aka music from SNES games. So, I modded around with it and this is what I came up with:

(Note, you will need to make a folder with your project called DLL and it will need to contain 4 Winamp Plugins, Winamp.dll, in_snes.dll, out_wave.dll, and snesapu.dll.)

(Also note, this will ONLY play .SPC files in your game, and naturally, you will need to manually add the .SPC files to your audio folder.)

Make sure to put this as a new script above main.
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Emotion Script Ánemus 0 2,160 08-29-2008, 01:00 PM
Last Post: Ánemus
  Beran's iPod script Sniper308 0 2,570 08-09-2008, 01:00 PM
Last Post: Sniper308
  NeoABS & NeoSABS ()enemy processes script azrith001 0 2,331 04-04-2008, 01:00 PM
Last Post: azrith001
  Blur Effect Script Hadriel 0 2,527 01-30-2008, 01:00 PM
Last Post: Hadriel
  Warp Script Sheol 0 2,528 12-28-2007, 01:00 PM
Last Post: Sheol
  AIM Script Pack vgvgf 0 2,805 09-13-2007, 01:00 PM
Last Post: vgvgf
  Audio Encryption Script InfiniteSpawn 0 2,211 05-09-2007, 01:00 PM
Last Post: InfiniteSpawn
  Credits Script Remake avatarmonkeykirby 0 2,227 03-10-2007, 01:00 PM
Last Post: avatarmonkeykirby
  Leon Blade's Percent Script Leon Blade 0 2,223 03-05-2007, 01:00 PM
Last Post: Leon Blade
  Cogwheels original pixelmovement script!!! mechacrash 0 2,151 01-14-2007, 01:00 PM
Last Post: mechacrash



Users browsing this thread: