Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Basic audio record queue and playback

  1. #1
    Junior Member
    Join Date
    Jun 2019
    Posts
    1

    Basic audio record queue and playback

    Looking for documentation for how to use a few filters and use the audio queue and playback. Specifically to output left channel and right channel separate as my pcb I made has two mems microphones

    Iím trying to follow the GUI designer but itís not for newbies like myself

    Here is my code: (pseudo code)

    Setup()
    AudioInputI2S i2sIN;
    AudioOutputI2S i2sOUT;
    AudioFilterBiquad biquadINNER;
    AudioFilterBiquad biquadOUTER;
    AudioRecordQueue queueInInner;
    AudioRecordQueue queueInOuter;
    AudioPlayQueue queueOut;
    AudioConnection pathCord0(i2sIN,0,biquadINNER,0);
    AudioConnection pathCord3(i2sIN,1,biquadOUTER,0);
    AudioConnection patchCord1(biquadINNER, 0, queueInInner, 0); // This is where we swap channels if necessary
    AudioConnection patchCord2(biquadOUTER, 0, queueInOuter, 0); // Swap these two 0,1 to swap audio channels
    AudioConnection patchCord9(queueOut,0,i2sOUT,0);
    AudioConnection patchCord10(queueOut,0,i2sOUT,1);
    AudioControlSGTL5000 sgtl5000_1;


    Loop()
    if (queueInInner.available() >= 2 && queueInOuter.available() >= 2) { //input buffer is filled, unload it please
    memcpy(bufferOuter, queueInOuter.readBuffer(), 256);
    memcpy(bufferInner, queueInInner.readBuffer(), 256);
    memcpy(bufferAverage+(256*buffer_ptr), bufferInner, 256);

    /*if (filterSwitch == 1) {
    my_adaptive_filter(bufferInner, bufferInnerLeftover, bufferOuter, bufferOuterLeftover, errorout, aweights,10000, BufferLen, AFiltLen);
    }*/
    memcpy(errorout, bufferInner, 256);

    int16_t * playerptr = queueOut.getBuffer();
    memcpy(playerptr,errorout,256);
    memcpy(bufferAverage+(256*buffer_ptr++), errorout, 256);
    queueOut.playBuffer();
    queueInOuter.freeBuffer();
    queueInInner.freeBuffer();
    }

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,068
    Quote Originally Posted by Bretcj7 View Post
    I’m trying to follow the GUI designer but it’s not for newbies like myself
    We have a 31 page tutorial to help you get started with the GUI design tool. It also comes with a 45 minute full walkthrough video. If you get stuck anywhere in the tutorial, you can watch how we did it in the video!

    However, the queue objects are not simple beginner material. They give you access to the raw audio data, which means you have to carefully craft your program to handle the rapid data streams of the audio. Usually this should be avoided, just let the audio library do all the audio data processing.

    If your goal is simply to use 2 MEMS mics, apply filters, and then output those signals elsewhere, you can do all that in the audio library without use of the queues to transfer the data to your program. Do yourself a favor and just let the audio library do the heavy lifting of processing all that data. It's designed to be fairly simple to use that way.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •