DMC channel
Moderator: Moderators
That'd be a bitch to do, even with a static display. Big Bird stored its shortest samples in unused parts of CHR, but I don't feel like tracing the code.tokumaru wrote:Store the samples in CHR-ROM!tepples wrote:but I can't fit more than 2 minutes into a 512 KiB (max mmc1/mmc3 size) fileThen you could go up to 768KB...
-
Celius
- Posts: 2159
- Joined: Sun Jun 05, 2005 2:04 pm
- Location: Minneapolis, Minnesota, United States
- Contact:
I've been wanting to experiment with using $4011 for sound samples for a while. I understand basically all you have to do is at (carefully) timed intervals, load and store a value into $4011. That's easy enough.
However, I'm a total newb when it comes to the way sound works in general. So the actual data that is stored in there, I have no idea how it works. I don't know what the values actually represent, and I just thought I'd ask: what do they mean?
Secondly, what should I do to go about making a store-it-into-$4011-friendly sound sample from an audio file?
Thanks so much in advance.
However, I'm a total newb when it comes to the way sound works in general. So the actual data that is stored in there, I have no idea how it works. I don't know what the values actually represent, and I just thought I'd ask: what do they mean?
Secondly, what should I do to go about making a store-it-into-$4011-friendly sound sample from an audio file?
Thanks so much in advance.
Sound works in waves, length of the wave is the frequency. The timing that the sample changes with (your $4011 update rate) is the frequency (aka digital sample-rate). The values that you write to $4011 is the amplitude for each sample.Celius wrote: However, I'm a total newb when it comes to the way sound works in general. So the actual data that is stored in there, I have no idea how it works. I don't know what the values actually represent, and I just thought I'd ask: what do they mean?
Save it in an 8-bit unsigned format. Since $4011 is 7-bit, you could either reduce the volume by half on the whole sample beforehand, or do an LSR on-the-fly as you play each sample.Secondly, what should I do to go about making a store-it-into-$4011-friendly sound sample from an audio file?
The values are raw PCM data. Each value is a "photo" taken of a sound wave at a particular instant in time. With a series of values you can draw any sound wave you want, with 7 bits of precision.Celius wrote:what do they mean?
WAV files are just like that, a series of "photos" of a sound wave taken at a certain frequency. You can easily convert information from WAV files into the raw values the NES expects, you just have to research the exact format of the numbers. You have to know if they are signed or not, that kind of thing. This is a place with a few documents about the WAV format.
You'll have to see the frequency at which you'll be able to write the values on the NES, and you'll probably have to use a sound editor to convert the source WAV file to that frequency. Or you could just try to achieve the same frequency used by the original WAV file.
-
Celius
- Posts: 2159
- Joined: Sun Jun 05, 2005 2:04 pm
- Location: Minneapolis, Minnesota, United States
- Contact:
Thanks for the replies, guys.
So you have to convert a WAV file to a raw format (assuming you have a WAV file)?
Also, I understand that pitch is determined by frequency, and that if you play the sample faster, the pitch will be higher. But I still don't know how pitch is determined within the sample. All the values are "amplitudes", you say. Does that just mean they're like Y values for a "pixelated" (quantized?) sound wave? And also, are the values signed or unsigned?
Sorry for all the questions. Thanks again, guys for helping me.
So you have to convert a WAV file to a raw format (assuming you have a WAV file)?
Also, I understand that pitch is determined by frequency, and that if you play the sample faster, the pitch will be higher. But I still don't know how pitch is determined within the sample. All the values are "amplitudes", you say. Does that just mean they're like Y values for a "pixelated" (quantized?) sound wave? And also, are the values signed or unsigned?
Sorry for all the questions. Thanks again, guys for helping me.
The pitch is determined within a simple at which rate a waveform repeats. If you understand what a square wave is, how close to each other the edge are determines the frequency (or pitch). How height the wave is determine the amplitude (or volume).
WAV files can be made with more complex forms than square waves. With fourrier transform, everything can be decomposed into a sum of sine waves. The lowest freqency sine wave is the fundamental and determines the pitch of the sound. The higher frequency of sine waves are the harmonics and determine how the sound sounds. Note that some waves, such as white noise cannot be decomposed into sine waves because they are random, so this doesn't appy. That's why you don't hear any pitch when you hear white noise (or any other kind of "noise").
WAV files can be made with more complex forms than square waves. With fourrier transform, everything can be decomposed into a sum of sine waves. The lowest freqency sine wave is the fundamental and determines the pitch of the sound. The higher frequency of sine waves are the harmonics and determine how the sound sounds. Note that some waves, such as white noise cannot be decomposed into sine waves because they are random, so this doesn't appy. That's why you don't hear any pitch when you hear white noise (or any other kind of "noise").
Useless, lumbering half-wits don't scare us.
Bores.com has a DSP tutorial that should help you understand.Celius wrote:However, I'm a total newb when it comes to the way sound works in general.
-
Celius
- Posts: 2159
- Joined: Sun Jun 05, 2005 2:04 pm
- Location: Minneapolis, Minnesota, United States
- Contact:
So take these graphs of waves:
All "x"s are 1 sample fetch wide, and the higher the number of x's stacked, the higher the number stored into $4011 is. Basically it's a bad graph. But the top one would make a higher, quieter sound, and the lower one would make a lower, louder sound, right?
Code: Select all
|
|
| xx xx xx xx x
|xxxxxxxxxxxxxx
|xxxxxxxxxxxxxx
|--------------
| x x x
| xxx xxx xxx
|xxxxxxxxxxxxxx
|xxxxxxxxxxxxxx
|xxxxxxxxxxxxxx
|--------------
-
Celius
- Posts: 2159
- Joined: Sun Jun 05, 2005 2:04 pm
- Location: Minneapolis, Minnesota, United States
- Contact:
Okay, I've got some samples working now by doing the lsr trick memblers mentioned. It was an 8-bit mono WAV file at 6 KHz. I'm not quite sure why it didn't work when I tried it last, but now it did.
I was hoping to make some use of this channel running at 60 Hz (hahaha). Yeah, probably not going to happen for anything but like a helicopter sound effect. It might be possible to play sounds clocked at really low speeds though (6000 Hz max if you plan on performing anything while playing samples, even if using an IRQ). For example, I wanted to have my character die in the game, and possibly let out a scream of some sort. Their body flies back, and the screen would scroll over a little while it plays the game over music. For that, I'd have to do a little game logic, and would probably want to play the sound with a scanline counter. And I would want to do that as little as possible, so the quality would have to be lowish...
I was hoping to make some use of this channel running at 60 Hz (hahaha). Yeah, probably not going to happen for anything but like a helicopter sound effect. It might be possible to play sounds clocked at really low speeds though (6000 Hz max if you plan on performing anything while playing samples, even if using an IRQ). For example, I wanted to have my character die in the game, and possibly let out a scream of some sort. Their body flies back, and the screen would scroll over a little while it plays the game over music. For that, I'd have to do a little game logic, and would probably want to play the sound with a scanline counter. And I would want to do that as little as possible, so the quality would have to be lowish...
I just tried an S3M simulation of writing $7F, $3F, $1F, $00, at 60 Hz, and it made a sound that could be used as a passable kick drum.Celius wrote:I was hoping to make some use of this channel running at 60 Hz (hahaha). Yeah, probably not going to happen for anything but like a helicopter sound effect.
You could try hardware DPCM playback instead. Otherwise, OAM DMA will cause a 512-cycle hiccup in your sample playback.For example, I wanted to have my character die in the game, and possibly let out a scream of some sort. Their body flies back
One thing you can do to save space is convert your samples into 4-bit and pack two samples to the byte. Plenty of commercial NES games did this with linear PCM (e.g. $8A $43 $67 $D6 in wav -> $84 $6D in rom -> $40 $20 $30 $68 in $4011) for a modest improvement over hardware DPCM quality especially in the treble. In another topic, I explained a software ADPCM technique that brought still more improvement.