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 6202
1021 키입력 한글입력스크립트 16 file 아방스 2007.11.09 11828
1020 온라인 채팅 가능 온라인 스크립트 배포 107 file 아방스 2009.01.03 10685
1019 온라인 RPG 만들기 xp 온라인 스크립트 33 아방스 2007.11.09 9601
1018 맵/타일 [유니크급] RPG XP 게임을 3D화로 보자! Neo Mode7 script / 52 file 쉴더 2009.02.28 9447
1017 온라인 온라인 스크립트 Unis Net RMXP 공식 배포! 25 file 뮤바보 2011.12.25 9403
1016 온라인 광넷[ 광땡 온라인 + 넷플레이 ] 62 - 하늘 - 2009.08.02 9003
1015 전투 [액알]neo_a-rpg_module_1[1][1].2 스크립트 83 file 은빛바람 2009.10.03 8307
1014 이름입력 대화창에 얼굴, 이름 띄우기 37 킬라롯 2008.11.09 7497
1013 온라인 넷플레이1.7.0+abs5.5+한챗 49 쀍뛝쒧 2009.01.24 7289
1012 메뉴 메이플스토리처럼 메뉴를^^ 57 file 딸기님 2010.07.13 7145
1011 메시지 대화창에 얼굴 그래픽 띠우기 73 아방스 2007.11.09 7119
1010 스킬 ABP액알 v1.2 스킬추가, 버그수정판 36 file 백호 2009.02.22 6920
1009 전투 [신기술 체험] 강회된 횡스크롤 액알 13 file 백호 2009.02.22 6841
1008 메뉴 온라인메뉴처럼!! 메이플 메뉴처럼!! 변신~스크립트 33 WMN 2008.03.17 6824
1007 그래픽 화면을 부드럽게 해주는스크립트[ 아주 유용] 56 file - 하늘 - 2009.08.05 6566
1006 온라인 Mr.Metring NPE 1.0 [RPG XP 온라인 스크립트] 35 아방스 2009.01.07 6535
1005 이름입력 케릭터 위에 또는 NPC 위에 이름 뛰우기 [헬악이님 제공] 49 file 아방스 2007.11.09 6414
1004 액터 시트르산의 XP용 감정 말풍선 표시 스크립트 37 file 시트르산 2011.01.25 6114
1003 HUD 주인공,NPC이름 머리 나타내기 49 file 송긔 2010.11.28 6067
1002 전투 액알 스크립트 24 백호 2009.02.22 6017
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 52 Next
/ 52