Introduction Hi, I present one of the first scripts that uses the RGSS Linker !

This script is a rewrite of Audio module to use the C/C++ functions coded in the RGSS FmodEx.dll and RGSS Linker.dll DLLs.

RGSS FmodEx.dll depends on fmodex.dll, therefore to avoid the dependences problems, I included the file in the following archive :

You must paste these files in your project's root and everything should be fine.



Update of the DLL :

http://www.mediafire.com/file/knt7ran4nhbw0sq/RGSS_FmodEx.dll

http://www.mediafire.com/file/vj64d7cuwj2ct27/fmodex.dll



Note : This files were analysed by Kapersky and doesn't contain viruses, if a virus is found by your antivirus, it's a false positive.

The RGSS Linker is a bit special, it links RGSS functions in dynamic way by using static metric. Some AV such as Avast have difficulties with that and panick for nothing. Hi, I present one of the first scripts that uses the RGSS Linker !This script is a rewrite of Audio module to use the C/C++ functions coded in the RGSS FmodEx.dll and RGSS Linker.dll DLLs.RGSS FmodEx.dll depends on fmodex.dll, therefore to avoid the dependences problems, I included the file in the following archive : http://www.mediafire.com/download/jrlci7hwh5z0zhe/Fichiers+DLL+FmodEX.zip You must paste these files in your project's root and everything should be fine.: This files were analysed by Kapersky and doesn't contain viruses, if a virus is found by your antivirus, it's a false positive.The RGSS Linker is a bit special, it links RGSS functions in dynamic way by using static metric. Some AV such as Avast have difficulties with that and panick for nothing.

RGSS Linker script This script permit to define the necessaries methods for the good function of the next script.

Your project must use RGSS104E.dll for that script function properly.

#=== #RGSS Linker (Kernel) # Function that helps the load of extentions using RGSS Linker. #--- #© 2015 - Nuri Yuri (塗 ゆり) #=== module Kernel unless @RGSS_Linker #>To avoid the RGSS Reset problem @RGSS_Linker = {:core => Win32API.new("RGSS Linker.dll","RGSSLinker_Initialize","p","i")} Win32API.new("kernel32","GetPrivateProfileString","ppppip","i").call("Game","Library",0,lib_name = "\x00"*32,32,".//Game.ini") raise LoadError, "Failed to load RGSS Linker." unless(@RGSS_Linker[:core].call(lib_name)==1) lib_name = nil module_function #=== #>Kernel.load_module # Helps to load a RGSS extension #--- #I : module_filename : String : Name of the file which contains the extension # module_function : String : Name of the function that will load the extension #=== def load_module(module_filename, module_function) return if @RGSS_Linker[module_filename] mod = @RGSS_Linker[module_filename] = Win32API.new(module_filename, module_function, "", "") mod.call end end #>unless @RGSS_Linker end This script permit to define the necessaries methods for the good function of the next script.Your project must use RGSS104E.dll for that script function properly.

Audio module Script (FmodEx) This script must be placed after the RGSS Linker script otherwise it won't work.

#=== #Audio (FmodEx) # A rewrite of Audio module to integrate FmodEx #--- #© 2015 - Nuri Yuri (塗 ゆり) #© 2015 - GiraPrimal : Concept of LOOP_TABLE #--- #Script written by the menbers of the Community Script Project #=== module Audio LOOP_TABLE = [ # [ "Audio/xxx/File_name", begin, end ] # Add here # Note : Renember to add a comma after each ] # (except for the last line and the below ]). ] #--- #>Puts the file names in lowercase to improve the search #--- LOOP_TABLE.each do |i| i[0].downcase! end unless @bgm_play #>To avoid the RGSSReset problem #=== #>Load and initialize FmodEx #=== Kernel.load_module("RGSS FmodEx.dll","Init_FmodEx") ::FmodEx.init(32) #--- #>Indication of the default lib' #--- @library = ::FmodEx #--- #>Saving the RGSS functions #--- @bgm_play = method(:bgm_play) @bgm_fade = method(:bgm_fade) @bgm_stop = method(:bgm_stop) @bgs_play = method(:bgs_play) @bgs_fade = method(:bgs_fade) @bgs_stop = method(:bgs_stop) @me_play = method(:me_play) @me_fade = method(:me_fade) @me_stop = method(:me_stop) @se_play = method(:se_play) @se_stop = method(:se_stop) #--- #>Volumes definition #--- @master_volume = 100 @sfx_volume = 100 #=== #>Extensions supported by FmodEx #=== EXT = ['.ogg', '.mp3', '.wav', '.mid', '.aac', '.wma', '.it', '.xm', '.mod', '.s3m', '.midi'] #=== #>Creation/definition of the functions #=== module_function def bgm_play(file_name, volume = 100, pitch = 100) volume = volume * @master_volume / 100 return @bgm_play.call(file_name, volume, pitch) if(@library != ::FmodEx) filename = check_file(file_name) bgm = ::FmodEx.bgm_play(filename, volume, pitch) loop_audio(bgm, file_name) end def bgm_fade(time) return @bgm_fade.call(time) if(@library != ::FmodEx) ::FmodEx.bgm_fade(time) end def bgm_stop return @bgm_stop.call if(@library != ::FmodEx) ::FmodEx.bgm_stop end def bgs_play(file_name, volume = 100, pitch = 100) volume = volume * @sfx_volume / 100 return @bgs_play.call(file_name, volume, pitch) if(@library != ::FmodEx) filename = check_file(file_name) bgs = ::FmodEx.bgs_play(filename, volume, pitch) loop_audio(bgs, file_name) end def bgs_fade(time) return @bgs_fade.call(time) if(@library != ::FmodEx) ::FmodEx.bgs_fade(time) end def bgs_stop return @bgs_stop.call if(@library != ::FmodEx) ::FmodEx.bgs_stop end def me_play(file_name, volume = 100, pitch = 100) volume = volume * @master_volume / 100 return @me_play.call(file_name, volume, pitch) if(@library != ::FmodEx) file_name = check_file(file_name) ::FmodEx.me_play(file_name, volume, pitch) end def me_fade(time) return @me_fade.call(time) if(@library != ::FmodEx) ::FmodEx.me_fade(time) end def me_stop return @me_stop.call if(@library != ::FmodEx) ::FmodEx.me_stop end def se_play(file_name, volume = 100, pitch = 100) volume = volume * @sfx_volume / 100 return @se_play.call(file_name, volume, pitch) if(@library != ::FmodEx) file_name = check_file(file_name) ::FmodEx.se_play(file_name, volume, pitch) end def se_stop return @se_stop.call if(@library != ::FmodEx) ::FmodEx.se_stop end #=== #>check_file # Check the presence of the file and return the filename # /!\ Doesn't correct the mistake #==== def check_file(file_name) return file_name if File.exist?(file_name) EXT.each do |ext| filename = file_name+ext return filename if File.exist?(filename) end return file_name end #=== #>loop_audio # Function that automatically call the set_loop_points #=== def loop_audio(sound, file_name) filename = file_name.downcase LOOP_TABLE.each do |i| if(i[0] == filename) return sound.set_loop_points(i[1], i[2]) end end end end end Note : The begin and end contained in LOOP_TABLE must be in milliseconds. They apply only for the BGM and BGS. This script must be placedthescript otherwise it won't work.Note : The begin and end contained in LOOP_TABLE must be in milliseconds. They apply only for the BGM and BGS.

FmodEx::Sound methods Here are the methods of the FmodEx::Sound class.

At the exception of initialize, the following methods can return nil.

Think check if the result is not nil before using them in calculations.



You can create a sound independently of the BGM, BGS, ME and SE by using the "new" method of FmodEx::Sound (with the arguments of the initialize method).

initialize(filename, volume = 100, pitch = 100, position = 0, looping = true, streaming = true, *args)

Initialize a sound.

Arguments : filename, volume, pitch, position, looping, streaming, memory_data, dls_file_name

Optional from volume (include)

If the position is less than 0, sound will initially paused.

memory_data corresponds at a string/channel who contains the file data.

dls_file_name is the name of the dls file used to read the midis.



stop

Stop the sound (automatically release the channel and the sound)

Return true if the stop was made, false if stop isn't possible.

Raise a FmodEx::Error exception if FmodEx fails and no Fade Thread is associated with sound.



fade(time_ms)

Fade out of a sound.

The user indicate the time in milliseconds.

Return true if the sound fade was triggered, false if not.



pause(pause_state)

Pausing a sound.

The user indicates if he wants the sound to be paused (true) or played (false).

Returns requested pause status, or nil if it is not possible.

Raises a FmodEx :: Error exception if FmodEx can not paused the sound.



paused?

Retrieve the "pause" status of a sound.

Return true if the sound is in pause, false if not.

Raise a FmodEx::Error exception if FmodEx cannot retrieve the status.



set_loop_points(begin_pt, end_pt)

Indicate the loop points of the sound.

If the sound is looped, the user can indicate the begin and end of the loop in milliseconds.

Returns true if this was done, nil if this is not possible.

Raise a FmodEx::Error exception if FmodEx cannot save the loop points.



set_looping(state)

Indicate the loop possibility.

The user indicates if he wants the sound is looped (true) or not (false)

Returns the requested status, nil if is not possible.

