NESDev and Strangulation Records messageboards
Forum Index | FAQ | New User | Login | Search

Previous ThreadView All ThreadsNext Thread*Show in Threaded Mode


SubjectBlarrg's DMC Triangle ROM  
Posted byAnonymous
Posted on9/6/04 02:07 AM
From IP152.163.252.168  



Blarrg, I've got a question on how to do this like int Tri_wave.nes so that I can make it into a sample to use with MCK. You seem to have $4012 loaded with ram $0007 (which toggles between $80 and $81). $4012 is loaded with #$00 so it's exactly a 1 byte sample.

Both areas that $4012 point to is $e000 (value of $00, DMC address when $4012 = $80) and $e040 (value of $ff, DMC address when $4012 = $81). You keep toggling between them with the DPCM to produve triangle waves.

And also $4010 has playback mode IRQ generating after the 1-byte sample has finished (in which stuff happens and eventually loads $0007 with either $80 or $81 depending on $0003 and some rom value that is dependant on $0003).

You see I need to get this working in MCK. I just need to know (as I'm too lazy to figure out the rest of your rom) how much $0007/$4012 is toggled so that I can figure out the exact waveform. I've tried to get this working in MCK, but the triangle waves I produce usually don't sound anything like the native 2A03 triangle wave (I've tried $FF, $00, $00, $FF....$F0, $F0, $F0, F0....$00, $00, $FF, $FF....you know loops like those, but they don't work) like your does.

And also you seem to have more frequencies then 16....how'd you do that?

In MCK I've "hacked" a way to get DMC frquency control + playback control so I would like to get some waves playin on the DMC at different frequencies and have them keep looping (so like 4 byte dmc files that keep looping...so you know have the very end of the file end at where the beggining of the file starts and loop it).....and my first one is the triangle wave.

If you (or anyone) could help me out I'd be grateful. :-)




SubjectRe: Blarrg's DMC Triangle ROM new  
Posted byAnonymous
Posted on9/6/04 02:15 AM
From IP152.163.252.168  



Wait I think I see how you do the more than 16 frequencies thing. You use 2 bytes then alternate at some pattern (what I'm trying to figure out...) and the actually DMC playback is 1 byte at a time and then an IRQ is generated and you tell it which 1 byte sample to play next. Do you have different frequencies for each byte? So like $00 (freq $F), $FF (freq $C), etc.. Do you do that to produce more than the 16 frequencies the DMC has?




SubjectRe: Blarrg's DMC Triangle ROM new  
Posted bytepples
Posted on9/6/04 02:20 AM
From IP68.53.188.30  



The closest DMC approximation of the 2A03 triangle waveform is alternating among $FF, $FF, $00, $00, changing speed at each byte.

____________________
My English is better than your Geberquen.


SubjectRe: Blarrg's DMC Triangle ROM new  
Posted byblargg
Posted on9/6/04 04:19 AM
From IP199.170.90.138  



Right, my driver changes the DMC frequency after each byte has played.

I'm assuming you've read http://www.slack.net/~ant/nes-emu/dmc_waves.html and http://www.slack.net/~ant/nes-emu/old_dmc_waves.html (it has more diagrams).

This method of generating waveforms requires a special driver; it's not just a particular DMC sample being looped. The driver serves two main purposes: change the DMC frequency after each byte (8 delta bits) plays, and periodically reset the DAC (for a saw wave) or switch between $00 and $ff samples (triangle wave).

There are tables of the DMC frequency combinations to use for a particular note. By having each cycle of the wave built from multiple samples played at different frequencies, I can get several octaves with fairly good accuracy, even though the base unit is limited to only 16 frequencies. The pictures show this clearly.

For the saw wave, the driver must reset the DAC ($4011) from 0 to full volume every n IRQs. For the triangle wave, every n IRQs it switches between the $00 and $ff sample values.

The saw and triangle waves use a constant-ramp sample is always being used; the steepness of the ramp is set by the current DMC frequency, rather than using a sample like $ee or $11. In the picture for the triangle wave, each 8-stairstep segment is playing at a different DMC frequency.

The asm source for the saw wave is there on the page. The modification for a triangle and square wave is trivial. I figured the quality of the latter two wasn't worth using in anything, since both waves are already available natively.

If you're adding support for DMC-based triangle and saw waves to MCK, I'd like help with the effort. E-mail me at mail.com.





SubjectRe: Blarrg's DMC Triangle ROM new  
Posted byAnonymous
Posted on9/6/04 04:47 AM
From IP152.163.252.168  



Well, actually I'm going to make my own song driver which supports these things. Right now I just want to hack it into MCK. The closest I got was taking an actually sample from the NES triangle wave and turning into the dmc sample. It doesn't work perfectly though. You see I couldn't get the end of the triangle sample to perfectly fit with the begiining of the triangle sample.

I didn't see the old version of the DMC waves html. It seems to prove more useful to me than the other. BTW I don't get how you doubled the length of the saw wave in olddmcwaves.html. The $4011 volume control thing I get (although I don't know what values put here correspond to the different volumes), but how'd you get it to double in volume?




SubjectRe: Blarrg's DMC Triangle ROM new  
Posted byblargg
Posted on9/6/04 3:54 PM
From IP199.170.90.33  



BTW I don't get how you doubled the length of the saw wave in olddmcwaves.html. The $4011 volume control thing I get (although I don't know what values put here correspond to the different volumes), but how'd you get it to double in volume?

An 8-step stairstep sample of 1-byte length is played repeatedly. This decrements the DAC by 2 each step, for a total of 16 each sample. The IRQ routine triggers after each 8-step sample plays.

If the DAC is reset between each 8-step sample (every IRQ), this gives 17 possible volume levels from 0 through 16. For example, if the DAC is reset to 8 each IRQ (second figure), it will be decremented to 6, then 4, then 2, then 0, and stay at 0 for the remaining steps until the IRQ fires again. Any level above 16 will be (almost) equivalent to 16, since the DAC will only be decremented by 16 total. For example, if the DAC is reset to 30 each IRQ, it will only be decremented to 14 by the next IRQ, thus cover 16 levels as before, resulting in (almost) the same wave with a DC offset (due to the non-linearity of the DAC, it will be slightly quieter).

If the DAC is reset every n IRQs (fourth figure), then it will be decremented n*16 for each wave cycle (n 8-step samples each decrementing by 16). This allows the volume to vary from 0 to n*16. So if n is 2, the volume can be between 0 and 32, which is (about) twice as loud as possible when the DAC is reset every IRQ.

Note that the delay described in old_dmc_waves.html isn't possible, since I later found that the DMC sample unit runs continuously and can't be reset in the middle of a sample. I had to go the route hinted at there, of changing the DMC frequency after each 1-byte sample finished.

If you're supporting these waves in a new driver, be sure to support saw waves in addition to triangle waves.





Previous ThreadView All ThreadsNext Thread*Show in Threaded Mode
Jump to

Memblers' homepage             Contact Me

Forums powered by WWWThreads Demo