I’m having some trouble getting sound. I followed the “White noise Generator” tutorial and generated both a GUI window, and no command line +plus no sound. Anything missing?
//==============================================================================
MainComponent::MainComponent()
{
// Make sure you set the size of the component after
// you add any child components.
setSize (800, 600);
// specify the number of input and output channels that we want to open
setAudioChannels (0, 2);
}
//==============================================================================
void MainComponent::prepareToPlay(int samplesPerBlockExpected, double sampleRate)
{
String message;
message << "Preparing to play audio" << newLine;
message << "Samples per-block expected =" << samplesPerBlockExpected << newLine;
message << "Sample Rate =" << sampleRate;
Logger::getCurrentLogger()->writeToLog(message);
}
void MainComponent::getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill)
{
for (auto channel = 0; channel < bufferToFill.buffer->getNumChannels(); ++channel)
{
auto* buffer = bufferToFill.buffer->getWritePointer(channel, bufferToFill.startSample);
for (auto sample = 0; sample < bufferToFill.numSamples; ++sample)
buffer[sample] = random.nextFloat()* 0.25f - 0.125f;
}
bufferToFill.clearActiveBufferRegion();
}
void MainComponent::releaseResources()
{
// This will be called when the audio device stops, or when it is being
// restarted due to a setting change.
// For more details, see the help for AudioProcessor::releaseResources()
}
//==============================================================================
void MainComponent::paint (Graphics& g)
{
float x = 60;
float y = 50;
float h = 30;
float w = 50;
float c = 40;
float T = 30;
g.fillAll(Colours::brown); // clear the background
g.setColour(Colours::cornflowerblue);
g.Graphics::drawRoundedRectangle(x, y, h, w, c, T); // draw an outline around the component
g.setFont(50.0f);
g.drawText("GUI IS STILL UGLY", getLocalBounds(),
Justification::centred, true);
}
MainComponent::~MainComponent()
{
shutdownAudio();
};
void MainComponent::resized()
{
// This is called when the MainContentComponent is resized.
// If you add any child components, this is where you should
// update their positions.
}