DMC channel
Moderator: Moderators
-
Celius
- Posts: 2159
- Joined: Sun Jun 05, 2005 2:04 pm
- Location: Minneapolis, Minnesota, United States
- Contact:
DMC channel
I was wondering whether or not to start this thread, but I decided that I must, because I just have no clue what I'm doing in this field. I've been interested in learning about the DMC channel, but everywhere I look leaves me with one question: "...What?"
I honestly don't know what the documents are talking about. But, I did look around in a few threads on this site that pointed me to a few programs, such as Tepple's program for converting WAV files to DMC files. So I recorded a sound, and turned it into a WAV file, and then converted it to a DMC file.
However, I don't know exactly what to do with this file. I tried to .incbin my file at a specific location; one that was a multiple of $40 + $C000 ($C400 to be exact). I don't know what it is, but I can't get it to play. The file is 7 KB. Is this even a valid file size? Doesn't the length counter only allow for around 4 KB ($FF * $10 + 1 = $FF1 = 4081)? Well, Perhaps someone could point me in the right direction by telling me how I can initiate this file with a small peice of sample code. With that, I could study the documents, and study the code, and possibly get some useful information out of it. If someone could do that for me, I'd be very very happy.
I honestly don't know what the documents are talking about. But, I did look around in a few threads on this site that pointed me to a few programs, such as Tepple's program for converting WAV files to DMC files. So I recorded a sound, and turned it into a WAV file, and then converted it to a DMC file.
However, I don't know exactly what to do with this file. I tried to .incbin my file at a specific location; one that was a multiple of $40 + $C000 ($C400 to be exact). I don't know what it is, but I can't get it to play. The file is 7 KB. Is this even a valid file size? Doesn't the length counter only allow for around 4 KB ($FF * $10 + 1 = $FF1 = 4081)? Well, Perhaps someone could point me in the right direction by telling me how I can initiate this file with a small peice of sample code. With that, I could study the documents, and study the code, and possibly get some useful information out of it. If someone could do that for me, I'd be very very happy.
Re: DMC channel
You are correct. Your file is too long to play in its entirety. Shorten it by either shortening the wav you're converting, or using a lower frequency/quality setting when converting it.Celius wrote:The file is 7 KB. Is this even a valid file size? Doesn't the length counter only allow for around 4 KB ($FF * $10 + 1 = $FF1 = 4081)?
Playing them is pretty simple:
Code: Select all
LDA #$0F
STA $4010 ; set frequency ($0F is highest quality/pitch. Experiment with
; lower values, but beware that below $0A or so they get pretty slow)
LDA #$3F
STA $4011 ; set output to "center line". This step can possibly be skipped,
; but I'd recommend leaving it in... see notes at bottom)
LDA #$10
STA $4012 ; set address to $C400
LDA #$FF
STA $4013 ; set length to max ($FF1 bytes) -- lower this if you shrink your dmc sample.
LDA #$0F
STA $4015 ; stop DMC if it's currently playing
LDA #$1F
STA $4015 ; and restart it
As far as the "center line" stuff goes -- if your wave extends too high or too low it will end up getting clipped which will distort the sound. Setting the center line to $3F or $40 keeps it right in the middle so there's the least chance of clipping occuring.
EDIT
I made this a while back so you can preview your DMC sample before dropping it in your program:
http://disch.arc-nova.org/dmcplayer.zip
-
Celius
- Posts: 2159
- Joined: Sun Jun 05, 2005 2:04 pm
- Location: Minneapolis, Minnesota, United States
- Contact:
Thank you very much Disch, you've pretty much answered my questions. And it turns out that it wasn't playing at first due to a completely unrelated reason. However, all of this information was very helpful. So pretty much anyone who's new to the DMC channel should be pointed to this thread. Does anyone think it would be a good idea to write a small document for those who want to learn about the DMC channel, but can't really understand what the docs are saying?
EDIT: By the way, very nice little program. I'll be using it quite frequently =).
EDIT: By the way, very nice little program. I'll be using it quite frequently =).
-
atari2600a
- Posts: 324
- Joined: Fri Jun 29, 2007 10:25 pm
- Location: Earth, Milkyway Galaxy, The Universe, M-Theory
- Contact:
Curious, has anyone ever tried converting an entire song & slapping it into a ROM?
Code: Select all
*=$0000
loop JMP loop
.eofI've done so. But 512 KiB for a <2 minute song is impractical. Better is to do it without DPCM.atari2600a wrote:Curious, has anyone ever tried converting an entire song & slapping it into a ROM?
-
Celius
- Posts: 2159
- Joined: Sun Jun 05, 2005 2:04 pm
- Location: Minneapolis, Minnesota, United States
- Contact:
I'm just wondering how that would be possible, because can't you only stick DMC data in $C000-$FFFF? Is the ROM 1024k? I think I may have heard that before actually...
EDIT: No, actually, I had a different ROM that was 1024k, and it had a DMC file in it, and it was really really nice sound. I remember that it was when I wasn't even into NESdev yet, and I was so blown away by the quality and I didn't know how it was even possible to do such a thing.
EDIT: No, actually, I had a different ROM that was 1024k, and it had a DMC file in it, and it was really really nice sound. I remember that it was when I wasn't even into NESdev yet, and I was so blown away by the quality and I didn't know how it was even possible to do such a thing.
you can stream raw PCM data to $4011 to produce your own sound wav. A few games do this (Battletoads comes to mind right away).
That is to say... you can output a 44.1 KHz wave (good quality) if you write to $4011 with a new sample 44100 times every second (spaced evenly, of course).
You're still limited to 7-bit mono samples though.
That is to say... you can output a 44.1 KHz wave (good quality) if you write to $4011 with a new sample 44100 times every second (spaced evenly, of course).
You're still limited to 7-bit mono samples though.
MMC3 has two switchable banks. In one common configuration, one is placed at $C000-$DFFF and the other at $A000-$BFFF.Celius wrote:I'm just wondering how that would be possible, because can't you only stick DMC data in $C000-$FFFF?
But why would someone waste that much NOR flash on one song? Sure it's possible, just like it's possible to hack a low-quality reproduction of Sonic Adventure music into Sonic the Hedgehog for Sega Genesis. But that doesn't make it desirable.EDIT: No, actually, I had a different ROM that was 1024k, and it had a DMC file in it, and it was really really nice sound. I remember that it was when I wasn't even into NESdev yet, and I was so blown away by the quality and I didn't know how it was even possible to do such a thing.
It does indeed sound like crap.tepples wrote:Sure it's possible, just like it's possible to hack a low-quality reproduction of Sonic Adventure music into Sonic the Hedgehog for Sega Genesis. But that doesn't make it desirable.
I believe that's called Big Bird's Hide and Speak. I tried tracing through its audio decompression code. It has about eight "flavors" of compressed sample blocks; they take different amounts of time to decode so each byte just JSRs into a big NOP slide to kill time. Eventually, I said screw it, I'm just writing my own ADPCM playback engine.tokumaru wrote:This would be the hard part, if you are doing anything besides playing the samples. But I guess this would allow for some sort of audio compression, if the decompression engine was simple enough and everything was very well timed.Disch wrote:spaced evenly
-
Celius
- Posts: 2159
- Joined: Sun Jun 05, 2005 2:04 pm
- Location: Minneapolis, Minnesota, United States
- Contact:
So in other words, you'd have to update it every X scanlines, where X = (However many cycles are in a frame) * 60 / 44100. So you could do something with MMC3's scanline counter. That would be interesting. That seems like it would be really hard without a scanline counter. I have to admit, the DMC address byte is a really stupid concept. It would have caused way less problems if they just made it like $2005/$2006, where you can do two writes to it. It's actually kind of dissapointing to know that there isn't that much flexibility with it.
Scanlines? I don't think any scanline counter will be able to help you there... 44100 is the number of samples in a second... since the NES runs at nearly 60 frames per second, that'd be 735 samples per frame, and that number is quite larger than the number of scanlines. I think you'd have to write a byte every 40 or so CPU cycles.Celius wrote:So in other words, you'd have to update it every X scanlines
EDIT: In the formula you presented, X is the number of cycles, not scanlines, and it evaluates to 40 and some fraction of cycle.