It is currently Sat Aug 18, 2018 12:00 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: Sat Feb 03, 2018 9:17 am 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 1101
Location: Pennsylvania, USA
If I'm just playing samples and never manually feeding PCM samples through $4011, I should just leave the register totally alone, right? I just found a bug in ggsound where I had been writing this register every frame alongside sample playback. It only sounds correct vs. what I hear in FamiTracker when I totally leave $4011 alone. (interestingly, the only problem that it introduced when I HADN'T left it alone was very subtle differences in the pitch of the dpcm sample being played. Didn't notice it at all until now.)


Top
 Profile  
 
PostPosted: Sat Feb 03, 2018 9:26 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20413
Location: NE Indiana, USA (NTSC)
In FamiTracker:

  • The Zxx effect in the DPCM channel writes its argument to $4011.
  • Each DPCM instrument specifies whether to write $4011 first. Down the middle of the DPCM instrument editor are three controls Octave, Pitch, and D-. If D- is set to "Off", no $4011 write is made before playback. If it's instead set to 0-127, that value is written to $4011.
  • There appears to be a difference between "note release", which only stops playback, and "note cut", which stops playback and then writes to $4011.


Top
 Profile  
 
PostPosted: Sat Feb 03, 2018 9:29 am 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 3110
Location: Tampere, Finland
It's not a good idea to write $4011 while you're playing samples, because it's not well defined whether the writes will take effect or not. (I guess you can force it to take effect by writing a couple of times in row, though.) You might want to write it right before you start a sample though, to make the sample playback always start at the same level (e.g., centered at $40). This makes sure that the samples can't go haywire and saturate to the upper/lower limit of the 7-bit range. However, it might cause some popping to be heard when the sample starts.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi


Top
 Profile  
 
PostPosted: Sat Feb 03, 2018 9:33 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20413
Location: NE Indiana, USA (NTSC)
Another technique is to convert the wave in an unsigned manner, adding DC to the start and end of the wave so that it comes out to 0 at the start and end. I think FamiTracker calls this "tilt".


Top
 Profile  
 
PostPosted: Sat Feb 03, 2018 9:35 am 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 1101
Location: Pennsylvania, USA
thefox wrote:
It's not a good idea to write $4011 while you're playing samples, because it's not well defined whether the writes will take effect or not. (I guess you can force it to take effect by writing a couple of times in row, though.) You might want to write it right before you start a sample though, to make the sample playback always start at the same level (e.g., centered at $40). This makes sure that the samples can't go haywire and saturate to the upper/lower limit of the 7-bit range. However, it might cause some popping to be heard when the sample starts.

What sort of going haywire can occur? Also what do you mean by level and 7 bit range (what sort of range?) Right at the moment, it appears the best behavior comes from never writing $4011. I did actually hear some popping sometimes when I HAD been writing $4011, which is unpleasant for music playback.


Top
 Profile  
 
PostPosted: Sat Feb 03, 2018 9:43 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20413
Location: NE Indiana, USA (NTSC)
Not writing $4011 means no pops. But it also means your balance between triangle and noise on one hand and the pulse on the other hand depends on exactly where the sample was stopped.


Top
 Profile  
 
PostPosted: Sat Feb 03, 2018 10:25 am 
Offline
User avatar

Joined: Sun Nov 09, 2008 9:18 pm
Posts: 1101
Location: Pennsylvania, USA
tepples wrote:
Not writing $4011 means no pops. But it also means your balance between triangle and noise on one hand and the pulse on the other hand depends on exactly where the sample was stopped.

I wonder what situations would reveal this behavior most clearly? I haven't noticed anything odd or like volume changed or what not when I leave $4011 alone.
tepples wrote:
Another technique is to convert the wave in an unsigned manner, adding DC to the start and end of the wave so that it comes out to 0 at the start and end. I think FamiTracker calls this "tilt".

If FamiTracker somehow takes care of this during the sample conversion process to begin with (as maybe you were saying with regards to the "tilt" feature?) that may explain why I am not noticing anything, all my samples were generated by importing wavs in famitracker.

Adding in a write to $4011 when I restart the sample playback really sounds bad. Thankfully I don't use DPCM myself; just wondering on behalf of what users of ggsound may run into if I leave $4011 alone.


Top
 Profile  
 
PostPosted: Sat Feb 03, 2018 12:11 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 7392
Location: Seattle
GradualGames wrote:
I haven't noticed anything odd or like volume changed or what not when I leave $4011 alone.
The difference in triangle and noise channel volume over the range of the DPCM DAC is only about 4 dB—it might be subtle enough to not be noticeable except by contrast within a song.


Top
 Profile  
 
PostPosted: Sat Feb 03, 2018 1:16 pm 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 3110
Location: Tampere, Finland
GradualGames wrote:
What sort of going haywire can occur? Also what do you mean by level and 7 bit range (what sort of range?) Right at the moment, it appears the best behavior comes from never writing $4011. I did actually hear some popping sometimes when I HAD been writing $4011, which is unpleasant for music playback.

What tepples said (although it's minor). There's another somewhat minor case where if your sample playback is not balanced (that is, the sum of the played +2/-2 samples is not 0), you will accumulate some bias in the DAC counter. Eventually it could hit the upper or lower boundary of the 7-bit range (0 or 127), and the sample would start getting distorted. Thus, I think a good safeguard is to reset the DAC counter at least sometimes (e.g., when starting a new song).

By level I simply meant the value of the DAC counter. The DAC counter has a 7-bit range, incremented/decremented by 2 based on each bit of the DPCM sample.

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi


Top
 Profile  
 
PostPosted: Sat Feb 03, 2018 2:29 pm 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6596
Location: Canada
When it hits the edge, that particular peak gets cut off, but when the waveform returns it kind of makes its own headroom again, so DPCM samples tend to have an auto--centering kind of effect. The actual distortion from the clamp is fairly localized, it's like a single very soft pop, and not at all like e.g. clipping distortion. IMO it's not even very noticeable in the mix with DPCM's other inherent distortions.

Like, if your waveform is centred, you've got room for 32 steps up, 32 steps down without hitting the edge (128 / +/-2 per sample = 64).

Eg. if your sample has a peak of +/- 15, if started in the middle it won't hit either side, and the central/rest value should be the same before and after the sample. However, if it was started near one edge or the other, the clamping will automatically push it away from the edge when that peak is hit, so it would end up centred around 15 or 64-15 by the end.

The exception to this is if they waveform is continually having a peak to trough greater than 64, which would produce continual distortion of the waveform. That's something to be avoided.


There is also the possibility of making unbalanced waveforms that don't oscillate around a centre line. This is not something that's easy to do with standard audio software, unfortunately. Famitracker's "tilt" feature in its sample editor is sort of a manifestation of this. It inserts random 0 samples into the selected range, with the purpose that when the end of the sample is dying down in volume it also starts drifting back to 0, so that your samples may consistently leave the DMC's counter at 0 rather than some floating centre point.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 7 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