PDA

View Full Version : Sound recording



Somnium
10-08-2006, 04:28 AM
How would I go about doing this...

When a sound comes into my chip it will save the sound, start recording with another sound input (mic) as well as start a servo to move... at the end the chip will be triggered by a switch that will combine the two sounds together and send it out through headphone.

Is this at all possible and how would I go about doing it? Thanks...

Post Edited By Moderator (Joshua Donelson (Parallax)) : 10/23/2009 4:42:14 AM GMT

Mike Green
10-08-2006, 04:43 AM
There are examples in the Parallax Object Exchange of objects that will convert sound from the microphone into bytes and then convert it back directly to the headphone output. Someone recently posted an example of a variation that added a short delay to the sound. There is limited memory in the Propeller and sound usually takes a lot of memory to record. There will be a sound library posted sometime in the near future as part of the HYDRA project and I think it will have some sound recording routines. There will be certainly some sound playback routines in that library. There are also two objects in the Object Exchange that can drive one or more servos given a desired control pulse width.

Combining two sound streams is beyond the level of what you're likely to find for detailed advice here. If you're going to play one sound through one channel and the other through the other, you just need the sound samples to be "clocked" at the same rate. Two cogs can be synchronized to put out samples to each of two channels at the same time. If you want to combine two streams into one channel, you'll have to add the samples together and, if necessary, scale them so they don't exceed the maximum value in the digital to analog converter.

Somnium
10-08-2006, 01:42 PM
Is there a way to store the sound externally? like maybe a computer or something?

Mike Green
10-08-2006, 07:52 PM
You can attach serial EEPROM (or RAMTRON's serial FRAM) to the Propeller. These come in sizes from about 32K x 8 to 128K x 8. There are a few larger units (to 512K x 8) that are quite different to use. There are also several manufacturers that make interfaces to MMC/SD cards and USB thumb drives. You can use a serial COM port on a PC, certainly up to 112KB. Most EEPROM is too slow to use for real-time sound recording above about 8kHz without some kind of compression, so you'd be limited to what you can buffer internally unless you use faster external memory.

Newzed
10-08-2006, 08:33 PM
Let me see if I understand this - if I remove the 24LC256 EEPROM from my Propeller board and simply plug in a 24LC512 EEPROM, this will give me 64K of memory for each cog. The change in EEPROMs will be transparent to the Propeller. Is this correct?

Sid

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Need a TV Module?

Newzed@aol.com (mailto:Module?Newzed@aol.com)

Mike Green
10-08-2006, 09:42 PM
Sort of. The Propeller boot loader (and the Propeller Tool) only know about the first 32K of any EEPROM connected to pins 28/29. You can write a program that accesses the additional memory and uses it for whatever it wants. The Propeller OS does this. When it starts, it uses its own routines to look in whatever EEPROM is connected to pins 28/29. If it finds additional EEPROM there (more than 32K), it looks for specific information at the end of each 32K "page" that tells it that there's a file name stored there.

There are I2C routines in the Propeller Object Exchange that can be used for this and the Propeller OS routines can also be used by themselves to access this memory.

Newzed
10-08-2006, 09:52 PM
So.........if I'm using the OS system I can change the EEPROM, Propeller will know all about it, and I will have 64K of memory for each cog. Do I have it straight yet?

Sid

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Need a TV Module?

Newzed@aol.com (mailto:Module?Newzed@aol.com)

Mike Green
10-08-2006, 10:19 PM
No. The Propeller itself only knows about the first 32K and only uses that to initially load the RAM (main HUB/SPIN memory) when you reset the chip or uses that to make a copy of the program in RAM when it's directed to do so by the Propeller Tool. Nothing that you attach to the Propeller will increase the amount of memory addressable by the COGs or directly accessible to SPIN. Think of the EEPROM the same as a disk drive on a PC. The PC boots from the disk drive, and can load programs from the disk drive into main memory, but, if you don't have enough main memory for the program to run, it doesn't matter how big a disk you have, you still won't be able to run the program.

Newzed
10-08-2006, 10:33 PM
Well, that clears that up. Someday - not today - I will ask what would I do with the extra 256K of EEPROM and how would I use it. Oh, well.......

Sid

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Need a TV Module?

Newzed@aol.com (mailto:Module?Newzed@aol.com)

Somnium
10-08-2006, 11:19 PM
ok then... would it be possible to get the input then just change it to play backwards but send the sound out after a certain amount of time?

Mike Green
10-09-2006, 02:54 AM
Somnium,
As long as you can buffer the sound in the Propeller's memory (the sound is short enough and the quality of what you can afford to record is good enough), you can play it backwards, forwards, both directions at the same time, any time you want. Again, someone recently posted a variation on the sound playing example in the Propeller Tool's demo library that adds an echo to sound from the Demo Board's microphone by buffering sound for a short period of time and adding it back into the live sound stream. I'm sorry, I don't have the link to it.
Mike