Thanks for note about ScopedPointer! Alright, I looked at the call stack and this is my corrections:
if (fileStream != nullptr)
{
WavAudioFormat wavFormat;
AudioFormatWriter* writer = wavFormat.createWriterFor(fileStream, sampleRate, 2, 16, StringPairArray(), 0);// does not fail
if (writer != nullptr)
{
fileStream.release();
threadedWriter = new AudioFormatWriter::ThreadedWriter(writer, backGroundThread, 32768);//real reason
thumbnail.reset(writer->getNumChannels(), writer->getSampleRate());
nextSampleNum = 0;
const ScopedLock sl(this->getCallbackLock());
activeWriter = threadedWriter;
}
}
}
Jassert appears in another thread. ThreadedWriter::Buffer calls for write() method, and last one calls AudioBuffer::copyFrom()
This jassert is from juce_AudioSampleBuffer.h file line 813:
void copyFrom (int destChannel,/*1*/
int destStartSample,
const Type* source,
int numSamples) noexcept
{
jassert (isPositiveAndBelow (destChannel, numChannels));
jassert (destStartSample >= 0 && destStartSample + numSamples <= size);
jassert (source != nullptr);//this one
if (numSamples > 0)
{
isClear = false;
FloatVectorOperations::copy (channels [destChannel] + destStartSample, source, numSamples);
}
}
Next jassert is from this code:
void SampleTransform::processBlock(AudioBuffer<float>& buffer/*numOfChannels is 1 instead of 2*/, MidiBuffer & midiMessages)
{
float* left = buffer.getWritePointer(0);
float* right = buffer.getWritePointer(1);//second jassert fail
//...
}
And has jassert from juce_AudioSampleBuffer.h file line 233:
Type* getWritePointer (int channelNumber/*1*/) noexcept
{
jassert (isPositiveAndBelow (channelNumber, numChannels));//this
isClear = false;
return channels [channelNumber];
}
I’m getting sample rate from at this part of this code( idk how it works by the way
):
void RecordingProcessor::prepareToPlay(double sampleRate, int maximumExpectedSamplesPerBlock)
{
this->sampleRate = getSampleRate();
}
And when i create the writer it still has the 48000 value(default by my sound card).
Am I do something wrong?