Last active
May 10, 2019 13:11
-
-
Save Xenakios/d8ccb28b45aaafb211213b13ebf3ae97 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyAudioCallback : public AudioIODeviceCallback | |
{ | |
public: | |
MyAudioCallback() {} | |
void audioDeviceIOCallback(const float **inputChannelData, int numInputChannels, | |
float **outputChannelData, int numOutputChannels, int numSamples) override | |
{ | |
for (int i = 0; i < numSamples; ++i) | |
{ | |
float sample = jmap(m_rnd.nextFloat(), 0.0f, 1.0f, -0.1f, 0.1f); | |
outputChannelData[0][i] = sample; | |
outputChannelData[1][i] = sample; | |
} | |
} | |
void audioDeviceAboutToStart(AudioIODevice *device) override | |
{ | |
} | |
void audioDeviceStopped() override | |
{ | |
} | |
private: | |
Random m_rnd; | |
}; | |
class MainComponent : public Component | |
{ | |
public: | |
//============================================================================== | |
MainComponent() | |
{ | |
m_adman.initialiseWithDefaultDevices(0, 2); | |
m_adman.addAudioCallback(&m_acb); | |
setSize (600, 400); | |
} | |
~MainComponent() | |
{ | |
m_adman.removeAudioCallback(&m_acb); | |
} | |
void paint (Graphics& g) override | |
{ | |
g.fillAll (getLookAndFeel().findColour (ResizableWindow::backgroundColourId)); | |
g.setFont (Font (16.0f)); | |
g.setColour (Colours::white); | |
g.drawText ("Hello World!", getLocalBounds(), Justification::centred, true); | |
} | |
void resized() override | |
{} | |
private: | |
MyAudioCallback m_acb; | |
AudioDeviceManager m_adman; | |
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment