MML DPCM - few questions

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
MML DPCM - few questions
by on (#35647)
I am trying to recreate a Fester's Quest bass line. The song is Track 3 (overworld). I found 4 dmc samples to use from an old archive in 2a03. The samples are called fesLO, fesMEDLO, fesMEDHI, and fesHI. This is obviously telling me something about what pitch the dmc is in. However, when I tested out the files it was just a brief high pitched sound. I fixed this when I read up about altering the pitch of a dpcm. But when I solved this minor problem many more questions took their place.

1.) How am I supposed to know what the proper pitch to set the dmc files to? For example, I can make fesHI sound like crap if I set it like:
@DPCM12 = { "samples\fesHI.dmc", 3 }.
I'm sure the higher pitched dmc files should get a higher pitch assignment, but what should they be set to exactly?

2.) How can I increase the pitch of a dmc without decreasing the length of its "note"? Some of the higher notes in the song are not brief, but sustained.

3.) Taking off from question 2, how do you alter the length of a dmc sample?

I took a midi file of the song in question and I checked it out with frinika (a free midi composer). Using frinika, I was able to find out all the notes used in the bass line and I arranged them in a list from lowest in tone to highest:

*Fester's Quest Bass Line*
How many notes are in the bass scale? What are the lowest pitches?
Format: <octave><notation>
4d# (highest)
4d
4c
3a#
3g
3d#
3d
3c
2a#
2g#
2g
2f#
2f (lowest)

For those that are musically inclined, the scale is:
f f# g g# a# c d d#
The Espla's scale or Eight-tone spanish scale matches this perfectly, with:
C D D# F F# G G# A#

I also found out that there are only 3 different note times (for lack of the proper word). They are:

0:360
0:240
0:120

Of course this is in "Frinika's time", so this isn't a standard number by far but at least it is something to use. Notice how these are all multiples of 120.

4.) How can I use this information to recreate the bass line of Fester's Quest (track 3, overworld)?
Re: MML DPCM - few questions
by on (#35651)
Fib Gibbley wrote:
2.) How can I increase the pitch of a dmc without decreasing the length of its "note"?

Apart from a looped sample, you can't do it in hardware on the NES. You have to use a longer sample.

Quote:
3.) Taking off from question 2, how do you alter the length of a dmc sample?

By finding the source .wav file, editing it to be longer, and converting it again.

