Page 1 of 1

DMC Sample?

Posted: Wed Mar 08, 2017 9:58 am
by DementedPurple
Hey, does anyone know how I would compress and use a DMC sample? Is it pretty much just an MP3?

Re: DMC Sample?

Posted: Wed Mar 08, 2017 10:19 am
by dougeff
Famitracker does a good job making DMC samples....but I think you have to feed it mono WAV files. You can convert MP3 to WAV using an audio editor, like Audacity.

Unrelated side note, I believe you have to download a separate LAME encoder dll to output MP3 from Audacity.

Tepples also made a DMC encoder, but I think famitracker has better results. I can't remember which file it is.

EDIT, tepples linked to it below...

Re: DMC Sample?

Posted: Wed Mar 08, 2017 10:21 am
by tepples
The MP3 codec was invented in the mid-1990s. Delta modulation is much older. The counter in the NES version has 64 levels, and deltas are packed little-endian with 1 to add one level and 0 to subtract one level.

I've written two command-line conversion tools to convert a .wav file: one in C (available as a Windows executable and source code) and one as a Python script that runs on all major operating systems. The Python script is included in the tools directory in the source code of Eighty; do you want me to dig up the C version?

Re: DMC Sample?

Posted: Wed Mar 08, 2017 10:24 am
by tokumaru
No, nothing like MP3, which is a format waaay too complex for the NES to handle. The only format of sampled audio the NES can play automatically is 1-bit DPCM, at different rates. A value of 0 or 1 moves the audio wave up or down, and that's it. I believe there are a few programs that can convert audio to this format. More samples per second means higher quality, but also more space. After you start a sample, the APU will periodically read sample bytes from PRG-ROM automatically, leaving the CPU free to do other things. The APU can optionally fire an IRQ when the sample ends, so you can decide what to do next (repeat the same sample, play another one, etc.).

You can also write 7-bit audio samples directly to the APU, which means you can use your own compression format (MP3 would require a much faster CPU though) and output samples manually in a timely fashion. Due to the time needed to decode the samples and the need to output them at a constant rate, this typically uses 100% of the CPU time, so you normally can't do this while running a game.

Re: DMC Sample?

Posted: Sun Jul 02, 2017 1:09 pm
by DementedPurple
Okay, the main question I had was how would I make one?

Re: DMC Sample?

Posted: Sun Jul 02, 2017 1:18 pm
by dougeff
You can either.
-Record a sound, and edit it
-Generate a new sound, using a DAW, or soft-synth
-Borrow a free public-domain sample
-use math (ie, program a small program) to produce the data of a sine-wave (for example)

Edit, you could also go to the famitracker forum, download some famitracker files, and take the DMC samples from there. Preferably with permission.

Re: DMC Sample?

Posted: Sun Jul 02, 2017 3:20 pm
by rainwarrior
Use the RJDMC tool.
viewtopic.php?t=6975