Removing/Disabling music but keeping sound effects

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
User avatar
Jason Frudnick
Posts: 12
Joined: Wed Jul 11, 2018 2:24 am
Location: Batrachia, New York

Removing/Disabling music but keeping sound effects

Post by Jason Frudnick »

Would anyone have some advice about Removing/Disabling music but keeping the sound effects in a NES rom? I've tried a few things... just not sure where to begin. This is my 2nd hack; still noobing out hard here, but I'm pretty sure this game hasn't been hacked before.

Check out my first hack if you have some time to kill : http://www.romhacking.net/news/2062/
User avatar
za909
Posts: 249
Joined: Fri Jan 24, 2014 9:05 am
Location: Mijn hart woont al in Nederland

Re: Removing/Disabling music but keeping sound effects

Post by za909 »

This largely depends on how the particular sound engine is built. I personally always have two flags that allow me to disable the music and/or sound effects so that the player can change these settings. But most games probably did not bother to add any kind of separation, in which case you'll have to reverse-engineer the sound engine to find where music processing starts and where sound effect processing starts so that you can add your own code to (conditionally) skip over the music part.
User avatar
koitsu
Posts: 4201
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Removing/Disabling music but keeping sound effects

Post by koitsu »

What game? It matters.

Yes it's possible -- people doing NSF rips basically do the opposite (playing only the music tracks). However, it's long and involved, and kind of a "niche" thing because it requires, on a game-by-game basis. You won't find many (if any at all) romhacking tutorials on this subject. This is what's involved, paraphrased:

1. Reverse-engineering of the game, to figure out where the music playback code/engine is in the game (it may be in multiple places depending on the game) -- this requires extensive 6502 knowledge and general familiarity with the NES, as well as its audio registers. Many people find the audio aspects of the NES to be very tedious/daunting and tend to avoid it (I myself am one such person),

2. Reverse-engineering the engine itself, and its sequence data format for the music/sound effects. The engine has to be "understood" before it can be analysed further. Every music engine is different, although commercial companies tend to make their own engines and use them throughout games (ex. Capcom had their own, Konami had their own, Nintendo had their own, etc.), and change/tweak them over time (as newer games tended to do different things),

3. Figuring out, safely, what 6502 and/or data needs to be changed in the ROM so that effectively the sequenced music data isn't used but the sound effects are. This is a subset of item #2 above (so more like "#2b" rather than "#3"), and then doing it. This may become complicated if the desire is "disable the music played only in this one part of the game", where the music in question is actually used in several places in the game.

In other words: you really have to understand how the music engine in the game works at the 6502 level, and the data format of the sequence or effects data, to accomplish this.

A good example of the in-depth reverse-engineering of this sort was done by rainwarrior some time ago for StarTropics. The deep technical details of the reverse-engineering aren't covered in that video, but safe to say Brad had to do all of the above... then again, considering he made and released his own NES game (Lizard) his capability to do it should come as no surprise.

I might suggest posting in this thread and asking one of the people there who commonly do NSF rips if they could take a look at your thread here for general assistance. But do not hijack that thread for this project/idea you have here -- that thread has a very specific purpose. People doing NSF rips tend to be quite familiar with game sound engines and may be able to provide technical insights to certain games or certain engines, i.e. User X might have great familiarity with doing NSF rips of Capcom games, while have no experience with Acclaim games, while User Y has the opposite.
ccovell
Posts: 1045
Joined: Sun Mar 19, 2006 9:44 pm
Location: Japan
Contact:

Re: Removing/Disabling music but keeping sound effects

Post by ccovell »

If you don't know 6502 assembly, forget it; find a good Samaritan somewhere to do it for you for your particular game.

If you know 6502 assembly, it's not that hard. Just look into the NSF for a hint as to where the game code receives its value for the song or effect, and do it the dumb way: usually a range of values is music, and all values above/below that range are SFX. Write some rerouting code that CMPs #LOWER_LIMIT, and CMPs #UPPER_LIMIT to reject values above or below these.

Going as deep as the audio driver or music data format is usually not necessary; you just find the entry point for initializing tunes and filter out unwanted values.
User avatar
olddb
Posts: 188
Joined: Thu Oct 26, 2017 12:29 pm
Contact:

Re: Removing/Disabling music but keeping sound effects

Post by olddb »

What is the most common method for implement sound effects in games?

I understand it's per-game basis, but I'm asking in broad terms.

