• AVR Freaks

Audio capture and playback

Author
KamPutty
Junior Member
  • Total Posts : 95
  • Reward points : 0
  • Joined: 2005/07/08 17:24:42
  • Status: offline
2006/10/24 13:09:02 (permalink)
0

Audio capture and playback

Hi all,

I've looked and looked and looked, and finally I need to ask someone!

I have a simple(!!!) project that -

#1. Captures audio via a condensor microphone
#2. Turns that audio into data
#3. Passed that data to another uP
#4. That uP plays the sound

Simple eh?! The issue is that I am NOT an electronics person, so this is slow going for me.
My sample rate is only going to me phone quality at best, nothing fancy...I just want to learn how to do this...

My issue is not passing the data, but capturing it, and then playing it. I've seen many other threads here and on other boards, but I'm still lost! It's just poor ol' me doing this, I have no hardware guru support!

Did I mention I am not a electronics guy?! Software okay, but electronics, NOVICE!

So.....

Can anyone help and point me to the right direction? There are 2 parts to this that need answering

#1. How do I capture audio via a microphone so I can use the ADC on my pic18f4520
#2. How do I take the data from #1, and push it out so headphones can here it (or speaker etc)

I know, I know, I know...there are many threads on this, just non have clicked in my brain!

Any and all advice will be geatly appriciated.

~Kam (^8*



#1

12 Replies Related Threads

    dchisholm
    Super Member
    • Total Posts : 3805
    • Reward points : 0
    • Joined: 2003/12/14 15:30:12
    • Location: St Louis Mo
    • Status: offline
    RE: Audio capture and playback 2006/10/24 14:50:02 (permalink)
    0
    You may discover that capturing and reproducing a voice is not as easy as it sounds.  (Do I get extra points for bad puns?)

    You might start by looking at Data Sheets and Application Notes related to the dsPIC family for clues about how to accomplish this.

    The signal from your microphone will need amplification and conditioning before you can A/D convert it.  It MIGHT be possible to use the op-amps built into a few of the PIC processors to do this, but I haven't investigated this.

    Unless the reproduction occurs essentially simultaneously with the capture you will need some kind of RAM to store the signal data - probably off-chip.

    I don't think any of the 16Fxxx or 18Fxxx parts have an on-chip D/A converter.  When that function is needed we often use the PWM capability of the CCP module followed by some analog filtering.  This might be an acceptable approach, though I doubt that it can actually achieve true telco-quality.  An off-chip D/A converter may actually be easier in the long run.

    Some other ideas (and example calculations) to look at can be found in Dr Reese's lecture notes for Mississippi State course ECE3724: http://www.ece.msstate.edu/~reese/ece3724/lectures/chap14_audiosample.pdf

    Dale

    edit: update link
    post edited by dchisholm - 2009/05/04 11:52:28
    #2
    KamPutty
    Junior Member
    • Total Posts : 95
    • Reward points : 0
    • Joined: 2005/07/08 17:24:42
    • Status: offline
    RE: Audio capture and playback 2006/10/24 16:01:35 (permalink)
    0
    Dale,

    Thank you for your reply. The URL contains GOLD!!!

    ~Kam (^8*
    #3
    ljm.weber
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2006/01/31 15:02:32
    • Location: 0
    • Status: offline
    RE: Audio capture and playback 2006/10/27 13:51:46 (permalink)
    0
    I have seen and worked on circuits used by the army and thought that I should tell you this:
    The interesting sound range for voice lays between 20Hz and less than 4800Hz. This means, that you don't need the fastest ADC available. You might not end up with telecom quality, but a clear voice transmission can be atchieved.
     
    God bless
     
    Mani
    #4
    dchisholm
    Super Member
    • Total Posts : 3805
    • Reward points : 0
    • Joined: 2003/12/14 15:30:12
    • Location: St Louis Mo
    • Status: offline
    RE: Audio capture and playback 2006/10/27 14:27:52 (permalink)
    0
    ORIGINAL: ljm.weber

    The interesting sound range for voice lays between 20Hz and less than 4800Hz.
    For decades the "standard" telco analog voice channel was assumed to extend from 400 Hz to 3500 Hz, though in practice wider bandwidth was often provided.  The early digital systems (anybody remember the term "span line"?) used a lopass filter that essentially killed everything above 4 KHz, sampled at 8 KHz and digitized with a 7-bit code.  (8 KHz x 7 bits = 56 KB/sec: ever wonder why dial-up modems don't go much faster than that?)  Those parameters should give you an idea of what resources are required for a moderate level of performance in a speech reproduction system. 

    Dale
    #5
    sirc4526
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2009/05/04 03:25:56
    • Location: 0
    • Status: offline
    RE: Audio capture and playback 2009/05/04 20:14:02 (permalink)
    0
    Sir, I have a project where I need to encrypt voice signal from a microphone. I believe that I should convert it first to digital so encryption is simpler. I made a program to utilize PIC 16F877A's A/D converter but I am not sure if it is correct. I am using CCS C Compiler and here is my program:

    #include<16F877A.h>
    #device adc=10
    #fuses HS,NOWDT,NOPROTECT,NOLVP
    #use delay (clock=20000000)
    #use rs232 (baud=9600, xmit=PIN_C6, rcv=PIN_C7)

    void main()
    {
    float sample;

    //setup the ic ports in preparation for adc
    set_tris_a(0xFF);
    setup_port_a(ALL_ANALOG);
    setup_adc(ADC_CLOCK_INTERNAL);
    set_adc_channel(0);

    printf("\n\nSampling");
    delay_ms(100);

    //place the sampling syntax inside this do-while loop to enable continuous sampling.
    do
    {
    delay_ms(500);
    sample=Read_ADC();
    if(!input(PIN_B0))
    {printf("\n\n Measured Value: %1.2f",sample);
    output_d(sample);
    }
    }while(TRUE);

    }

    The output is sent to the PC Monitor via RS232.
    Please note sir that I am using a development kit.

    With this program, the output does not vary when nothing is attached to port A. but when I attach an input (MUSIC DIRECTLY FROM LAPTOP's SPEAKER OUTPUT JACK). The output varies, but it only varies very slightly like 1018-1023 something like that sir... I don't know if I still need some circuit for the input before I attach it to the analog input port... sir thank you very much for responding!
    #6
    vu2iti
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2003/11/07 12:39:09
    • Location: India
    • Status: offline
    RE: Audio capture and playback 2009/05/27 01:11:29 (permalink)
    0
    Dear sirc4526,
    It seems that you are sampling your signal with 2 samples per second. You need to sample the signal atleast twice the maximum frequency content in your signal. For speech signals a sampleing rate of 8 KSPS is good . ( check up the RS232 speed also)

    Good luck!

    VU2ITI
    #7
    sirc4526
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2009/05/04 03:25:56
    • Location: 0
    • Status: offline
    RE: Audio capture and playback 2009/05/27 01:18:33 (permalink)
    0
    thanks for the respons sir! just wanted to know how u were able to say that my sampling rate is only 2 times? thank you sir!
    post edited by sirc4526 - 2009/05/27 20:33:46
    #8
    leon_heller
    Super Member
    • Total Posts : 6411
    • Reward points : 0
    • Joined: 2004/08/17 13:19:45
    • Location: St. Leonards-on-Sea, E. Sussex, UK.
    • Status: offline
    RE: Audio capture and playback 2009/05/27 03:58:30 (permalink)
    0
    An anti-aliasing filter before the ADC is a good idea, to prevent higher frequencies than 3.5 kHz being converted and processed.

    Radio amateurs generally use 300 Hz to 3 kHz.

    Leon

    Leon Heller
    G1HSM

    #9
    vu2iti
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2003/11/07 12:39:09
    • Location: India
    • Status: offline
    RE: Audio capture and playback 2009/05/27 07:34:05 (permalink)
    0

    Your do loop contains a a delay of 500 milli seconds. So you will be taking reading for every 500 m seconds.
    VU2ITI
    #10
    vu2iti
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2003/11/07 12:39:09
    • Location: India
    • Status: offline
    RE: Audio capture and playback 2009/05/27 07:41:58 (permalink)
    0
    ORIGINAL: sirc4526


    With this program, the output does not vary when nothing is attached to port A. but when I attach an input (MUSIC DIRECTLY FROM LAPTOP's SPEAKER OUTPUT JACK).


    I forgot to mention one thing: The PIC ADC is  Unipolar  One. You cannot give signals from laptop's speaker out to the ADC input.   { make it unipolar, by offsetting a DC value to the speaker out}
    VU2ITI
    #11
    QuantumInfo
    New Member
    • Total Posts : 12
    • Reward points : 0
    • Joined: 2009/08/19 12:45:39
    • Location: 0
    • Status: offline
    RE: Audio capture and playback 2009/11/25 04:26:09 (permalink)
    0
    Did you get your encryption algo working in the PIC?
    #12
    nykei_j
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2010/02/09 16:27:06
    • Location: 0
    • Status: offline
    RE: Audio capture and playback 2010/02/17 16:27:21 (permalink)
    0
    HI
    i read this forum.
    so, if i have to capture signals from sensors, can we implement similar way?
    basically, i have to capture couple of signals from different sensors,
    and then feed it to computer.
    so, i just want to use pic32 to read the signals from sensor and feed it to computer.
    any help guys?
    thanks.

    #13
    Jump to:
    © 2019 APG vNext Commercial Version 4.5