STAMP Sound
Sachiel7
Posts: 41
Hey Everyone,
This is my first post here, so hey.
Alrighty, where to begin, well, lets see.
I'm working on a self-designed game system I call the Retrosys. Its basically a Basic Stamp 2sx on a Super Carrier board with an ezVid 2.0 (from multilabs)
I've been working with the system for over a year now, and am already planning a RetroSys 2.0, if you will.
I want the newer system to have some sound, for once.
So, I've been trying to develop a circuit that will serve as a suitable digital audio device.
My main problem is that I'm really not too well versed in circuits, but somewhat in digital audio, so,
here's my plans:
-I plan to have the sound device output 16bit 11.025 kHz Stereo Audio (22.05 kBs).
-The Device will have about 8 Mb of EEPROM memory to store sample data.
-The memory will be used to store 1 second sound clips, which will be stored in 48 note (4 octave) banks.
-6 48 note banks will be available, as well as a ~35 note "effects" bank for random sounds.
-1 Mb of the memory will be available for extra storage and·sequencing data
Now, here's where my (mis)understanding of Digital Audio comes in. I'm sampling audio at a rate of 11.025kHz. Each 'sample' is a measure of the frequency at that point in time.
So, my basic understanding is that I will need to have a microprocessor driving this device that generates a frequency at every interval basically by toggling a pin at the rate of the sample.
Dont know if I explained that properly at all...hmm.
Also, I'm curious how volume/amplitude come into play too.
I know I posted this in the Stamp forum, because all I have at my disposal right now is a BS2sx to test some of these theories on, but, I am currently planning to develop the newer system around the Propeller. The concept, however, should be the same, between either microprocessor.
How can I create a decent sound Device?
(I'm looking for something more advanced than just a mono set of sine and square waves)
Post Edited (Sachiel7) : 12/8/2006 5:09:35 AM GMT
This is my first post here, so hey.
Alrighty, where to begin, well, lets see.
I'm working on a self-designed game system I call the Retrosys. Its basically a Basic Stamp 2sx on a Super Carrier board with an ezVid 2.0 (from multilabs)
I've been working with the system for over a year now, and am already planning a RetroSys 2.0, if you will.
I want the newer system to have some sound, for once.
So, I've been trying to develop a circuit that will serve as a suitable digital audio device.
My main problem is that I'm really not too well versed in circuits, but somewhat in digital audio, so,
here's my plans:
-I plan to have the sound device output 16bit 11.025 kHz Stereo Audio (22.05 kBs).
-The Device will have about 8 Mb of EEPROM memory to store sample data.
-The memory will be used to store 1 second sound clips, which will be stored in 48 note (4 octave) banks.
-6 48 note banks will be available, as well as a ~35 note "effects" bank for random sounds.
-1 Mb of the memory will be available for extra storage and·sequencing data
Now, here's where my (mis)understanding of Digital Audio comes in. I'm sampling audio at a rate of 11.025kHz. Each 'sample' is a measure of the frequency at that point in time.
So, my basic understanding is that I will need to have a microprocessor driving this device that generates a frequency at every interval basically by toggling a pin at the rate of the sample.
Dont know if I explained that properly at all...hmm.
Also, I'm curious how volume/amplitude come into play too.
I know I posted this in the Stamp forum, because all I have at my disposal right now is a BS2sx to test some of these theories on, but, I am currently planning to develop the newer system around the Propeller. The concept, however, should be the same, between either microprocessor.
How can I create a decent sound Device?
(I'm looking for something more advanced than just a mono set of sine and square waves)
Post Edited (Sachiel7) : 12/8/2006 5:09:35 AM GMT
Comments
To fully understand creating digital sound with samples, you have to think of sound as a rapid series of changes in atmospheric pressure. (I won't call them vibrations, since that brings a definate time into the picture.) A microphone is a device capable of converting the pressure changes to voltage, and a speaker changes voltages into pressure changes. The amplitude is how big these changes are, compared to the ambient pressure. This is why big speakers have a vent on them, so they don't get air trapped behind them, which would lessen the force of the pressure changes.
With this in mind, consider a way to record the changes in pressure. We need a way to know how strong they were (amplitude), but we also need to know how they behaved. Did the pressure rise rapidly and fall off slowly? Did it follow a square form and drop almost immediately back to normal? Given the infinite varieties of changes, we can't really use a numeric system to describe how a single change happened, and expect to accurately reproduce the sound. Recording amplitude and a rough estimate of behavior just won't do.
Now we will deal with time on a definate scale. If we check the pressure at a given interval, we should be able to detect changes in pressure that last for as as little as one measurement. If we measure fast enough to catch the pressure mid-change, we will be able to adequately record how it falls. This requires only a rapid series of measurements. These are the samples we know and love.
Essentially: The samples represent the amplitude (voltage) at a given moment. To play back a series of 16-bit samples, just hook up the input of a digital-analog converter to the sample source, and the output to a speaker, and play them back at a set speed.
EDIT: I forgot, a cheap and easy DAC for experimenting can be made yourself with a breadboard, time, and a lot of resistors. See http://en.wikipedia.org/wiki/R-2R·. I've used an 8-bit DAC to generate sine waves that sounded more or less like what you get with FREQOUT. On monday, if I can find it, I'll post some code.
Post Edited (Sarten-X) : 12/9/2006 9:51:11 AM GMT
Thanks for the explanation, btw, it explains things more clearly to me.
I have found a company that manufactures cheap ADC/DAC and DSP chips, you can check them out here:
http://www.wavefrontsemi.com/index.php?products&hashID=13a2fe7418702fd111bb718bd9977afd
They're geared more specifically to audio.
So, here's my new general layout idea. Have a microprocessor thats linked to a series of EEPROM banks to store sample data, and linked to the ADC/DAC or DSP.
To load sounds I'll write an app on my lappy that will communicate with the circuit and play the sounds out of the line out on my laptop and into the ADC on the circuit. The microprocessor will take the ADC digital output and dump it into EEPROM at each sample interval.
To play back a sample, the microprocessor will output the dumped bits to the DAC at each sample interval, which will have connections for the line out.
Now, this sould give me a cheap and easy way to do sound capture and playback, but here's where my next issue comes up, mixing samples.
My ultimate goal is to be able to have sequenced music, like MIDI, that uses instrument banks made up of samples. However, since I'm only dealing with two audio channels (left and right) primarily, is there a way I can mix the samples at each interval in software on the microprocessor? I assume any simple assumption such as simply the sum of the data will not properly mix them...
I think I'm off to a good start here though, I cant wait to get this thing up and running (soon, hopefully!)
-=Sachiel7=-
It actually is the sum, but you have to work around maximum amplitude issues.
Here's a link:
http://www.vttoth.com/digimix.htm
Think I've almost got all my cards in order!· Now I just need to figure out the data transfer rate of the EEPROM...to make sure it wont kill me to stream from it...
-=Sachiel7=-
Post Edited (Sachiel7) : 12/12/2006 5:22:15 AM GMT
I was planning to use EEPROM to store the sample data and mix it through software on the processor, and stream it to a buffer that goes to the DAC. However, I am now aware that the transfer rate of EEPROM using serial methods is WAY to slow to match up with the data rate of the audio itself. So, anyone have any suggestions? I've only mainly worked with EEPROM and Serial communications, just to let you know.
-=Sachiel7=-