Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /storage/content/49/145849/famitracker.com/public_html/forum/classes/dbHandler.php on line 29 FamiTracker
Login:
Menu:
Post: Author:
FamiTracker > General > FamiTracker Talk > Importing DMC sample to ROM? Owner: Baka94 New post
Page 1 of 1 Sort:  
Importing DMC sample to ROM? Posted: 2015-04-30 08:51  (Last Edited: 2015-04-30 08:52) Reply | Quote
Baka94

Avatar

Member for: 2677 days
Location: Finland
Status: Offline

#68520
Can I import a DMC sample to a ROM as it is (in the .dmc format used by FamiTracker), or do I need to convert it somehow for it to work? If I need to convert it, how do I do it?

EDIT: I'll be using .incbin (assembler command to include file in binary) to import the DMC samples

Posted: 2015-04-30 14:46 Reply | Quote
za909

Avatar

Member for: 3963 days
Location: Hungary
Status: Offline

#68521
Yeah, that's all you need to do.
.incbin something.dmc (or .bin or whatever)
And you need it to be in the last ROM bank (or not if you are using a mapper capable of switching the $C000-$FFFF range)
A useful assembler command to use here is also .align 64 because you need your sample to begin at $xx00 $xx40 $xx80 or $xxC0.


_______________________
Rectangular sh*t ©
Posted: 2015-04-30 21:31 Reply | Quote
jsr
Administrator

Avatar

Member for: 5925 days
Location: Sweden
Status: Offline

#68524
DMC is the native NES format for samples, you don't need to do anything other than aligning it to proper addresses as explained above.

_______________________
Programmer and developer
Posted: 2015-05-05 10:55 Reply | Quote
Baka94

Avatar

Member for: 2677 days
Location: Finland
Status: Offline

#68566
Okay, I was not sure if the file had some kind of header that needs to be edited out. BTW, how do the samples itself work? Is it just a string of values that represent how "high" or "low" the waveform goes at that point?

e.g.
"0,1,2,3,4,5,6,7,8,8,7,6,5,4,3,2,1,0" would make a triangle wave, right?

Posted: 2015-05-05 12:50  (Last Edited: 2015-05-05 12:54) Reply | Quote
za909

Avatar

Member for: 3963 days
Location: Hungary
Status: Offline

#68567
That would be how PCM works. With the 1-bit DPCM, every bit is interpreted one after the other, and each one represents whether the signal level increases or decreases. I can demonstrate by making a 1-byte triangle sample (in practice this would be a very quiet sound and you'd need to enable the looped mode for it)
1 byte is 8 bits. So you want 4 "go up" bits and 4 "go down" bits. The unit itself reads the bits from right to left so your bits would be arranged like so: 0 0 0 0 1 1 1 1 , so the sample byte is $0F. This is why DPCM samples look so steppy in an oscilloscope. PCM can jump to all possible signal levels, but DPCM has to crawl there step by step. [url=http://www.skrasoft.com/blog/blogfiles/2A03/sine1.png]Nice image I found
So you can't draw a straight line with DPCM, for that it has to alternate between 0 and 1 bits. You are getting a constant square wave or noise on top of the actual sound you want to make, but the highest rate the NES can do makes it inaudibly high.

_______________________
Rectangular sh*t ©
Posted: 2015-05-05 13:25 Reply | Quote
furrykef

Avatar

Member for: 5190 days
Status: Offline

#68568
This is also why so many samples sound awful when converted to DPCM. I've had more than one project I had to scrap because I couldn't get a DPCM sample I found acceptable.

Posted: 2015-05-06 21:14 Reply | Quote
za909

Avatar

Member for: 3963 days
Location: Hungary
Status: Offline

#68578
Generally DPCM on the NES is best for sampling low-frequency sounds. When the frequency is too high for the sampling rate, it has no choice but to become a mess of triangle-like distortion. Most of the time, only bass samples or orchestra hits were used when it comes to melodic samples because the encoding process can represent those changes better as they happen over a longer time period. But you also can't go too low, otherwise the noise from the steps becomes too strong compared to the desired sound.

Something I always wish they could've implemented was a larger lookup table for the pitches. Because in reality, all 16 possible pitches are just 16 hardwired period values that mean the same thing as for the other channels (but the 16 noise pitches also work like this)
There are three unused bits in the hardware where your 4-bit pitch goes. The eight bit is whether or not you want an IRQ to fire at the end of the sample, which is not supported by the NSF specification anyway. But a larger lookup table, even a 32 entry one could've been so much better. That, or fixing the stupid +1 byte length rule.
All samples can be of a length of a multiple of 16, +1 bytes and this transposes looped samples down by one semitone.

_______________________
Rectangular sh*t ©
Page 1 of 1 Sort: