It is currently Tue Jul 16, 2019 6:01 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sat Jun 29, 2019 10:36 pm 
Offline

Joined: Fri Jun 07, 2019 12:44 pm
Posts: 7
What are the limitations of the NES APU? For example, if you are using three channels for the music, will gameplay sounds take precedence over the music and temporarily silence one or more of the music channels? Also, do digitized sound effects like the ones in this video: https://m.youtube.com/watch?v=cpd87e2PJnE further limit music options? Thank you in advance.


Top
 Profile  
 
PostPosted: Sat Jun 29, 2019 11:29 pm 
Offline
Site Admin
User avatar

Joined: Mon Sep 20, 2004 6:04 am
Posts: 3697
Location: Indianapolis
Sound priority is determined by the sound engine, and there's a ton of ways to do that. Pently for example, I believe has instruments that work like sound effects (other than it being triggered by the music patterns obviously), so instruments can interrupt other instruments the same way a sound effect would.

Digitized audio does affect things, mostly memory layout and CPU time. That video has a mix of DPCM (Bayou Billy) and raw $4011 writes (Gauntlet, Skate or Die 2). $4011 is virtually unusable during gameplay, so I'll focus on DPCM.

DPCM is easy to do, it's a DMA thing so it automatically reads it from NES memory during playback, halting the CPU for some time. That matters if your CPU timing is critical, usually it's not. Unless you're running cycle-timed code. DPCM playback also affects the controller reading, it's pretty much a bug in the NES. There are work-arounds for it in the wiki, you have to use one or else you'll get phantom button presses.

But usually the biggest limitation is where to keep them in memory. You can bankswitch your CPU code/data all you want, but DPCM samples have to mapped into memory as long as the sample is playing. You can play more samples by bankswitching the sample memory as well, but I don't know if any of the exising sound engines are set up for that.


Top
 Profile  
 
PostPosted: Sat Jun 29, 2019 11:29 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 4152
Location: A world gone mad
It's entirely based on how the sound engine is programmed on a per-engine/per-game basis.


Top
 Profile  
 
PostPosted: Sun Jun 30, 2019 10:56 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 21505
Location: NE Indiana, USA (NTSC)
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:

  1. Last wins: Sound effect played later always interrupts sound effect played earlier on same channel
  2. ID determines priority: Later sound effect wins if and only if it has a higher (or lower) number than the existing sound effect
  3. 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:

  1. No pulse pool: Each sound effect is hardcoded to pulse 1 or pulse 2
  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:

  1. 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
  2. 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
  3. Interrupt then fade in: Sound effect always interrupts instrument, and that music channel fades in over a few frames once the sound effect ends
  4. 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:


_________________
Pin Eight | Twitter | GitHub | Patreon


Top
 Profile  
 
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 2 guests


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