It is currently Sat Oct 19, 2019 8:55 am

All times are UTC - 7 hours

Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Nov 20, 2014 12:43 pm 

Joined: Mon Nov 03, 2014 4:35 pm
Posts: 17
*I apologize if this should have gone under NES Music sections but I didn't want to get answers that were over my head so I figured posting it under the Newbie Help Center was best.

Excluding the DMC channel, if the other four channels are playing background music for my game and I have a sound effect trigger what happens to the sound that was playing on that channel when the sound effect is triggered? And what happens after the sound effect ends?

e.g. I have background music playing with a drum beat on the noise channel. My character punches an enemy triggering the "punch" sound effect on the noise channel. Does the drum beat get interrupted the instant the "punch" sound is triggered? Does the drum beat then resume once the "punch" effect is over?

Similarly, I have a G note playing on the triangle channel and it's a long, drawn out note. My character jumps triggering a "jump" sound effect on the triangle channel part way through the long, drawn out note. Assuming that the G note is held for 10 seconds, the "jump" sound effect is triggered 5 second from the start of the G note and lasts for 1 second, does the G note come back on for the remaining 4 seconds of it's normal duration or is it cut off and stopped entirely?

Just to be clear:
Second 1 - G note starts playing on the triangle channel
Second 5 - Jump sound effect is triggered on the triangle channel
Second 6 - Jump sound effect ends
Seconds 7,8,9 & 10 - what happens?

Thanks as always for your help folks. This place is great and I really appreciate the wisdom!

PostPosted: Thu Nov 20, 2014 12:59 pm 

Joined: Sun Apr 13, 2008 11:12 am
Posts: 8617
Location: Seattle
The APU doesn't "handle" anything. (It just understands "Play this note at this volume with this tone color")

The software that you write (or whatever game you're hacking wrote) instead has to decide how it's going to handle a request to play more different sounds than there is space for.

PostPosted: Thu Nov 20, 2014 1:04 pm 
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 7601
Location: Canada
I prefer to cancel the note entirely, rather than resuming the sound as if it had continued underneath. If you do this, though, you should write the music so that the channels that can get cancelled frequently have new note events (e.g. if you need a long tone, maybe continue it with extra notes) to pick back up quickly.

A more advanced thing you might do is fade the channel back in after the sound effect, if it's on square or noise (16 frames going from 0-15 would probably soften it nicely).

PostPosted: Thu Nov 20, 2014 2:12 pm 

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 21637
Location: NE Indiana, USA (NTSC)
The music engine in Thwaite and RHDE runs one sound effect and one musical note in parallel on each channel. Every frame it compares the two and keeps the louder. It routes the drums through the sound effect system, where each drum consists of two effects. For example, a kick drum is a rapid sweep down on channel 3 and a short burst of high-frequency noise followed by a low-frequency tail on channel 4. This behavior makes triangle drums easy; though triangle lacks volume, the volume bits still get used for priority between the drum sound effect and the bass line. Two sound effects played on the same channel have to fight for priority; I calculate a sound effect's priority as its number of remaining (volume, pitch) pairs. The main melody is scored to play on channel 2, and pulse sound effects usually get played on channel 1, though sound effects for channel 1 get shifted to channel 2 if the effect currently playing on channel 1 has more remaining data, such as if channel 1 is busy and channel 2 is idle.

Pin Eight | Twitter | GitHub | Patreon

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 7 hours

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group