Raise a FmodEx::Error exception if FmodEx cannot modify the sound status.



looping?

Return if the sound is looped or not.

Raise a FmodEx::Error exception if FmodEx cannot retrieve the status.



set_position(position_ms)

Indicates the playing position of a sound.

The user indicate the playing position in milliseconds.

Return the requested position if it cannot save.

Raise a FmodEx::Error exception if FmodEx cannot modify the position.



get_position

Return the actual position of the sound playing.

Raise a FmodEx::Error exception if FmodEx fails.



set_volume(volume)

Indication of sound volume.

The user indicates the desired volume between 0 and 100.

Returns the requested volume if realized.

Raise a FmodEx::Error exception if FmodEx fails.



get_volume

Returns the sound volume.

Raise a FmodEx::Error exception if FmodEx cannot retrieve the volume.



set_frequency(frequency)

Indicate the sound frequency.

Return the indicated frequency if it was realized.

Raise a FmodEx::Error exception if FmodEx cannot change the sound frequency.



get_frequency

Retrieve the sound frequency .

Raise a FmodEx::Error exception if FmodEx cannot retrieve the sound playing frequency.



set_pan(pan)

Indicates the sound pan (-100 = Left, 0 = Center, 100 = right)

Return the requested value.

Raise a FmodEx::Error exception if FmodEx cannot modify the pan.



get_pan

Retrieve sound pan.

Raise a FmodEx::Error exception if FmodEx cannot retrieve the pan.



playing?

Is FmodEx currently playing the sound ?

Return true if is the case.

Raise a FmodEx::Error exception if FmodEx cannot know what it does of the sound.



length

Retrieve the sound temporal length in milliseconds.

Raise a FmodEx::Error exception if FmodEx cannot retrieve the sound length. Here are the methods of the FmodEx::Sound class.At the exception of initialize, the following methods can return nil.Think check if the result is not nil before using them in calculations.You can create a sound independently of the BGM, BGS, ME and SE by using the "new" method of FmodEx::Sound (with the arguments of the initialize method).(filename, volume = 100, pitch = 100, position = 0, looping = true, streaming = true, *args)Initialize a sound.Arguments : filename, volume, pitch, position, looping, streaming, memory_data, dls_file_nameOptional from volume (include)If the position is less than 0, sound will initially paused.memory_data corresponds at a string/channel who contains the file data.dls_file_name is the name of the dls file used to read the midis.Stop the sound (automatically release the channel and the sound)Return true if the stop was made, false if stop isn't possible.Raise a FmodEx::Error exception if FmodEx fails and no Fade Thread is associated with sound.(time_ms)Fade out of a sound.The user indicate the time in milliseconds.Return true if the sound fade was triggered, false if not.(pause_state)Pausing a sound.The user indicates if he wants the sound to be paused (true) or played (false).Returns requested pause status, or nil if it is not possible.Raises a FmodEx :: Error exception if FmodEx can not paused the sound.Retrieve the "pause" status of a sound.Return true if the sound is in pause, false if not.Raise a FmodEx::Error exception if FmodEx cannot retrieve the status.(begin_pt, end_pt)Indicate the loop points of the sound.If the sound is looped, the user can indicate the begin and end of the loop in milliseconds.Returns true if this was done, nil if this is not possible.Raise a FmodEx::Error exception if FmodEx cannot save the loop points.(state)Indicate the loop possibility.The user indicates if he wants the sound is looped (true) or not (false)Returns the requested status, nil if is not possible.Raise a FmodEx::Error exception if FmodEx cannot modify the sound status.Return if the sound is looped or not.Raise a FmodEx::Error exception if FmodEx cannot retrieve the status.(position_ms)Indicates the playing position of a sound.The user indicate the playing position in milliseconds.Return the requested position if it cannot save.Raise a FmodEx::Error exception if FmodEx cannot modify the position.Return the actual position of the sound playing.Raise a FmodEx::Error exception if FmodEx fails.(volume)Indication of sound volume.The user indicates the desired volume between 0 and 100.Returns the requested volume if realized.Raise a FmodEx::Error exception if FmodEx fails.Returns the sound volume.Raise a FmodEx::Error exception if FmodEx cannot retrieve the volume.(frequency)Indicate the sound frequency.Return the indicated frequency if it was realized.Raise a FmodEx::Error exception if FmodEx cannot change the sound frequency.Retrieve the sound frequency .Raise a FmodEx::Error exception if FmodEx cannot retrieve the sound playing frequency.(pan)Indicates the sound pan (-100 = Left, 0 = Center, 100 = right)Return the requested value.Raise a FmodEx::Error exception if FmodEx cannot modify the pan.Retrieve sound pan.Raise a FmodEx::Error exception if FmodEx cannot retrieve the pan.Is FmodEx currently playing the sound ?Return true if is the case.Raise a FmodEx::Error exception if FmodEx cannot know what it does of the sound.Retrieve the sound temporal length in milliseconds.Raise a FmodEx::Error exception if FmodEx cannot retrieve the sound length.

