How to edit system sound effects?

Hi! 🙂

Does anyone know if it's possible to edit system sound effects through script calls? 😅 For example "cursor", "OK", "cancel" and "buzzer" sounds. It'd be really useful for me to have a method to do so in-game through events, so that I won't have to use the same sound effects throughout the whole game.

Hopefully, there's someone who can help me. 😉
Say, "Sound1" was used in early game
Now you want "Sound2" to be played when entering mid/end game?
Is that what you want?
Hi, TheoAllen!

Thank you for taking an interest in resolving this issue.

Yes, that is what I want.

The reason is that I have one set of sounds for the menu and choices in general. But when using choices for puzzles and say, mini-games, I want the sounds to differ. In order to make them differ, I need to be able to change them temporarily for the puzzles with a script call, before changing the sounds back to general again later.
I wrote a quick snippet, don't have much time to test if it works or broken, or to give detailed instruction. But here
Code:
#===============================================================================
# Sound Replacer
# By: TheoAllen
#-------------------------------------------------------------------------------
# Want to temporarily change sound effect? This is your solution
#===============================================================================
module Sound
 
  def self.init
    @replacer = {}
  end
 
  def self.change_sound(index, se)
    @replacer[index] = se
  end
 
  def self.play_system_sound(n)
    if @replacer[n].is_a?(RPG::SE)
      @replacer[n].play
      return
    end
    $data_system.sounds[n].play
  end
 
end
Sound.init
Usage would be in script call, write
Code:
Sound.change_sound(index, RPG::SE.new("sound name", vol, pitch))
You can see the index in default script, Sound module
For example, in Sound module it's written
Code:
  def self.play_ok
    play_system_sound(1)
  end
So if you want to change ok sound, put index as 1

If you want to revert back to original sound effect, use script cal
Code:
Sound.init

Edit :
It also not saved on save file information.
So if you replace the SE, it will replace the SE until either you reset em manually or restart the game by closing then reopen the game.exe
Just needed a few minor changes.
Code:
#===============================================================================
# Sound Replacer
# By: TheoAllen
#-------------------------------------------------------------------------------
# Want to temporarily change sound effect? This is your solution
#===============================================================================
# Usage would be in script call, write
# Sound.change_sound(index, RPG::SE.new("sound name", vol, pitch))
#
=begin
Index        name
0            cursor
1            ok
2            cancel
3            buzzer
4            equip
5            save
6            load
7            battle start
8            escape
9            enemy attack
10            enemy damage
11            enemy collaspe
12            boss collaspe1
13            boss collaspe2
14            actor damage
15            actor collaspe
16            recovery
17            miss
18            evasion
19            magic evasion
20            reflection
21            shop
22            use item
23            use skill
=end

module Sound
 
  def self.init
    @replacer = []
  end
 
  def self.change_sound(n, se)
    @replacer[n] = se
  end
 
  def self.play_system_sound(n)
    if @replacer[n].is_a?(RPG::SE)
      @replacer[n].play
      return
    end
    $data_system.sounds[n].play
  end
 
end
Sound.init

But otherwise it works.

Moved to Script Requests



Since a script was used.
Thank you so much, TheoAllen, for creating the script, Sound Replacer.

And thank you too, Rominator2, for the edit. Your help is appreciated.

I'm overjoyed to say that I've tested it and it works perfectly!
I know this is quite old, but I'm hoping to get some help with this. One one occasion I was able to get this to work, so I have to believe it's something I'm doing wrong...

I'm typing :


Sound.change_sound(0, RPG::SE.new
("cursormove", 100, 100))

I think the issue has something to do with the shortness of the script window. TheoAllen's post has it written in one line. I'm copying the script call straight from this thread but it's giving me trouble.


Update : So it does look like the issue was with the length of the script call. For the benefit of anyone else having this issue with this very useful script, to fix it I've modified the script to work with the call :

Sound.cs(index, RPG::SE.new("sound name", vol, pitch))

instead of change_sound to conserve some space, as well as shortened some file names.


One quirky thing I've found with this is that if you change the system sounds mid game, then return to the title screen, the changes stick. But when the player launches the game again, they return to normal. If anyone knows of a way to make it so that the changed sound effects do not remain when returning to the title screen I'd be grateful. As it is now, if you want to have title screen specific sounds, you have to change them back to the title screen sounds prior to calling the save menu; otherwise if the player saves the game and then returns to the title screen they will hear in game sounds instead of the title screen sounds.
something I'm doing wrong
The script and the information provided is for RPG Maker VX Ace. Your screen shot shows you are using VX.
So good on you for making it work.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-edit-system-sound-effects.93561/