by on (#35671)
I have trouble understanding something about DPCM. If I can only see 4 samples from the song, I and can get those same 4 samples, why can't I create all the same music that the song can? The way I am seeing it, it's like having the same ingredients as the chef next to you, but for some reason you can't bake the same cake.

by on (#35678)
My understanding of your problem may not be correct, so bear with me.

DMC (or DPCM if you prefer) samples are a fixed length. The NES outputs this fixed size sample until it reaches its end.

Regarding the pitch of the sample: The NES has 16 "speeds" which it can play back the sample. The faster you play it back, obviously the shorter it will be (will reach the end faster). Also, due to the way audio works... the faster you play it back, the higher the pitch -- this is just how it is. Think of an old cassette player... if you fastforward it or play it on high speed, it moves faster and it sounds higher pitched. There are ways around this, but they're computationally expensive, and the NES doesn't do them anyway, so they may as well not exist for your purposes.

To work around this problem, you can have multiple samples played at each desired pitch. But that would require you to produce multiple .dmc files (like tepples mentioned, you could get the source wav, make it the size you want, and reconvert).


The reason for the multiple DMC files is because the DMC channel on the NES isn't capable of playing every note on the scale. Best way I can illustrate this is to borrow a snippit from dmc.txt:

Code:
 value    CPU
written   clocks  octave  scale
-------   ------  ------  -----
F   1B0   8   C
E   240   7   G
D   2A8   7   E
C   350   7   C
B   400   6   A
A   470   6   G
9   500   6   F
8   5F0   6   D
7   6B0   6   C
6   710   5   B
5   7F0   5   A
4   8F0   5   G
3   A00   5   F
2   AA0   5   E
1   BE0   5   D
0   D60   5   C


These are the 16 "speeds" which the NES can play the sample back. You'll notice that the fastest two speeds... it goes from G to C. So if you wanted to play a B or a C#, you couldn't with this sample! This is why the games had multiple samples: each of those samples are set to slightly different pitches which makes you able to play every note on the scale useing the above speeds.

As for which samples to use and at which pitch -- you'll just have to try them out and see. I wrote a DMC player program that can playback samples at each speed pretty quickly a while back. You can get it here:

http://disch.arc-nova.org/dmcplayer.zip

Try each of the 4 samples you have at each speed, and make like a chart or something of how to get specific notes. In my experience, the lower speeds are pretty much useless for these kinds of samples, so you'll probably want to go at speed A and faster (iirc, anyway, but try them all out to see for yourself).


I don't understand your chef/cake metaphore at all. If you have all the samples a song uses, you can reproduce the song.

by on (#35685)
Fib Gibbley wrote:
The way I am seeing it, it's like having the same ingredients as the chef next to you, but for some reason you can't bake the same cake.

Howard Jones wrote:
You can look at the menu but you just can't eat
You can feel the cushions but you can't have a seat
You can dip your foot in the pool but you can't have a swim
You can feel the punishment but you can't commit the sin

Are you trying to convert "No One Is to Blame" to NSF?

by on (#35686)
Ha, no. I was saying that when I went looking for the samples to recreate the song, I expected it to end there. I didn't think the sample ripping program was holding out on me, and I had to go craft my own dmcs with the 4 samples.

I thought I was given all the dmcs available (ingredients) to make the cake (song). I thought all I had to do was tweak a few things to make all the notes.

So, why didn't the program rip 13 samples (or more) instead of just 4? I guess there is something I still don't understand about the E channel.

I found out the notes are:
fesLo - 2nd octave G#
fesMedLo - 2nd octave A
fesMedHi - 2nd octave A#
fesHi - 2nd octave B
Which is interesting because A and B are not even notes used in the song.

Also, it looks like this post is closely related to my problem. They are even talking about Fester's Quest! What should I learn from it that is valid?
http://nesdev.com/bbs/viewtopic.php?t=3309

by on (#35687)
Quote:
I thought I was given all the dmcs available (ingredients) to make the cake (song). I thought all I had to do was tweak a few things to make all the notes.


You were. And that is all you have to do. You're making this more complicated than it is.

Quote:
So, why didn't the program rip 13 samples (or more) instead of just 4?


Because to get all the notes you have to play those samples at different speeds.


Did you try what I said and play those samples at different speeds? They'll produce different tones when you do. What speed are you playing the samples at to get those tones you mentioned?

Even though the game doesn't have notes A or B, it might still use those samples at different speeds to get a tone different from A or B.

Also -- could you upload these samples somewhere so I can listen to them? I could walk you through what I do after that (even though I thought my previous post covered it -- maybe a more step-by-step approach would be easier to understand)

by on (#35688)
First of all thank you for that program disch. Without your help I wouldn't have been able to get this far.

Using your program, I am playing the samples all at the same speed; 5. I closely compared them to the source to get my notes at that speed. The way I see it, they created these dmcs with the speed at 5 all along, right?

The source files are available here, at http://2a03.free.fr/
At the bottom of that page you will see "latest files". Find DCPM_Samples (should be the fifth one down from the top). In that, go to Synth&Instrument > SunSoft Bass > Uncle Festor.

by on (#35690)
Okay -- hopefully my math here is right.

If you figure note C is 0, and you number each note above it as the next highest number (C#=1, D=2, D#=3, E=4, F=5, etc). And each octave higher being +12. Then looking again at that chart from dmc.txt.. we can produce a different chart. We will use speed 5 as the baseline, and find out how much the note changes when played at different speeds. According to the chart, speed 5 plays 'A' which would be assigned number 9.

Code:
speed    tone change
-----------------------
   3       -4      (F - A  =  -4)
   4       -2      (G - A   =  -2)
   5       0        <--  using this as the baseline, so it's 0
   6       +2      (B - A   =  +2)
   7       +3      (12 + C - A  =  +3)  +12 because it's an octave higher
   8       +5      (12 + D - A  =  +5)
   9       +8      (12 + F - A  =  +8)
   A       +10     (12 + G - A  =  +10)
   B       +12     (12 + A - A  =  +12)


So what does that mean? That means if you play fesLo.dmc at speed 5 and get a G#... playing it at speed 6 will get you a tone 2 notes higher (A#). With that... we can build yet another table:

Code:
    Lo    MLo   MHi   Hi
--+---------------------
3 | E-2   F-2   F#2   G-2
4 | F#2   G-2   G#2   A-2
5 | G#2   A-2   A#2   B-2
6 | A#2   B-2   C-3   C#3
7 | B-2   C-3   C#3   D-3
8 | C#3   D-3   D#3   E-3
9 | E-3   F-3   F#3   G-3
A | F#3   G-3   G#3   A-3
B | G#3   A-3   A#3   B-3


Hopefully I didn't screw that up. As you can see... you can get any note on the scale between E-2 and B-3 by using a specific sample at a specific speed.

by on (#35709)
im trying to really under how this dMC channel works. any of you sages up to making a stair stepping chart/ scale chart. just though it would look cool :)

by on (#35712)
You start with four or five waves, spaced one semitone apart. Number them 0-3 or 0-4 from lowest to highest pitch.

To choose the wave:
Code:
 _______________________________________________
|| | ||| | | ||| | ||| | | ||| | ||| | | ||| | ||
||1|1|||1|1|1|||1|1|||1|1|1|||1|3|||2|1|3|||1|3||
|| | ||| | | ||| | ||| | | ||| | ||| | | ||| | ||
| U U | U U U | U U | U U U | U U | U U U | U U |
| | | | | | | | | | | | | | | | | | | | | | | | |
|0|0|0|0|0|0|0|0|0|2|0|0|0|2|0|2|0|1|0|2|4|0|2|4|
|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|
 C D E F G A B C D E F G A B C D E F G A B C D E

To choose the playback rate:
Code:
 _______________________________________________
|| | ||| | | ||| | ||| | | ||| | ||| | | ||| | ||
||0|1|||3|4|5|||7|8|||9|A|B|||C|C|||D|E|E|||F|F||
|| | ||| | | ||| | ||| | | ||| | ||| | | ||| | ||
| U U | U U U | U U | U U U | U U | U U U | U U |
| | | | | | | | | | | | | | | | | | | | | | | | |
|0|1|2|3|4|5|6|7|8|8|9|A|B|B|C|C|D|D|E|E|E|F|F|F|
|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|
 C D E F G A B C D E F G A B C D E F G A B C D E

by on (#35716)
So I counted the three different note times I need, and along with the 13 notes I have a total of 23 dmc files I need to make (about two timings per note).

The only problem is that I don't have the source wav files. All I have are dmc samples. I have seen pages and pages of wavtodmc programs, but what about dmc to wav? What is a good program (or method) for doing this?

And what wav editing program would you recommend? I would need something to keep a count of the time (0:000) and allow me to increase the length of a wav (like cut and paste sections). I was thinking with cut and paste, I could increase and decrease the duration of the actual tone played to the amount I need.

by on (#35718)
Wave editor: Audacity.

DMC to WAV: my ripper.

by on (#35719)
Fib Gibbley wrote:
So I counted the three different note times I need, and along with the 13 notes I have a total of 23 dmc files I need to make (about two timings per note).


? I'm a little confused. Why can't you just use the 4 samples you have?

by on (#35727)
I can't use the four samples I have because I need the notes to be sustained at three specific times. When you change the pitch you also speed up the play back time, and this is undesirable for specific note times. This is the list I made:

Different lengths used.
0:360
0:240
0:120

4d#: 240,120
4d: 240, 120
4c: 120, 240
3a#: 120
3g: 240,
3d#: 240, 120
3d: 240, 120
3c: 240, 120
2a#: 360, 240, 120
2g#: 240, 360
2g: 120, 240
2f#: 240
2f: 240
Total Notes Needed: 23

For example, in 2a#, I can't just have one dmc and have everything time correctly, because 2a# has three note times (lengths) used in the song.

by on (#35730)
I don't know what those length numbers are supposed to mean. Is that 120 milliseconds? Frames?

At any rate, you can stop a sample prematurely if you need to (just turn the DMC off before the sample finishes playing). As for making it longer.. you'd probably be better off creating a new sample from scratch, since a conversion from DMC to WAV and back to DMC would probably result in a lot of quality loss and distortion (and those samples aren't exactly high quality to begin with).

But I'm still a little confused. I thought you were just reproducing the song... and if that's the case... the same samples that worked in the original would suffice for a remake, wouldn't they? The only way I can see you needing longer samples was if you're slowing the tempo way down. But maybe I'm misunderstanding what you're doing.

by on (#35733)
I don't really know what those numbers are either. I just know that they relate to time somehow. In frinika (a free midi composer), you can highlight a note and it shows you the length of that note visually and with that number format (0:000). I was hoping to just dive in there and figure it out myself.

I can't just take the samples and increase the pitch because that would alter the time the notes plays. You told me yourself; it's like when you increase the speed of a tape recorder. It plays at a higher pitch (like a chipmunk voice) but it IS faster. What am I supposed to do if I need a note to be one second at 2g then two seconds at 2g? The way I see it, I need a dmc sample for each and every single specific note. This means I need 23 total, which I can use to build the entire piece.

So I guess the next question is - how do you turn off a dmc sample prematurely? Are you talking about just pushing stop or pause while running some recording program?

Believe me, if I could just create these DMCs from scratch I would. All I can rip from the track (using nsfLive!) is the four samples. How else could I do it?

In conclusion, the song has 13 notes and 3 different note lengths. I can only get 4 samples at some indescriminate note length. If you can think of a better way to do this, please let me know.

by on (#35740)
Fib Gibbley wrote:
So I guess the next question is - how do you turn off a dmc sample prematurely?

By turning off channel 5. In some playback engines, you might need to create a short, silent wave to interrupt the playing wave.

by on (#35779)
So I gave it a shot anyways - it doesn't sound bad at all. I guess the original sample was just the right length. It must have been the way the programmers created the dmc.