title: How to use audioDeviceIOCallback, audioDeviceAboutToStart and audioDeviceStopped in a simple audio recorder program
body: <p>Using Juce, I tried to create a simple audio recorder from the <a href="https://github.com/WeAreROLI/JUCE/tree/master/examples/DemoRunner" rel="nofollow noreferrer">demo runner</a>.
  I've extracted the <a href="https://github.com/WeAreROLI/JUCE/blob/master/examples/Audio/AudioRecordingDemo.h" rel="nofollow noreferrer">AudioRecordingDemo</a> to create audio recorder based on a simple audio project.</p>
  
  <p>When I'm clicking on the start recording button, the sampleRate still have the default value: </p>
  
  <pre><code>void startRecording(const File&amp; file)
      {
          stop();
  
          if (sampleRate &gt; 0)
          { 
              // Create an OutputStream to write to our destination file...  
  </code></pre>
  
  <blockquote>
    <p>sampleRate = 0.0</p>
  </blockquote>
  
  <p>In the AudioRecordingDemo, the audioDeviceAboutToStart increment the sample rate. But I don't have any AudioIODevice in my main component.</p>
  
  <pre><code>void audioDeviceAboutToStart(AudioIODevice* device) override
  {
      sampleRate = device-&gt;getCurrentSampleRate();
  
  }
  </code></pre>
  
  <p>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.</p>
  
  <p>I also tried to make the MainComponent class inherits from the AudioIODeviceCallback :</p>
  
  <pre><code>class MainComponent : public Component,
           private AudioIODeviceCallback,
           private MidiInputCallback
  
  {
  public:
  //...
  </code></pre>
  
  <p>I found this method in the <a href="https://docs.juce.com/master/tutorial_mpe_introduction.html" rel="nofollow noreferrer">Build a multi-polyphonic synthesiser tutorial</a>.</p>
  
  <p>But when I tried this, I got an overwriting error in the main class.</p>
  
  <p>So here is my problem, how to use the AudioIODeviceCallback, audioDeviceAboutToStart and audioDeviceStopped that are defined in the AudioRecordingDemo class in my project ?</p>
  
  <p>You can find the source code <a href="https://gitlab.com/DamienAuvray/simpleaudiorecorder/" rel="nofollow noreferrer">here</a>. </p>