Are the effects made by the DMC channel and the rest of the channels are used by the music?
Or are the effects somehow mixed-in with the music by disabling a music channel momentarily?
Any other method?
...
User avatar
pubby
Posts: 583
Joined: Thu Mar 31, 2016 11:15 am

Re: Removing/Disabling music but keeping sound effects

Post by pubby »

olddb wrote:What is the most common method for implement sound effects in games?
Mute whatever music channel(s) are needed while the sound effects play. Different sound effects will want to use different channels, or multiple channels; it's too restrictive to force them onto one.
User avatar
olddb
Posts: 188
Joined: Thu Oct 26, 2017 12:29 pm
Contact:

Re: Removing/Disabling music but keeping sound effects

Post by olddb »

pubby wrote:
olddb wrote:What is the most common method for implement sound effects in games?
Mute whatever music channel(s) are needed while the sound effects play. Different sound effects will want to use different channels, or multiple channels; it's too restrictive to force them onto one.
Won't this cause "hiccups" in the music?
...
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Removing/Disabling music but keeping sound effects

Post by tepples »

olddb wrote:
pubby wrote:Mute whatever music channel(s) are needed while the sound effects play. Different sound effects will want to use different channels, or multiple channels; it's too restrictive to force them onto one.
Won't this cause "hiccups" in the music?
Yes. When these hiccups are short, the human auditory system ignores them under the illusory continuity of tones effect. When these hiccups are long, the player accepts them as a quirk of the NES platform. Different games apply different interruption policies:
  1. Stop the playing note, and don't start it again until both the sound effect has ended and it's time to play another note.
  2. Stop the playing note but resume it immediately once the sound effect has ended.
  3. Stop the playing note but resume it with a fade-in once the sound effect has ended.
  4. Each tick of the audio driver (usually 60 Hz), compare the volume of the playing note to the volume of the sound effect on the same channel, and play whatever is louder. In my experience, this produces better results when a sound effect has a long quiet tail, as the music is allowed to mask it.
My own audio driver "Pently" uses option D by default but can be configured at build time for option B using the PENTLY_USE_MUSIC_IF_LOUDER flag.

Previous discussions about sound effect interruption:
In any case, to minimize interruption, one convention several games use is to put pulse sound effects on channel 1 and your main melody on channel 2.
User avatar
olddb
Posts: 188
Joined: Thu Oct 26, 2017 12:29 pm
Contact:

Re: Removing/Disabling music but keeping sound effects

Post by olddb »

Thank you so much.
...
ccovell
Posts: 1045
Joined: Sun Mar 19, 2006 9:44 pm
Location: Japan
Contact:

Re: Removing/Disabling music but keeping sound effects

Post by ccovell »

A qualified "Yes" would do.
Attachments
lecturessm.jpg
User avatar
Jason Frudnick
Posts: 12
Joined: Wed Jul 11, 2018 2:24 am
Location: Batrachia, New York

Re: Removing/Disabling music but keeping sound effects

Post by Jason Frudnick »

Still having trouble locating some of the music parameters in hex code. Like everything else its doable just tricky... the joys of trial and error
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Removing/Disabling music but keeping sound effects

Post by rainwarrior »

To elaborate on the tip to use NSF rips as a guide:

NSFs will have their INIT routine called with a song number loaded into A. (In FCEUX you can actually conveniently type INIT and PLAY into the address for breakpoints.)

You can usually follow that directly to where it gets used to actually start playing a song. Often it will get stored temporarily with a PHA before some initialization routines, or look up a second number from a table added by the NSF ripper, but ultimately that value in A has to determine the song to play.

Once you find where it goes, you can probably achieve music silence by cutting off the code that reads that value back to load a new song.
User avatar
Jason Frudnick
Posts: 12
Joined: Wed Jul 11, 2018 2:24 am
Location: Batrachia, New York

Re: Removing/Disabling music but keeping sound effects

Post by Jason Frudnick »

I found a NSF file still struggling to find those breakpoints! So close on this one!
mkwong98
Posts: 282
Joined: Mon May 30, 2011 9:01 pm

Re: Removing/Disabling music but keeping sound effects

Post by mkwong98 »

If the game writes the song ID to a fixed location to play a different song and one of the songs is silence then simply change all those writes to the ID of the silent song.
User avatar
Sumez
Posts: 919
Joined: Thu Sep 15, 2016 6:29 am
Location: Denmark (PAL)

Re: Removing/Disabling music but keeping sound effects

Post by Sumez »

.... or just change the routine that reads the song index :P
Post Reply