SHARE
TWEET

Untitled

a guest May 20th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class MyAudioCallback : public AudioIODeviceCallback
  2. {
  3. public:
  4.     MyAudioCallback() {}
  5.     void audioDeviceIOCallback(const float **inputChannelData, int numInputChannels,
  6.         float **outputChannelData, int numOutputChannels, int numSamples) override
  7.     {
  8.         for (int i = 0; i < numSamples; ++i)
  9.         {
  10.             float sample = jmap(m_rnd.nextFloat(), 0.0f, 1.0f, -0.1f, 0.1f);
  11.             outputChannelData[0][i] = sample;
  12.             outputChannelData[1][i] = sample;
  13.         }
  14.     }
  15.  
  16.     void audioDeviceAboutToStart(AudioIODevice *device) override
  17.     {
  18.     }
  19.  
  20.     void audioDeviceStopped() override
  21.     {
  22.     }
  23. private:
  24.     Random m_rnd;
  25. };
  26.  
  27. class MainComponent   : public Component
  28. {
  29. public:
  30.     //==============================================================================
  31.     MainComponent()
  32.     {
  33.         m_adman.initialiseWithDefaultDevices(0, 2);
  34.         m_adman.addAudioCallback(&m_acb);
  35.         setSize (600, 400);
  36.     }
  37.     ~MainComponent()
  38.     {
  39.         m_adman.removeAudioCallback(&m_acb);
  40.     }
  41.     void paint (Graphics& g) override
  42.     {
  43.         g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId));
  44.         g.setFont (Font (16.0f));
  45.         g.setColour (Colours::white);
  46.         g.drawText ("Hello World!", getLocalBounds(), Justification::centred, true);
  47.     }
  48.     void resized() override
  49.     {}
  50. private:
  51.     MyAudioCallback m_acb;
  52.     AudioDeviceManager m_adman;
  53.    
  54.     JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent)
  55. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top