AudioTransportSource assign to std::vectors


#1

Hello,
I know AudioTransportSource::getNextAudioBlock() but it assign buffer to const AudioSourceChannelInfo& . But I want to assign for example left channel buffer to std::vector<float> leftVector and right to std::vector<float> rightVector . And want to avoid assigning data to AudioSourceChannelInfo buffer.
How to make that?


#2

To be clear. I just want to manipulate the data before it goes to the speaker. But when I call transportSource.getNextAudioBlock (bufferToFill); It already play the wave file untouched.
Maybe there is some simpler thing to do than assigning to independent vector?


#3

std::vector is not compatible with Juce’s AudioBuffer and related classes anyway, so forget using those in this case. (You technically could use them but you would need to copy audio data around, which maybe isn’t what you want happening.)


#4

So how to get data from source file, change them and then send to bufferToFill?


#5

Of course I want make changes on data in the real time


#6

I am not entirely sure what you asking but just fill the buffer with the audio source and then modify the data in the buffer?


#7

But how to get those data? I am in the getNextAudioBlock want to get the buffer from source file , send it for example to some compressor or filter and then send them to the BufferToFill


#8

But when I use transportSource.getNextAudioBlock (bufferToFill); it immediately send it to the speakers.


#9

Obviously, if that’s the only code you have. Alter the buffer contents after the transportSource.getNextAudioBlock call to process the audio…


#10

Not sure what you mean. Yes I have code for making compression.


#11

It’s impossible to help without seeing more of the involved code.


#12

My code is:
void MainComponent::getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill)
{
if (wAudioPlayer.readerSource.get() == nullptr)
{
bufferToFill.clearActiveBufferRegion();
return;
}

wAudioPlayer.transportSource.getNextAudioBlock (bufferToFill);

if(makeCompression.compType !=0)
{
    makeCompression.setInputData(*bufferToFill.buffer);
}

}


#13

Code formatting problem sorry


#14

That doesn’t unfortunately tell much. Is the setInputData call supposed to process the audio? What is that function’s signature?


#15

Sorry, on the end, before last } there is more code:
for(int sample = bufferToFill.startSample; sample<bufferToFill.buffer->getNumSamples(); sample++)
{
float output;

    output = makeCompression.wOutput->at(sample);
    
    bufferToFill.buffer->addSample(0, sample, output);
}

#16

OK, I’ve found out. I’ve just created my own AudioSourceChannelInfo. And it works. Thanks for patient