Hello,
I tried above lines with my application as below:
void MyappAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
{
juce::ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
auto tune = 2.0; // let's introduce a variable that will tune our signal.
auto readHead = 0; // we need a variable that acts as sort of an index
for (auto i = 0; i < buffer.getNumSamples(); ++i) {
for (auto ch = 0; ch < buffer.getNumChannels(); ++ch)
{
int chantoread = ch % fileBuffer.getNumChannels();
//buffer[ch][i] = fileBuffer[ch][readHead]; //this expression not possible
buffer.setSample(ch, i, tune * fileBuffer.getSample(chantoread, filepos_start));
}
readHead += tune;
while (readHead >= buffer.getNumSamples()) readHead -= buffer.getNumSamples();
}
}
Is it okay or something wrong?
I am sharing one more function. So you can understand how i am trying to load audio file.
void MyappAudioProcessor::loadFile(juce::File file)
{
std::cout << "File path: " << file.getFullPathName() << std::endl;
myFormatReader = formatManager.createReaderFor (file);
if (myFormatReader != nullptr)
{
fileBuffer.setSize (myFormatReader->numChannels, (int)myFormatReader->lengthInSamples);
std::cout << "Number of samples in buffer "<<fileBuffer.getNumSamples()<<std::endl;
std::cout << "lengthInSamples "<<myFormatReader->lengthInSamples<<std::endl;
myFormatReader->read (&fileBuffer, 0, (int) myFormatReader->lengthInSamples, 0, true, true);
filepos_end = fileBuffer.getNumSamples();
if (mute == false)
filepos_start = 0;
else
filepos_start = filepos_end;
thumbnail.setSource (new juce::FileInputSource (file));
play = false;
mute = false;
reverse = false;
}
}