XP 스크립트


Happy_music_demo_3.0.zip


지난번에 올린 스크립트의 버전업판입니다.  이번에는 모듈사운드도 지원.(스크립트를 수정하면 윈앰프 플러그인으로 재생가능한 사운드파일은 거의 사용가능할 겁니다)  이 스크립트 사용에 필요한 winamp.dll은 예전에 올린 게시물에 첨부되어 있습니다.(아니면 데모를 받아보시든가)

Update:
 - 3.1: 일부 버그 수정(간혹 장소를 바꾸거나 전투로 들어갈 때 배경음악이 섞이는 문제 수정)

#==============================================================================
# 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']
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&uuml;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&ouml;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.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


**그런데 누가 FMODEx사용 스크립트랑 이거랑 합칠사람 없나.....(단순히 둘을 같이 사용하려고 한다면 어느 한쪽은 정상적으로 사용할 수 없는지라.  사실 OGG 스트리밍도 놓치긴 아깝죠)  아니면 BASS 라이브러리(http://www.un4seen.com/ )를 이용해서 RMXP에서 다른 사운드파일을 지원하게 한다든가......(BASS 라이브러리는 애드온으로 윈앰프 플러그인 지원이 가능)

Who's 백호

?

이상혁입니다.

http://elab.kr


List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 습작 2012.12.24 6313
461 메뉴 넷플레이 업그레이드됀 메뉴 스크립트 4 백호 2009.02.22 2040
460 전투 S ABS_NonSDK(구버전용) 5 file 백호 2009.02.22 1494
459 전투 S ABS_NonSDK ver 1 file 백호 2009.02.22 1458
458 기타 Defining Encounter Areas by RPG Advocate (사용법 첨부) file 백호 2009.02.22 1201
457 아이템 Item Acquired Window by SiliconHero@rmxp.net 백호 2009.02.22 1097
456 기타 풀스크린 스크립트 2 백호 2009.02.22 1408
455 온라인 Multi-Netplay Extended[구버전용] 3 백호 2009.02.22 2176
454 온라인 Multi-Netplay Extended (신버전) 10 백호 2009.02.22 2865
453 HUD 넷플레이 HUD표시 2 file 백호 2009.02.22 3097
452 메뉴 링 메뉴 Edited by Hypershadow180@rmxp.net 1 file 백호 2009.02.22 1976
451 전투 Steal Script 5.5 by trickster@rmxp.net (SDK호환) file 백호 2009.02.22 1206
450 기타 스크립트 자료 3 file 백호 2009.02.22 906
449 온라인 multy-netplay 로그인창에서 비밀번호를 ***표시해주는 script~! 1 백호 2009.02.22 1890
448 타이틀/게임오버 심심해서 구현해본 타이틀음악만으로 게임 플레이하기 2 백호 2009.02.22 1622
447 기타 Selected phyolomortis.com scripts 1 file 백호 2009.02.22 789
446 파티 Party Switching Screen by exseiken file 백호 2009.02.22 1305
445 기타 창고 시스템 8 백호 2009.02.22 1763
444 장비 Advanced Equip Window 백호 2009.02.22 806
443 장비 장비창 개조 스크립트 from Harts Horn 7 백호 2009.02.22 1775
» 오디오 WinAMP 플러그인을 이용하여 RMXP에서 다른 사운드포맷 지원하기 v3 by Guillame777@rmxp.net 백호 2009.02.22 936
Board Pagination Prev 1 ... 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 ... 52 Next
/ 52