- clean working copy for leaving SVN

This commit is contained in:
2022-06-28 19:04:46 +02:00
parent 62a2d47cb3
commit 762b8f0e7d
1966 changed files with 699872 additions and 126 deletions
@@ -0,0 +1,101 @@
/*
==============================================================================
This file was auto-generated by the Introjucer!
It contains the basic startup code for a Juce application.
==============================================================================
*/
#include "../JuceLibraryCode/JuceHeader.h"
Component* createMainContentComponent();
//==============================================================================
class AudioAppExampleApplication : public JUCEApplication
{
public:
//==============================================================================
AudioAppExampleApplication() {}
const String getApplicationName() override { return ProjectInfo::projectName; }
const String getApplicationVersion() override { return ProjectInfo::versionString; }
bool moreThanOneInstanceAllowed() override { return true; }
//==============================================================================
void initialise (const String& /*commandLine*/) override
{
// This method is where you should put your application's initialisation code..
mainWindow = new MainWindow (getApplicationName());
}
void shutdown() override
{
// Add your application's shutdown code here..
mainWindow = nullptr; // (deletes our window)
}
//==============================================================================
void systemRequestedQuit() override
{
// This is called when the app is being asked to quit: you can ignore this
// request and let the app carry on running, or call quit() to allow the app to close.
quit();
}
void anotherInstanceStarted (const String& /*commandLine*/) override
{
// When another instance of the app is launched while this one is running,
// this method is invoked, and the commandLine parameter tells you what
// the other instance's command-line arguments were.
}
//==============================================================================
/*
This class implements the desktop window that contains an instance of
our MainContentComponent class.
*/
class MainWindow : public DocumentWindow
{
public:
MainWindow (String name) : DocumentWindow (name,
Colours::lightgrey,
DocumentWindow::allButtons)
{
setUsingNativeTitleBar (true);
setContentOwned (createMainContentComponent(), true);
setResizable (true, true);
centreWithSize (getWidth(), getHeight());
setVisible (true);
}
void closeButtonPressed() override
{
// This is called when the user tries to close this window. Here, we'll just
// ask the app to quit when this happens, but you can change this to do
// whatever you need.
JUCEApplication::getInstance()->systemRequestedQuit();
}
/* Note: Be careful if you override any DocumentWindow methods - the base
class uses a lot of them, so by overriding you might break its functionality.
It's best to do all your work in your content component instead, but if
you really have to override any DocumentWindow methods, make sure your
subclass also calls the superclass's method.
*/
private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainWindow)
};
private:
ScopedPointer<MainWindow> mainWindow;
};
//==============================================================================
// This macro generates the main() routine that launches the app.
START_JUCE_APPLICATION (AudioAppExampleApplication)
@@ -0,0 +1,154 @@
/*
==============================================================================
This file was auto-generated!
==============================================================================
*/
#ifndef MAINCOMPONENT_H_INCLUDED
#define MAINCOMPONENT_H_INCLUDED
#include "../JuceLibraryCode/JuceHeader.h"
//==============================================================================
class MainContentComponent : public AudioAppComponent
{
public:
//==============================================================================
MainContentComponent()
: phase (0.0f),
phaseDelta (0.0f),
frequency (5000.0f),
amplitude (0.2f),
sampleRate (0.0),
expectedSamplesPerBlock (0)
{
setSize (800, 600);
// specify the number of input and output channels that we want to open
setAudioChannels (2, 2);
}
~MainContentComponent()
{
shutdownAudio();
}
//=======================================================================
void prepareToPlay (int samplesPerBlockExpected, double newSampleRate) override
{
sampleRate = newSampleRate;
expectedSamplesPerBlock = samplesPerBlockExpected;
}
/* This method generates the actual audio samples.
In this example the buffer is filled with a sine wave whose frequency and
amplitude are controlled by the mouse position.
*/
void getNextAudioBlock (const AudioSourceChannelInfo& bufferToFill) override
{
bufferToFill.clearActiveBufferRegion();
const float originalPhase = phase;
for (int chan = 0; chan < bufferToFill.buffer->getNumChannels(); ++chan)
{
phase = originalPhase;
float* const channelData = bufferToFill.buffer->getWritePointer (chan, bufferToFill.startSample);
for (int i = 0; i < bufferToFill.numSamples ; ++i)
{
channelData[i] = amplitude * std::sin (phase);
// increment the phase step for the next sample
phase = std::fmod (phase + phaseDelta, float_Pi * 2.0f);
}
}
}
void releaseResources() override
{
// This gets automatically called when audio device paramters change
// or device is restarted.
}
//=======================================================================
void paint (Graphics& g) override
{
// (Our component is opaque, so we must completely fill the background with a solid colour)
g.fillAll (Colours::black);
const float centreY = getHeight() / 2.0f;
const float radius = amplitude * 200.0f;
// Draw an ellipse based on the mouse position and audio volume
g.setColour (Colours::lightgreen);
g.fillEllipse (lastMousePosition.x - radius / 2.0f,
lastMousePosition.y - radius / 2.0f,
radius, radius);
// draw a representative sinewave
Path wavePath;
wavePath.startNewSubPath (0, centreY);
for (float x = 1.0f; x < getWidth(); ++x)
wavePath.lineTo (x, centreY + amplitude * getHeight() * 2.0f
* std::sin (x * frequency * 0.0001f));
g.setColour (Colours::grey);
g.strokePath (wavePath, PathStrokeType (2.0f));
}
// Mouse handling..
void mouseDown (const MouseEvent& e) override
{
mouseDrag (e);
}
void mouseDrag (const MouseEvent& e) override
{
lastMousePosition = e.position;
frequency = (getHeight() - e.y) * 10.0f;
amplitude = jmin (0.9f, 0.2f * e.position.x / getWidth());
phaseDelta = 2.0f * float_Pi * frequency / sampleRate;
repaint();
}
void mouseUp (const MouseEvent&) override
{
amplitude = 0.0f;
repaint();
}
void resized() override
{
// This is called when the MainContentComponent is resized.
// If you add any child components, this is where you should
// update their positions.
}
private:
//==============================================================================
float phase;
float phaseDelta;
float frequency;
float amplitude;
double sampleRate;
int expectedSamplesPerBlock;
Point<float> lastMousePosition;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainContentComponent)
};
Component* createMainContentComponent() { return new MainContentComponent(); };
#endif // MAINCOMPONENT_H_INCLUDED