Audio Streaming from Mike using AudioTransportSource


#1

Hello All,

I am new to Juce and I am continuously learning on using juce. I have implemented the Audio REcording and the playback with the help of the tutorials found in Juce Demo.

Now I am trying to implement the live treaming from the mike to the speaker.  The below code is used for audio playback. Like the same code, instead of reading from file, I want to stream from the input device. I am searching how to do it. But unable to find it. COuld any one please help me on this??

 

Thanks in davance for your reply.

 

 

kRetCode_t AudioPlayback::startPlayback(const File& audiofile)
{
    kRetCode_t retCode = kError;
    if(GlobalStaticClass::IsInputDeviceInitialised())
    {
        if( ! transportSource.isPlaying())
        {
            AudioFormatReader* reader = formatManager.createReaderFor (audiofile);

            if (reader != nullptr)
            {
                readerSource = new AudioFormatReaderSource (reader, true);
                // ..and plug it into our transport source
                transportSource.setSource (readerSource,
                    32768,                   // tells it to buffer this many samples ahead
                    &thread,                 // this is the background thread to use for reading-ahead
                    reader->sampleRate);     // allows for sample rate correction
                transportSource.setPosition(0);
                transportSource.start();
                retCode = kNoError;
            }
        }
    }
    return retCode;