Non-realtime audio editing

How do I edit the audio data stored in a AudioFormatReaderSource I know how to do it in real time, but i need a non-real time aproach.

I tried loading the complete audio data in a buffer but then I don't know how to play it. 


Try using an AudioProcessor instead.  Give it an AudioSampleBuffer, then ...


load with something like this .....


    // Create a reader
    AudioFormatManager formatManager;


    // scoped pointer wont delete properly on windows ....
    ScopedPointer<AudioFormatReader> reader (formatManager.createReaderFor(myFile));

    // READ the File
    int lengthToRead = reader->lengthInSamples;
    jassert(lengthToRead != 0);

    sampleBuffer->setSize(2, lengthToRead, true, true, true); // set the size appropriately
    // READ THE FILE to the BUFFER 
    reader->read(sampleBuffer, 0, lengthToRead, 0, true, true);


To play it .... simply copy it ito the buffer in the processBlock() method .....

 for (short chan=0; chan < buffer->getNumChannels(); chan++)
        buffer->addFrom(chan, 0, sampleBuffer->getReadPointer(chan%2, playPos), numSamples);

 playPos = (playPos + numSamples)%sampleBuffer->getnumSamples();


Obviously, you can then edit the sampleBuffer any way you like (either within the processblock, or not).




Thanks! for the reply but if I make it this way I cannot use a transport source to change the sample rate, is there any simple solution?