![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | Thread Tools | Display Modes |
| | (permalink) |
| Experienced Member | Hello, I am trying to capture the audio waveform from a cheap toy, and reproduce it with a PIC. The sound I am trying to capture is about a second long. Right now I have the toy speaker output hooked up to an input of the PIC, and the actual speaker of the toy connected to an output of the PIC. For the code I am just using "output = input" and it makes an acceptable reproduction of the sound. Is there a way to capture this sound on the PIC, save it, and play it back at a later time? Ideally I would like to capture the sound (series of 1s and 0s) to RAM, then save to EEPROM, then pull the data from the computer and add to the code of a PIC to reproduce the sound when I wanted to. Right now I am limited by the small amount of RAM on the PIC. I was thinking that maybe instead of capturing the data straight, and outputting straight, I could instead capture the time between a 0 and 1, and 1 and 0, basically just capture the delays? Please let me know if you have any bright ideas! I will continue messing with it. |
| | |
| | (permalink) |
| Experienced Member | By your description (all this talk about 1s and 0s), it sounds like you are trying to reproduce a square wave...and nothing but a square wave. To Reproduce a sound you need more data than that. FOr example, 8-bit values sampled consecutively in time. Sound is more than just high or low (1 or 0). FOr example if I wanted to reproduce a tone (sin wave) I would store a bunch of 8-bit values at different points in time, each value being the magnitude of the sinusoid at that point in time. You may need to use some other form of external memory... |
| | |
| | (permalink) |
| Experienced Member | You can certainly make a sound with a square wave. The toy is cheap, and makes the sound with a square wave. So that is all the PIC needs to do. |
| | |
| | (permalink) |
| Experienced Member | I still don't see how it would work, but assuming that is the case, then you'd have to try both methods and see which one takes less memory. Since the period of time would have to be stored as a byte (or so), and if there are enough transitions during the sound then you could be using up to 8x more memory than if you went the other way. Or you could filter out transistions that are too short to reduce the number of transistions in the sound to reduce memory size. |
| | |
| | (permalink) |
| Experienced Member | |
| | |
| | (permalink) |
| Experienced Member | Thanks for the suggestion. I found that link a while ago, but didn't look into it too much. After you suggesting it, I looked into it some more, and it is actually exactly what I need. Thanks! |
| | |
| | (permalink) |
| Super Moderator | What is the actual audio you're trying to capture?, originally I presumed you needed analogue to digital conversion and storage, for an analogue audio signal. But then it seemed like it was a simple digital 'beep' type noise, where you could easily duplicate it without any analogue techniques. |
| | |
| | (permalink) |
| Experienced Member | It is a beep, but is is a weird beep that I could not figure out how to duplicate with just a simple coded square wave. Using Roman's audio program I have been able to make an acceptable copy of the sound, but it takes up a lot of room. I've attached a .wav of the sound, have a crack at it and see if you can duplicate it, if you want. Remove .zip, it isn't a zip file. |
| | |
| | (permalink) |
| Moderator | The .zip is corrupted. Upload it to the forum as an audio file
__________________ MechTronics |
| | |
| | (permalink) | |
| Experienced Member | Quote:
| |
| | |
| | (permalink) | |
| Experienced Member | Quote:
I did what you mentioned with a for loop a while ago, and never found a frequency that sounded like I wanted it to. | |
| | |
| | (permalink) | |
| Experienced Member | Quote:
| |
| | |
| | (permalink) |
| New Member | did u get this working man? im really interested in this audio rec and play issue but i dont really understand how to reproduce the tables, or how to connect the outputs to the speaker, if some one could explain that for me i would thank you a lot, really, thanks ^^ |
| | |
| | (permalink) |
| Experienced Member | dknguyen, I had to read it a couple times myself before I got it. Fred, post the project (code at least) when you are done. I too have thought about doing it and never did. I recalled that site from way back, was hard to find. But it is a neat idea for sounds from the pic/uC. Also, the bit bang might be fine. I did that with the old TRS-80 way back. It did not sound great but was clear enough. |
| | |