FmodEx module methods

FmodEx.init(nb_of_channels)

FmodEx initialisation.

nb_of_channels indicate the desired number of channels.

Return true if is succeed, false if already initialized.

Raise a FmodEx::Error exception if FmodEx fails in its task.



FmodEx.bgm_play(filename, volume = 100, pitch = 100, streaming = true, *args)

Play a ME.

Returns the ME sound playing.

Arguments : filename [,volume [, pitch [, streaming [, memory [, dls]]]]]

memory is the string that contain the file in RAM.

dls_file_name is the name of the dls file used to read the midis.



FmodEx.bgm_stop

Stop a BGM.



FmodEx.bgm_fade(time_ms)

Fade the BGM out.

time_ms is the fade out time in milliseconds.



FmodEx.bgm_sound

Retrieve the object FmodEx::Sound of BGM.

Can be nil if no BGM is played.



FmodEx.bgs_play(filename, volume = 100, pitch = 100, streaming = true, *args)

Play a BGS.

Returns the BGS sound playing.

Arguments : filename [,volume [, pitch [, streaming [, memory [, dls]]]]]

memory is the string that contain the file in RAM.

dls_file_name is the name of the dls file used to read the midis.



FmodEx.bgs_stop

Stop a BGS.



FmodEx.bgs_fade(time_ms)

Fade the BGS out.

time_ms is the fade out time in milliseconds.



FmodEx.bgs_sound(filename, volume = 100, pitch = 100, streaming = true, *args)

Retrieve the object FmodEx::Sound of BGS.

Can be nil if no BGS is played.



FmodEx.me_play

Play a ME.

Returns the ME sound.

Arguments : filename [,volume [, pitch [, streaming [, memory [, dls]]]]]

memory is the string that contain the file in RAM.

dls_file_name is the name of the dls file used to read the midis.



FmodEx.me_stop

Stop a ME.



FmodEx.fade_out(time_ms)

Fade the ME out.

time_ms is the fade out time in milliseconds.



FmodEx.me_sound

Retrieve the object FmodEx::Sound of ME.

Can be nil if no ME is played.



FmodEx.se_play(filename, volume = 100, pitch = 100, streaming = true, *args)

Play a SE.

Returns the SE sound.

Arguments : filename [,volume [, pitch [, streaming [, memory [, dls]]]]]

memory is the string that contain the file in RAM.

dls_file_name is the name of the dls file used to read the midis.



FmodEx.se_stop

Stops the SE. (nb_of_channels)FmodEx initialisation.nb_of_channels indicate the desired number of channels.Return true if is succeed, false if already initialized.Raise a FmodEx::Error exception if FmodEx fails in its task.(filename, volume = 100, pitch = 100, streaming = true, *args)Play a ME.Returns the ME sound playing.Arguments : filename [,volume [, pitch [, streaming [, memory [, dls]]]]]memory is the string that contain the file in RAM.dls_file_name is the name of the dls file used to read the midis.Stop a BGM.(time_ms)Fade the BGM out.time_ms is the fade out time in milliseconds.Retrieve the object FmodEx::Sound of BGM.Can be nil if no BGM is played.(filename, volume = 100, pitch = 100, streaming = true, *args)Play a BGS.Returns the BGS sound playing.Arguments : filename [,volume [, pitch [, streaming [, memory [, dls]]]]]memory is the string that contain the file in RAM.dls_file_name is the name of the dls file used to read the midis.Stop a BGS.(time_ms)Fade the BGS out.time_ms is the fade out time in milliseconds.(filename, volume = 100, pitch = 100, streaming = true, *args)Retrieve the object FmodEx::Sound of BGS.Can be nil if no BGS is played.Play a ME.Returns the ME sound.Arguments : filename [,volume [, pitch [, streaming [, memory [, dls]]]]]memory is the string that contain the file in RAM.dls_file_name is the name of the dls file used to read the midis.Stop a ME.(time_ms)Fade the ME out.time_ms is the fade out time in milliseconds.Retrieve the object FmodEx::Sound of ME.Can be nil if no ME is played.(filename, volume = 100, pitch = 100, streaming = true, *args)Play a SE.Returns the SE sound.Arguments : filename [,volume [, pitch [, streaming [, memory [, dls]]]]]memory is the string that contain the file in RAM.dls_file_name is the name of the dls file used to read the midis.Stops the SE.