To expand on koitsu's "How long is a piece of string?"-esque answer, I'll give a cross-section of sound effect policies that an audio driver might implement.
Different drivers have different algorithms for one sound effect against another. I've seen these:
- Last wins: Sound effect played later always interrupts sound effect played earlier on same channel
- ID determines priority: Later sound effect wins if and only if it has a higher (or lower) number than the existing sound effect
- Length determines priority: Later sound effect wins if it is longer than the remaining portion of the earlier sound effect
Different drivers also differ in whether each sound effect is hardcoded to a particular channel. Triangle, noise, and DPCM are all qualitatively different, but for allocating sound effects to the two pulse channels, I've seen these:
- No pulse pool: Each sound effect is hardcoded to pulse 1 or pulse 2
- Pulse pool: A sound effect plays on pulse 1 unless pulse 1 is busy with a sound effect, in which case the sound effect may be moved to pulse 2
Different drivers have different algorithms for music against sound effects. I've seen these:
- Interrupt then wait for note: Sound effect always interrupts instrument, and once the sound effect ends, that music channel remains muted until the next note begins
- Interrupt: Sound effect always interrupts instrument, and that music channel resumes immediately once the sound effect ends, intending for illusory continuity of tones to mask the gap in the note
- Interrupt then fade in: Sound effect always interrupts instrument, and that music channel fades in over a few frames once the sound effect ends
- Volume priority: Each frame, the driver evaluates the sound effect and instrument on each channel and plays whatever is louder
I maintain a homebrew NES audio driver called
Pently. It always uses "Length determines priority", but I know people have different opinions about some of these policies. So I added build-time configuration constants to switch between "Pulse pool" and not (
PENTLY_USE_SQUARE_POOLING) and between "Volume priority" and "Interrupt" policies (
PENTLY_USE_MUSIC_IF_LOUDER). Though the triangle channel doesn't have volume control, drivers using "Volume priority" can still use it to switch between, say, a kick drum and a bass note, keeping the kick drum enabled just a bit longer if a note isn't playing. (For more info on triangle kick drums, see video by
explod2A03.)
Previous discussions about sound effect interruption: