Hi Everyone... Been a while..... Just wondering if any one has any experience with outputting sound. I am working on a small project for the kids, it basically entails in a certain event a sound will play - like various farm animals (Eg. moo, dog barking, etc) I have done a little bit or research and found a few different ways of going about this. A good article to read is this: http://www.uchobby.com/index.php/2007/1 ... nd-part-1/ - Although it is very indepth. I am going to have a try at a few things however I was hoping that someone with experience with this would be able to point me in the right direction of which method I should go down to start with. Sound quality doesn't have to be exceptional however I would hope that it would at least be reasonale similar to the soundblaster 16 (can be mono) quality and would like to be able to interface with a pic (or even better have a pic handle the whole lot like the soundgin).
Anyone have any ideas? Any way take care eveyone...
Reasonable Quality Sound Output
Moderators: Chuckt, Garth, bitfogav
-
- semi-newbie
- Posts: 10
- Joined: Tue Apr 13, 2010 11:50 pm
- Location: Australia [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Reasonable Quality Sound Output
Danny
"Do not go where the path may lead; go instead where the path lead not and leave a trail"
"Do not go where the path may lead; go instead where the path lead not and leave a trail"
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Reasonable Quality Sound Output
Stacy has done some work with generating sound from a pic, he made a cool little sound chip that I put into my super pixel bros game. It was able to play music and sound fx.
As far as getting something as advanced as a sound blaster 16 though, I think that's another story!
I would be looking into microcontroller wave players or something similar. Or work out how a wav file is encoded and then program your pic to decode it and output to a dac via one of your ports.
As far as getting something as advanced as a sound blaster 16 though, I think that's another story!
I would be looking into microcontroller wave players or something similar. Or work out how a wav file is encoded and then program your pic to decode it and output to a dac via one of your ports.
Re: Reasonable Quality Sound Output
I've done a fair amount of digital recording with my workbench computer, and now am working on something to record on flash with a PIC16F72. Here are the last couple of paragraphs from the A note about A/D and D/A jitter (and other performance considerations) section of the circuit potpourri page of my 6502 primer:
Some toys have only two-bit samples and very low sampling rates and inadequate anti-alias filters (or none at all). If the dynamic range is super compressed (like AM radio is), you can get good voice intelligibility with only two bits. For what you're doing, you might want 4 or 6 bits, so you can get three or four samples in two bytes' storage with decent sound quality. Of course sampling rate is another consideration, separate from number of bits; but with good anti-alias filters, you can probably get by just fine with 6,000-8,000 samples per second. You could oversample and do some of the anti-alias filtering in software to make the hardware filters' requirements a little less stringent if desired. I'm doing that on the project mentioned above, sampling 24,000 times a second with the PIC's 8-bit A/D converter and averaging each set of four samples to record only 6,000 samples for second (for voice, not music) in the flash, and then upon playback, interpolating the oversamples and putting out 24,000 a second again, using the PIC's PWM output.How many samples do I need? and Do I need smoothing to produce a clean waveform? The answer might surprise you. Let's say you try to synthesize a sine wave with only 32 samples per cycle, or 8 samples per quarter cycle (90°). With no filtering, the first major harmonic distortion products will be the 31st and 33rd harmonics, down about 30dB from the fundamental. IOW, for a fundamental frequency above 600Hz, these will be out of the hearing range. The hottest harmonic distortion product below that is the 5th harmonic at about 54dB down from the fundamental. For a 16-sample sine wave, ie, only 4 samples per 90° (does that seem atrocious?), the first major harmonic distortion products are the 15th and 17th harmonics, down about 24db below the fundamental. The hottest harmonic distortion product below that is the 7th harmonic, at about 55dB down from the fundamental. If you go up to 64 samples per cycle, which is 16 samples per 90°, the first major harmonic distortion products are the 63rd and 65th harmonics at about 36dB below the fundamental. If you want to filter it, it will be easy, not requiring a many-order brick-wall filter, as long as you're not nearing the Nyquist frequency.
How many bits do I really need? As mentioned above, an 8-bit converter can theoretically reach a SNR of 50dB when signal is present, and have an output as quiet as that of a 24-bit converter if there's no signal, since the number won't be changing. There were some fine-sounding music cassette tapes before CDs took over, and their SNR was virtually no better than what an 8-bit converter can give you; yet the cassettes' frequency response and distortion at high record levels were quite inferior to what you can get with a good 8-bit converter and adequate sampling rate! I know it's unlikely anyone will ever use 8-bit recording for music for enjoyment, but this might put things in perspective. For things like machine control and measurements in test equipment, you will have to determine how accurate you need them, and whether external scaling and offsets will let you get by with fewer bits than you might think. There is some discussion of this in the first quarter of the front page about large look-up tables for hyperfast, accurate, 16-bit scaled-integer math. I'm definitely not against using converters of 12, 14, 16, or more bits when they are right for the application (in fact, I'm about to start shopping for a multi-channel SPI A/D of at least 12 bits), but I always like to point out what might be a pleasant unexpected discovery of what can be done with less.
http://WilsonMinesCo.com/ lots of 6502 resources
- brad
- Site Admin
- Posts: 2578
- Joined: Fri Mar 26, 2010 10:30 pm [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
Re: Reasonable Quality Sound Output
I've seen some great microcontroller sound projects out there, unfortunately it's not something i've delved into to much myself. I have created some very simple sound fx with a PIC but nothing like voice audio or multi-channel audio etc...
Who is online
Users browsing this forum: No registered users and 3 guests