+ Reply to Thread
Page 1 of 2
1 2 Last
Results 1 to 15 of 26

Thread: Audio recording/playback using PIC

  1. #1
    piper91765 Newbie
    Join Date
    Aug 2008
    Posts
    16

    Default Audio recording/playback using PIC

    Hello all,

    I have a senior project that I need to get started on and I was looking for some guidance. My goal is to record a guitar solo for later playback using a µController. I need to create a circuit that has the following functionalities:

    1) Record mid to high quality audio using a µController, audio recording IC, or a combination of the two.
    2) IC/uC must be able to store 1-2 minutes with a sampling rate of 44.1k.
    3) Store this audio using either internal memory or on an external SD card.
    4) Have the ability to playback the audio on demand via control of a uC.

    If you have any ideas, please feel free to share them. Also, if you have seen similar projects, please let me know!
    Thanks


  2. #2
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,736

    Default

    Quote Originally Posted by piper91765 View Post
    Hello all,

    I have a senior project that I need to get started on and I was looking for some guidance. My goal is to record a guitar solo for later playback using a µController. I need to create a circuit that has the following functionalities:

    1) Record mid to high quality audio using a µController, audio recording IC, or a combination of the two.
    2) IC/uC must be able to store 1-2 minutes with a sampling rate of 44.1k.
    Assuming mono, and 16 bit (or 10 bit if using most common PIC's), you will require just over 5 megabytes per minute.


    3) Store this audio using either internal memory or on an external SD card.
    PIC's have a few tens, or at most hundreds, of bytes of 'RAM', so that's not going to happen

    An SD card is a better possibility, but I'm not sure how fast you can write to them?.


    4) Have the ability to playback the audio on demand via control of a uC.
    That's no problem at all, you should be able to read an SD card that fast easy enough and output via a D2A.

    Obviously you MUST have anti-aliasing filters on both input and output.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  3. #3
    piper91765 Newbie
    Join Date
    Aug 2008
    Posts
    16

    Default

    Thank you for your response. A quick google search revealed this:

    http://www.thetechzone.com/?m=show&id=190

    It basically says that a 32x SD card can be written to at a speed of 4.8MB/s, i'm not sure if a PIC can write to the card that fast, but the card seems to have the capability of accepting high speeds.

    I'm not very familiar with Anti-Aliasing, i'll have to look that up when I get the chance.

    Any design consideration advice?

    Also, i'm worried about programming. I am assuming that I should try and store this data in a relatively known format such as WAV, is anyone aware of a sample code that I could look at to help me program this pic to store the audio in WAV?

  4. #4
    transistance Good transistance Good
    Join Date
    Apr 2008
    Location
    Istanbul
    Posts
    154
    Blog Entries
    1

    Default

    Here are some designs that might help you out:
    120 Second Voice Recorder
    Simple Voice Recorder

    Give more details on your project requirements and restrictions - such as type of microcontroller, budget, etc...
    Last edited by transistance; 21st August 2008 at 08:27 AM.
    transistance is futile...

  5. #5
    piper91765 Newbie
    Join Date
    Aug 2008
    Posts
    16

    Default

    Quote Originally Posted by transistance View Post
    Here are some designs that might help you out:
    120 Second Voice Recorder
    Simple Voice Recorder

    Give more details on your project requirements and restrictions - such as type of microcontroller, budget, etc...
    I couldn't check thoes links here at work because my firewall didn't deem them "work appropriate" so I'll check them when I get home tonight.

    Budget: $500 (but i know it shouldn't cost that much)
    Features: I would like a high quality recording, something that is a full 44.1k sample rate would be nice.
    Type of uController: Any that works, I don't have any preference to a single brand, but I may need one with a lot of ports, because I'm going to need to interface with an SD card and have controls for stop,play, etc.

    I was looking at this as an altertnative to an SD card.
    http://hem.passagen.se/communication/speach.html
    But I'm worried about sound quality. I don't want this to sound like an answering machine, so I don't know if this chip is appropriate.

  6. #6
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,736

    Default

    It's similar to the links posted, a voice quality recorder chip - like I said above, you need around 5 megabytes to store 120 seconds of mono 16 bit audio at CD quality.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  7. #7
    Someone Electro Newbie
    Join Date
    Sep 2003
    Location
    A boring village in Europe (slovene)
    Posts
    2,601

    Default

    i did such a project with a SD card and a dsPIC30F without any other ICs. It could do 48Khz without a problem. But i didn't make it record also.
    Il give you shocking experience.

  8. #8
    piper91765 Newbie
    Join Date
    Aug 2008
    Posts
    16

    Default

    Quote Originally Posted by Nigel Goodwin View Post
    It's similar to the links posted, a voice quality recorder chip - like I said above, you need around 5 megabytes to store 120 seconds of mono 16 bit audio at CD quality.

    I hear what you're saying Nigel, I'm leaning toward the SD card idea because the 120 sec chip has a max sample rate of 8.1 k samples/sec (that's telephone quality)

    I calculate 5.05 MB per min:
    44,100 (samples/sec) *60 (sec/min) *16 (Bits/sample) * 1/8 (byte/bit) * 1/1,048,576 (MB/ bytes)= 5.047 MB (using unit conversion)

    Let me know if any of that is incorrect. Are you dividing by two due to the mono? That is to say 22,050 samples per channel per second?

  9. #9
    piper91765 Newbie
    Join Date
    Aug 2008
    Posts
    16

    Default

    Quote Originally Posted by Someone Electro View Post
    i did such a project with a SD card and a dsPIC30F without any other ICs. It could do 48Khz without a problem. But i didn't make it record also.

    Any help with the programming? (that's what i'm worried about) Documentation? Website assistance?

  10. #10
    Someone Electro Newbie
    Join Date
    Sep 2003
    Location
    A boring village in Europe (slovene)
    Posts
    2,601

    Default

    Yeah i have a little for you

    Code that interfaces a SD or CF memory card or a IDE harddrive and even handles a FAT12 FAT16 or FAT32 filesystem
    http://www.microchip.com/stellent/id...pnote=en532040

    Information about the WAV file format
    http://ccrma.stanford.edu/courses/42...ts/WaveFormat/


    As for the DAC i just used a PWM at a very high frequency and used a resistor and capacitor filter on it, It seams to produce a excellent sound ( better than a cheap PC sound card ) Or one of the dsPIC33F chips has a built in audio DAC with its own buffer.
    Il give you shocking experience.

  11. #11
    piper91765 Newbie
    Join Date
    Aug 2008
    Posts
    16

    Default

    Quote Originally Posted by Someone Electro View Post
    Yeah i have a little for you

    Code that interfaces a SD or CF memory card or a IDE harddrive and even handles a FAT12 FAT16 or FAT32 filesystem
    http://www.microchip.com/stellent/id...pnote=en532040

    Information about the WAV file format
    http://ccrma.stanford.edu/courses/42...ts/WaveFormat/


    As for the DAC i just used a PWM at a very high frequency and used a resistor and capacitor filter on it, It seams to produce a excellent sound ( better than a cheap PC sound card ) Or one of the dsPIC33F chips has a built in audio DAC with its own buffer.



    Thanks, I'll review these.

  12. #12
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,736

    Default

    Quote Originally Posted by piper91765 View Post
    I hear what you're saying Nigel, I'm leaning toward the SD card idea because the 120 sec chip has a max sample rate of 8.1 k samples/sec (that's telephone quality)

    I calculate 5.05 MB per min:
    44,100 (samples/sec) *60 (sec/min) *16 (Bits/sample) * 1/8 (byte/bit) * 1/1,048,576 (MB/ bytes)= 5.047 MB (using unit conversion)
    Sorry, refer to my earlier post, 5 megabytes per minute.


    Let me know if any of that is incorrect. Are you dividing by two due to the mono? That is to say 22,050 samples per channel per second?
    No, the 44.1KHz is per channel, I incorrectly typed the time for one minute only.
    PIC programmer software, and PIC Tutorials at:
    http://www.winpicprog.co.uk

  13. #13
    Eurisko Newbie
    Join Date
    Aug 2008
    Posts
    7

    Default

    Quote Originally Posted by piper91765 View Post
    ...It basically says that a 32x SD card can be written to at a speed of 4.8MB/s, i'm not sure if a PIC can write to the card that fast, but the card seems to have the capability of accepting high speeds.
    Also, i'm worried about programming. I am assuming that I should try and store this data in a relatively known format such as WAV, is anyone aware of a sample code that I could look at to help me program this pic to store the audio in WAV?

    In SD 4-bit mode, that speed is probably doable. In SPI single-bit mode, you'd be lucky to hit 1 MB/sec. The 25 MHz max clock speed and the cards internal latency will reduce the transfer speed considerably.

    The good news is that you only need to transfer 88.2 KB/sec. The SD card could do that in stereo. Or quad.

    16 bit wave files (uncompressed) are incredibly easy to process. You just have to read the data from the SD card into a RAM buffer, read out two bytes 44100 times a second, popping the data into a 16 bit DAC. The output of the DAC goes into an audio amplifier, and Voila! CD quality sound.

    Use an interrupt service routine to keep the DAC busy. The ISR can flag the main program when the RAM buffer needs attention.

    The nice thing about the SD card's SPI mode is that the clock can be slowed down or shut down at any time. The ISR can interrupt the program at ANY point, and the SD card doesn't even care!
    Last edited by Eurisko; 22nd August 2008 at 05:31 AM. Reason: spelling

  14. #14
    Someone Electro Newbie
    Join Date
    Sep 2003
    Location
    A boring village in Europe (slovene)
    Posts
    2,601

    Default

    SD cards are fast no drought even with 25Mbit SPI. But you are going to need a MCU with a lot of ram. I recommend you have an at lest 1KB of buffer between the card and the DAC. That is because the card is read in 512B chunks, reading one chunk is fast. But when it gets to the end of it it needs to go look back in the FAT16 table where the next chunk it then just to that chunk and read it.This takes some time you you need a big enough buffer so it dosent get drained completely when it dose that.

    Also take a look at the dsPIC33F micronctroler family. They have a 40MIPS 16bit CPU with a DSP endgine that helps it with math. Also it has a preperial inside that moves data between ram and other preperials without the CPU doing it.Also one other sweet thing is that some have a built in stereo audio DAC that has its small buffer in it.This means you only interupt when your buffer needs to be filled That means a LOT less interupts and saveing a lot of the CPU time so you have lots of room for other stuff. (These MCUs are esaly fast enough to do things like digital tone controll and such effects along playing it)
    Il give you shocking experience.

  15. #15
    piper91765 Newbie
    Join Date
    Aug 2008
    Posts
    16

    Default

    Ok, so I have a handle on the hardware I should use.

    My plans are:

    1) Impliment some type of bandlimiting filter on the input to A/D converter (400 Hz to 20kHz = guitar audio range)
    2) Use pic33f family uController (I looked over the specs and they look impressive).
    3) Use SD memory card to store data.
    4) Amplify signal after D/A converter to speaker (maybe another filter, I dont know if its necessary).

    Thoes are my hardware considerations.

    Someone earlier mentioned anti-ailising filters, can anyone explain what that is used for and where to impliment them?

    Also, I'm at a loss for how to program this thing. Maybe I should formulate a high level plan for the two modes (record/play) and see what you guys think. I'll work on it.

    Any comments?

+ Reply to Thread
Page 1 of 2
1 2 Last

Similar Threads

  1. ADC (audio sampling) and PWM (audio playback)
    By MrNobody in forum Micro Controllers
    Replies: 52
    Latest: 27th November 2008, 01:47 AM
  2. Recording servo motion for playback
    By joshua17ss2 in forum Micro Controllers
    Replies: 4
    Latest: 30th April 2008, 10:00 PM
  3. Audio playback by pic
    By display in forum Micro Controllers
    Replies: 24
    Latest: 28th November 2006, 05:57 AM
  4. sound recording and playback
    By rana in forum Datasheet/Parts Requests
    Replies: 1
    Latest: 15th October 2005, 08:27 AM
  5. audio recording,need help
    By drom in forum Electronic Projects Design/Ideas/Reviews
    Replies: 14
    Latest: 16th March 2005, 05:07 PM

Tags for this Thread