Using Juce, I tried to create a simple audio recorder from the demo runner. I've extracted the AudioRecordingDemo to create audio recorder based on a simple audio project.
When I'm clicking on the start recording button, the sampleRate still have the default value:
void startRecording(const File& file)
{
stop();
if (sampleRate > 0)
{
// Create an OutputStream to write to our destination file...
sampleRate = 0.0
In the AudioRecordingDemo, the audioDeviceAboutToStart increment the sample rate. But I don't have any AudioIODevice in my main component.
void audioDeviceAboutToStart(AudioIODevice* device) override
{
sampleRate = device->getCurrentSampleRate();
}
The AudioIODeviceCallback that sets up the input and ouput is also never called in my code. I tried to use it in my MainComponent class without success.
I also tried to make the MainComponent class inherits from the AudioIODeviceCallback :
class MainComponent : public Component,
private AudioIODeviceCallback,
private MidiInputCallback
{
public:
//...
I found this method in the Build a multi-polyphonic synthesiser tutorial.
But when I tried this, I got an overwriting error in the main class.
So here is my problem, how to use the AudioIODeviceCallback, audioDeviceAboutToStart and audioDeviceStopped that are defined in the AudioRecordingDemo class in my project ?
You can find the source code here.
I fixed my problem by adding the audioDeviceIOCallback to my MainComponent Class :
void audioDeviceIOCallback (const float** /*inputChannelData*/, int /*numInputChannels*/,
float** outputChannelData, int numOutputChannels,
int numSamples) override
{
// make buffer
AudioBuffer<float> buffer (outputChannelData, numOutputChannels, numSamples);
// clear it to silence
buffer.clear();
}
The source code up to date : SimpleAudioRecorder