It is currently Sat Nov 25, 2017 12:54 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Sat Nov 21, 2015 9:54 am 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 987
Location: Pennsylvania, USA
I've run into an odd artifact in my sound engine, which only seems to be noticeable in certain situations. I've got a volume envelope in the square 1 channel that gradually increases in volume. During this song, a sound effect may play and overlay on the same square 1 channel with a different envelope, with different volume settings. Right now, it is overlaid directly, frame by frame, so when the sound effect ends, the music stream will supply where it would have been in its own envelope, potentially making a rude transition from one volume setting sharply to another. This results in an unpleasant "hiccup." And, I am certain this is not the effect described in MetalSlime's sound tutorial over on NA:

"Crackling Sounds: Writing to the 4th port of the Square channels ($4003/$4007) has the side effect of resetting the sequencer. If we write here too often, we will get a nasty crackling sound out of our Squares. This is not good."

I already followed his advice for preventing this effect when I upload all my apu register data. I think what I'm experiencing is purely due to abrupt shifting of the volume setting. If I'm right, it makes me wonder if others here who have written sound engines have any scheme to quickly interpolate volume values when overlaying sound effects, over a couple of frame perhaps---to smooth out this problem.


Top
 Profile  
 
PostPosted: Sat Nov 21, 2015 10:06 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1835
Location: DIGDUG
Mine silences the channel after a sound effect, and waits for the next NEW note before triggering.
Also, I keep the main song note on Sq 1 and square sound fxs on Sq 2, so the song doesn't sound interrupted.

(I'm still trying to think of a better engine, my sound effects are awfully simple)

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Sat Nov 21, 2015 10:12 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5842
Location: Canada
The "crackling sound" refers to when you do $4003/7 it in the middle of a note, e.g. if you have vibrato near A-3 (see: Mega Man 2 ending).

Getting a single "pop" from the phase reset at the start of a new note or sound effect is normal, and shouldn't be a problem. There are many things that change all of a sudden (pitch, volume, duty) when you begin a new note or sound effect, so a interruption of phase via $4003/7 is more or less irrelevant. The "crackling" problem is when you are trying to have a smooth continuous sound, but get discontinuities because of the phase reset (like with the vibrato example I linked).

Usually the start of a sound effect interrupting something is not a problem; sound effects are supposed to sound like an interruption. They should stick out and notify the player that something has happened in the game. The usual problem area is what happens when the sound ends.

If you resume the music in the middle of a note, it doesn't sound very musical; it sounds like an interruption, like a sound effect. There are a number of ways to deal with this. My own approach is just to leave the channel silent after a sound effect ends, and only resume the music at the next note. That way I never hear a partial note out of place. (As a consequence of this, on channels that are to be interrupted by SFX, I try to compose with frequent notes instead of long sustained ones, so the period of silence isn't long and glaring.)

Other people do things like fade a playing note back in over several frames, or comparing the volume of SFX vs Music and just playing whichever was louder that frame. I'm not really a fan of these techniques, but they're an option if you like them.


Top
 Profile  
 
PostPosted: Sat Nov 21, 2015 10:21 am 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 987
Location: Pennsylvania, USA
Thanks rainwarrior, that's quite helpful. I tend to use a lot of sustained notes in my own music...so I'm gonna try the fade-in-after-sfx-terminate idea and see how I like it.


Top
 Profile  
 
PostPosted: Sat Nov 21, 2015 11:09 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19259
Location: NE Indiana, USA (NTSC)
rainwarrior wrote:
comparing the volume of SFX vs Music and just playing whichever was louder that frame

That's what I do, especially because in my engine, drums can interrupt the note on the triangle channel in the same way that sound effects interrupt a note. This behavior ensures that if a sound effect has a long, quiet tail, a louder note on the same channel can interrupt that when prudent. And even though the triangle has no real volume control, it still uses the volume as a priority value between music and sound effects. For example, if a triangle kick drum has its volume bits set low for the last few frames, it will get cut slightly sooner when a note is playing than when not. Thanks to the the auditory phenomena of simultaneous masking, illusory continuity, and illusory discontinuity, the net effect is almost like having a mixer.


Top
 Profile  
 
PostPosted: Sat Nov 21, 2015 12:23 pm 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 987
Location: Pennsylvania, USA
Alright...tried all three techniques. I'm not sure I did the sfx/music volume compare quite correctly. However, I was able to get fade-in-after-terminate to work and also silence-until-note. I think I prefer silence-until-note. This sounded the least disruptive of all, in the context of the music/sfx I was working with. Thanks guys!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 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