git subrepo clone --branch=sono6good https://github.com/essej/JUCE.git deps/juce
subrepo: subdir: "deps/juce" merged: "b13f9084e" upstream: origin: "https://github.com/essej/JUCE.git" branch: "sono6good" commit: "b13f9084e" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596"
This commit is contained in:
123
deps/juce/examples/DemoRunner/Source/Demos/DemoPIPs1.cpp
vendored
Normal file
123
deps/juce/examples/DemoRunner/Source/Demos/DemoPIPs1.cpp
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2020 - Raw Material Software Limited
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
By using JUCE, you agree to the terms of both the JUCE 6 End-User License
|
||||
Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
|
||||
|
||||
End User License Agreement: www.juce.com/juce-6-licence
|
||||
Privacy Policy: www.juce.com/juce-privacy-policy
|
||||
|
||||
Or: You may also use this code under the terms of the GPL v3 (see
|
||||
www.gnu.org/licenses).
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#include <JuceHeader.h>
|
||||
#include "../../../Assets/DemoUtilities.h"
|
||||
#include "JUCEDemos.h"
|
||||
|
||||
#include "../../../Assets/AudioLiveScrollingDisplay.h"
|
||||
|
||||
//==============================================================================
|
||||
#include "IntroScreen.h"
|
||||
#include "../../../Audio/AudioAppDemo.h"
|
||||
#include "../../../Audio/AudioLatencyDemo.h"
|
||||
#include "../../../Audio/AudioPlaybackDemo.h"
|
||||
#include "../../../Audio/AudioRecordingDemo.h"
|
||||
#include "../../../Audio/AudioSettingsDemo.h"
|
||||
#include "../../../Audio/AudioSynthesiserDemo.h"
|
||||
#include "../../../Audio/MidiDemo.h"
|
||||
#include "../../../Audio/MPEDemo.h"
|
||||
#include "../../../Audio/PluckedStringsDemo.h"
|
||||
#include "../../../Audio/SimpleFFTDemo.h"
|
||||
|
||||
#include "../../../DSP/ConvolutionDemo.h"
|
||||
#include "../../../DSP/FIRFilterDemo.h"
|
||||
#include "../../../DSP/GainDemo.h"
|
||||
#include "../../../DSP/IIRFilterDemo.h"
|
||||
#include "../../../DSP/OscillatorDemo.h"
|
||||
#include "../../../DSP/OverdriveDemo.h"
|
||||
#if JUCE_USE_SIMD
|
||||
#include "../../../DSP/SIMDRegisterDemo.h"
|
||||
#endif
|
||||
#include "../../../DSP/StateVariableFilterDemo.h"
|
||||
#include "../../../DSP/WaveShaperTanhDemo.h"
|
||||
|
||||
#include "../../../Utilities/Box2DDemo.h"
|
||||
#if JUCE_MAC || JUCE_WINDOWS || JUCE_LINUX || JUCE_BSD
|
||||
#include "../../../Utilities/ChildProcessDemo.h"
|
||||
#endif
|
||||
#include "../../../Utilities/CryptographyDemo.h"
|
||||
#include "../../../Utilities/JavaScriptDemo.h"
|
||||
#include "../../../Utilities/LiveConstantDemo.h"
|
||||
#include "../../../Utilities/MultithreadingDemo.h"
|
||||
#include "../../../Utilities/NetworkingDemo.h"
|
||||
#include "../../../Utilities/OSCDemo.h"
|
||||
#include "../../../Utilities/SystemInfoDemo.h"
|
||||
#include "../../../Utilities/TimersAndEventsDemo.h"
|
||||
#include "../../../Utilities/UnitTestsDemo.h"
|
||||
#include "../../../Utilities/ValueTreesDemo.h"
|
||||
#include "../../../Utilities/XMLandJSONDemo.h"
|
||||
|
||||
void registerDemos_One() noexcept
|
||||
{
|
||||
REGISTER_DEMO (AudioAppDemo, Audio, false)
|
||||
REGISTER_DEMO (AudioLatencyDemo, Audio, false)
|
||||
REGISTER_DEMO (AudioPlaybackDemo, Audio, false)
|
||||
REGISTER_DEMO (AudioRecordingDemo, Audio, false)
|
||||
REGISTER_DEMO (AudioSettingsDemo, Audio, false)
|
||||
REGISTER_DEMO (AudioSynthesiserDemo, Audio, false)
|
||||
REGISTER_DEMO (MidiDemo, Audio, false)
|
||||
REGISTER_DEMO (MPEDemo, Audio, false)
|
||||
REGISTER_DEMO (PluckedStringsDemo, Audio, false)
|
||||
REGISTER_DEMO (SimpleFFTDemo, Audio, false)
|
||||
|
||||
REGISTER_DEMO (ConvolutionDemo, DSP, false)
|
||||
REGISTER_DEMO (FIRFilterDemo, DSP, false)
|
||||
REGISTER_DEMO (GainDemo, DSP, false)
|
||||
REGISTER_DEMO (IIRFilterDemo, DSP, false)
|
||||
REGISTER_DEMO (OscillatorDemo, DSP, false)
|
||||
REGISTER_DEMO (OverdriveDemo, DSP, false)
|
||||
#if JUCE_USE_SIMD
|
||||
REGISTER_DEMO (SIMDRegisterDemo, DSP, false)
|
||||
#endif
|
||||
REGISTER_DEMO (StateVariableFilterDemo, DSP, false)
|
||||
REGISTER_DEMO (WaveShaperTanhDemo, DSP, false)
|
||||
|
||||
REGISTER_DEMO (Box2DDemo, Utilities, false)
|
||||
#if JUCE_MAC || JUCE_WINDOWS || JUCE_LINUX || JUCE_BSD
|
||||
REGISTER_DEMO (ChildProcessDemo, Utilities, false)
|
||||
#endif
|
||||
REGISTER_DEMO (CryptographyDemo, Utilities, false)
|
||||
REGISTER_DEMO (JavaScriptDemo, Utilities, false)
|
||||
REGISTER_DEMO (LiveConstantDemo, Utilities, false)
|
||||
REGISTER_DEMO (MultithreadingDemo, Utilities, false)
|
||||
REGISTER_DEMO (NetworkingDemo, Utilities, false)
|
||||
REGISTER_DEMO (OSCDemo, Utilities, false)
|
||||
REGISTER_DEMO (SystemInfoDemo, Utilities, false)
|
||||
REGISTER_DEMO (TimersAndEventsDemo, Utilities, false)
|
||||
REGISTER_DEMO (UnitTestsDemo, Utilities, false)
|
||||
REGISTER_DEMO (ValueTreesDemo, Utilities, false)
|
||||
REGISTER_DEMO (XMLandJSONDemo, Utilities, false)
|
||||
}
|
||||
|
||||
Component* createIntroDemo()
|
||||
{
|
||||
return new IntroScreen();
|
||||
}
|
||||
|
||||
bool isComponentIntroDemo (Component* comp) noexcept
|
||||
{
|
||||
return (dynamic_cast<IntroScreen*> (comp) != nullptr);
|
||||
}
|
120
deps/juce/examples/DemoRunner/Source/Demos/DemoPIPs2.cpp
vendored
Normal file
120
deps/juce/examples/DemoRunner/Source/Demos/DemoPIPs2.cpp
vendored
Normal file
@ -0,0 +1,120 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2020 - Raw Material Software Limited
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
By using JUCE, you agree to the terms of both the JUCE 6 End-User License
|
||||
Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
|
||||
|
||||
End User License Agreement: www.juce.com/juce-6-licence
|
||||
Privacy Policy: www.juce.com/juce-privacy-policy
|
||||
|
||||
Or: You may also use this code under the terms of the GPL v3 (see
|
||||
www.gnu.org/licenses).
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#include <JuceHeader.h>
|
||||
#include "../../../Assets/DemoUtilities.h"
|
||||
#include "JUCEDemos.h"
|
||||
|
||||
#include "../../../Assets/AudioLiveScrollingDisplay.h"
|
||||
|
||||
//==============================================================================
|
||||
#if JUCE_MAC || JUCE_WINDOWS
|
||||
#include "../../../GUI/AccessibilityDemo.h"
|
||||
#endif
|
||||
#include "../../../GUI/AnimationAppDemo.h"
|
||||
#include "../../../GUI/AnimationDemo.h"
|
||||
#include "../../../GUI/BouncingBallWavetableDemo.h"
|
||||
#if JUCE_USE_CAMERA && ! (JUCE_LINUX || JUCE_BSD)
|
||||
#include "../../../GUI/CameraDemo.h"
|
||||
#endif
|
||||
#if ! JUCE_ANDROID
|
||||
#include "../../../GUI/CodeEditorDemo.h"
|
||||
#endif
|
||||
#include "../../../GUI/ComponentDemo.h"
|
||||
#include "../../../GUI/ComponentTransformsDemo.h"
|
||||
#include "../../../GUI/DialogsDemo.h"
|
||||
#include "../../../GUI/FlexBoxDemo.h"
|
||||
#include "../../../GUI/FontsDemo.h"
|
||||
#include "../../../GUI/GraphicsDemo.h"
|
||||
#include "../../../GUI/GridDemo.h"
|
||||
#include "../../../GUI/ImagesDemo.h"
|
||||
#include "../../../GUI/KeyMappingsDemo.h"
|
||||
#include "../../../GUI/LookAndFeelDemo.h"
|
||||
#include "../../../GUI/MDIDemo.h"
|
||||
#include "../../../GUI/MenusDemo.h"
|
||||
#include "../../../GUI/MultiTouchDemo.h"
|
||||
#if JUCE_OPENGL
|
||||
#include "../../../GUI/OpenGLAppDemo.h"
|
||||
#include "../../../GUI/OpenGLDemo.h"
|
||||
#include "../../../GUI/OpenGLDemo2D.h"
|
||||
#endif
|
||||
#include "../../../GUI/PropertiesDemo.h"
|
||||
#if ! (JUCE_LINUX || JUCE_BSD)
|
||||
#include "../../../GUI/VideoDemo.h"
|
||||
#endif
|
||||
#include "../../../GUI/WebBrowserDemo.h"
|
||||
#include "../../../GUI/WidgetsDemo.h"
|
||||
#include "../../../GUI/WindowsDemo.h"
|
||||
|
||||
void registerDemos_Two() noexcept
|
||||
{
|
||||
#if JUCE_MAC || JUCE_WINDOWS
|
||||
REGISTER_DEMO (AccessibilityDemo, GUI, false)
|
||||
#endif
|
||||
REGISTER_DEMO (AnimationAppDemo, GUI, false)
|
||||
REGISTER_DEMO (AnimationDemo, GUI, false)
|
||||
REGISTER_DEMO (BouncingBallWavetableDemo, GUI, false)
|
||||
#if JUCE_USE_CAMERA && ! (JUCE_LINUX || JUCE_BSD)
|
||||
REGISTER_DEMO (CameraDemo, GUI, true)
|
||||
#endif
|
||||
#if ! JUCE_ANDROID
|
||||
REGISTER_DEMO (CodeEditorDemo, GUI, false)
|
||||
#endif
|
||||
REGISTER_DEMO (ComponentDemo, GUI, false)
|
||||
REGISTER_DEMO (ComponentTransformsDemo, GUI, false)
|
||||
REGISTER_DEMO (DialogsDemo, GUI, false)
|
||||
REGISTER_DEMO (FlexBoxDemo, GUI, false)
|
||||
REGISTER_DEMO (FontsDemo, GUI, false)
|
||||
REGISTER_DEMO (GraphicsDemo, GUI, false)
|
||||
REGISTER_DEMO (GridDemo, GUI, false)
|
||||
REGISTER_DEMO (ImagesDemo, GUI, false)
|
||||
REGISTER_DEMO (KeyMappingsDemo, GUI, false)
|
||||
REGISTER_DEMO (LookAndFeelDemo, GUI, false)
|
||||
REGISTER_DEMO (MDIDemo, GUI, false)
|
||||
REGISTER_DEMO (MenusDemo, GUI, false)
|
||||
REGISTER_DEMO (MultiTouchDemo, GUI, false)
|
||||
#if JUCE_OPENGL
|
||||
REGISTER_DEMO (OpenGLAppDemo, GUI, true)
|
||||
REGISTER_DEMO (OpenGLDemo2D, GUI, true)
|
||||
REGISTER_DEMO (OpenGLDemo, GUI, true)
|
||||
#endif
|
||||
REGISTER_DEMO (PropertiesDemo, GUI, false)
|
||||
#if ! (JUCE_LINUX || JUCE_BSD)
|
||||
REGISTER_DEMO (VideoDemo, GUI, true)
|
||||
#endif
|
||||
REGISTER_DEMO (WebBrowserDemo, GUI, true)
|
||||
REGISTER_DEMO (WidgetsDemo, GUI, false)
|
||||
REGISTER_DEMO (WindowsDemo, GUI, false)
|
||||
}
|
||||
|
||||
CodeEditorComponent::ColourScheme getDarkColourScheme()
|
||||
{
|
||||
return getDarkCodeEditorColourScheme();
|
||||
}
|
||||
|
||||
CodeEditorComponent::ColourScheme getLightColourScheme()
|
||||
{
|
||||
return getLightCodeEditorColourScheme();
|
||||
}
|
129
deps/juce/examples/DemoRunner/Source/Demos/IntroScreen.h
vendored
Normal file
129
deps/juce/examples/DemoRunner/Source/Demos/IntroScreen.h
vendored
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2020 - Raw Material Software Limited
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
By using JUCE, you agree to the terms of both the JUCE 6 End-User License
|
||||
Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
|
||||
|
||||
End User License Agreement: www.juce.com/juce-6-licence
|
||||
Privacy Policy: www.juce.com/juce-privacy-policy
|
||||
|
||||
Or: You may also use this code under the terms of the GPL v3 (see
|
||||
www.gnu.org/licenses).
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
//==============================================================================
|
||||
class IntroScreen : public Component
|
||||
{
|
||||
public:
|
||||
IntroScreen()
|
||||
{
|
||||
setOpaque (true);
|
||||
|
||||
addAndMakeVisible (versionLabel);
|
||||
addAndMakeVisible (linkButton);
|
||||
addAndMakeVisible (logo);
|
||||
|
||||
versionLabel.setText (String ("{version} built on {date}")
|
||||
.replace ("{version}", SystemStats::getJUCEVersion())
|
||||
.replace ("{date}", String (__DATE__).replace (" ", " ")),
|
||||
dontSendNotification);
|
||||
|
||||
linkButton.setColour (HyperlinkButton::textColourId, Colours::lightblue);
|
||||
|
||||
setTitle ("Home");
|
||||
setFocusContainerType (FocusContainerType::focusContainer);
|
||||
}
|
||||
|
||||
void paint (Graphics& g) override
|
||||
{
|
||||
g.fillAll (getUIColourIfAvailable (LookAndFeel_V4::ColourScheme::UIColour::windowBackground));
|
||||
}
|
||||
|
||||
void resized() override
|
||||
{
|
||||
auto area = getLocalBounds().reduced (10);
|
||||
|
||||
auto bottomSlice = area.removeFromBottom (24);
|
||||
linkButton.setBounds (bottomSlice.removeFromRight (getWidth() / 4));
|
||||
versionLabel.setBounds (bottomSlice);
|
||||
|
||||
logo.setBounds (area);
|
||||
}
|
||||
|
||||
private:
|
||||
Label versionLabel;
|
||||
HyperlinkButton linkButton { "www.juce.com", { "http://www.juce.com" } };
|
||||
|
||||
//==============================================================================
|
||||
struct LogoDrawComponent : public Component,
|
||||
private Timer
|
||||
{
|
||||
LogoDrawComponent()
|
||||
{
|
||||
setTitle ("JUCE Logo");
|
||||
startTimerHz (30); // repaint at 30 fps
|
||||
}
|
||||
|
||||
void paint (Graphics& g) override
|
||||
{
|
||||
Path wavePath;
|
||||
|
||||
auto waveStep = 10.0f;
|
||||
auto waveY = (float) getHeight() * 0.5f;
|
||||
int i = 0;
|
||||
|
||||
for (auto x = waveStep * 0.5f; x < (float) getWidth(); x += waveStep)
|
||||
{
|
||||
auto y1 = waveY + (float) getHeight() * 0.05f * std::sin ((float) i * 0.38f + elapsed);
|
||||
auto y2 = waveY + (float) getHeight() * 0.10f * std::sin ((float) i * 0.20f + elapsed * 2.0f);
|
||||
|
||||
wavePath.addLineSegment ({ x, y1, x, y2 }, 2.0f);
|
||||
wavePath.addEllipse (x - waveStep * 0.3f, y1 - waveStep * 0.3f, waveStep * 0.6f, waveStep * 0.6f);
|
||||
wavePath.addEllipse (x - waveStep * 0.3f, y2 - waveStep * 0.3f, waveStep * 0.6f, waveStep * 0.6f);
|
||||
|
||||
++i;
|
||||
}
|
||||
|
||||
g.setColour (Colour::greyLevel (0.4f));
|
||||
g.fillPath (wavePath);
|
||||
|
||||
g.setColour (Colour (0xc4f39082));
|
||||
g.fillPath (logoPath, RectanglePlacement (RectanglePlacement::centred)
|
||||
.getTransformToFit (logoPath.getBounds(),
|
||||
getLocalBounds().reduced (20, getHeight() / 4).toFloat()));
|
||||
}
|
||||
|
||||
void timerCallback() override
|
||||
{
|
||||
repaint();
|
||||
elapsed += 0.02f;
|
||||
}
|
||||
|
||||
std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override
|
||||
{
|
||||
return std::make_unique<AccessibilityHandler> (*this, AccessibilityRole::image);
|
||||
}
|
||||
|
||||
Path logoPath { getJUCELogoPath() };
|
||||
float elapsed = 0.0f;
|
||||
};
|
||||
|
||||
LogoDrawComponent logo;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (IntroScreen)
|
||||
};
|
176
deps/juce/examples/DemoRunner/Source/Demos/JUCEDemos.cpp
vendored
Normal file
176
deps/juce/examples/DemoRunner/Source/Demos/JUCEDemos.cpp
vendored
Normal file
@ -0,0 +1,176 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2020 - Raw Material Software Limited
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
By using JUCE, you agree to the terms of both the JUCE 6 End-User License
|
||||
Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
|
||||
|
||||
End User License Agreement: www.juce.com/juce-6-licence
|
||||
Privacy Policy: www.juce.com/juce-privacy-policy
|
||||
|
||||
Or: You may also use this code under the terms of the GPL v3 (see
|
||||
www.gnu.org/licenses).
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#include <JuceHeader.h>
|
||||
#include "../../../Assets/DemoUtilities.h"
|
||||
#include "JUCEDemos.h"
|
||||
|
||||
//==============================================================================
|
||||
std::vector<JUCEDemos::DemoCategory>& JUCEDemos::getCategories()
|
||||
{
|
||||
static std::vector<DemoCategory> categories;
|
||||
return categories;
|
||||
}
|
||||
|
||||
JUCEDemos::DemoCategory& JUCEDemos::getCategory (const String& name)
|
||||
{
|
||||
auto& categories = getCategories();
|
||||
|
||||
for (auto& c : categories)
|
||||
if (c.name == name)
|
||||
return c;
|
||||
|
||||
std::vector<FileAndCallback> fc;
|
||||
categories.push_back ({ name, fc });
|
||||
|
||||
return categories.back();
|
||||
}
|
||||
|
||||
void JUCEDemos::registerDemo (std::function<Component*()> constructorCallback, const String& filePath, const String& category, bool isHeavyweight)
|
||||
{
|
||||
#if JUCE_MAC
|
||||
auto f = File::getSpecialLocation (File::currentExecutableFile)
|
||||
.getParentDirectory().getParentDirectory().getChildFile ("Resources");
|
||||
#else
|
||||
auto f = findExamplesDirectoryFromExecutable (File::getSpecialLocation (File::currentApplicationFile));
|
||||
#endif
|
||||
|
||||
#if ! (JUCE_ANDROID || JUCE_IOS)
|
||||
if (f == File())
|
||||
{
|
||||
jassertfalse;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
getCategory (category).demos.push_back ({ f.getChildFile (filePath), constructorCallback, isHeavyweight });
|
||||
}
|
||||
|
||||
File JUCEDemos::findExamplesDirectoryFromExecutable (File exec)
|
||||
{
|
||||
int numTries = 15;
|
||||
auto exampleDir = exec.getParentDirectory().getChildFile ("examples");
|
||||
|
||||
if (exampleDir.exists())
|
||||
return exampleDir;
|
||||
|
||||
while (exec.getFileName() != "examples" && numTries-- > 0)
|
||||
exec = exec.getParentDirectory();
|
||||
if (exec.getFileName() == "examples")
|
||||
return exec;
|
||||
return {};
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static String getCurrentDefaultAudioDeviceName (AudioDeviceManager& deviceManager, bool isInput)
|
||||
{
|
||||
auto* deviceType = deviceManager.getCurrentDeviceTypeObject();
|
||||
jassert (deviceType != nullptr);
|
||||
|
||||
if (deviceType != nullptr)
|
||||
{
|
||||
auto deviceNames = deviceType->getDeviceNames();
|
||||
return deviceNames [deviceType->getDefaultDeviceIndex (isInput)];
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
// (returns a shared AudioDeviceManager object that all the demos can use)
|
||||
AudioDeviceManager& getSharedAudioDeviceManager (int numInputChannels, int numOutputChannels)
|
||||
{
|
||||
if (sharedAudioDeviceManager == nullptr)
|
||||
sharedAudioDeviceManager.reset (new AudioDeviceManager());
|
||||
|
||||
auto* currentDevice = sharedAudioDeviceManager->getCurrentAudioDevice();
|
||||
|
||||
if (numInputChannels < 0)
|
||||
numInputChannels = (currentDevice != nullptr ? currentDevice->getActiveInputChannels().countNumberOfSetBits() : 1);
|
||||
|
||||
if (numOutputChannels < 0)
|
||||
numOutputChannels = (currentDevice != nullptr ? currentDevice->getActiveOutputChannels().countNumberOfSetBits() : 2);
|
||||
|
||||
if (numInputChannels > 0 && ! RuntimePermissions::isGranted (RuntimePermissions::recordAudio))
|
||||
{
|
||||
RuntimePermissions::request (RuntimePermissions::recordAudio,
|
||||
[numInputChannels, numOutputChannels] (bool granted)
|
||||
{
|
||||
if (granted)
|
||||
getSharedAudioDeviceManager (numInputChannels, numOutputChannels);
|
||||
});
|
||||
|
||||
numInputChannels = 0;
|
||||
}
|
||||
|
||||
if (sharedAudioDeviceManager->getCurrentAudioDevice() != nullptr)
|
||||
{
|
||||
auto setup = sharedAudioDeviceManager->getAudioDeviceSetup();
|
||||
|
||||
auto numInputs = jmax (numInputChannels, setup.inputChannels.countNumberOfSetBits());
|
||||
auto numOutputs = jmax (numOutputChannels, setup.outputChannels.countNumberOfSetBits());
|
||||
|
||||
auto oldInputs = setup.inputChannels.countNumberOfSetBits();
|
||||
auto oldOutputs = setup.outputChannels.countNumberOfSetBits();
|
||||
|
||||
if (oldInputs != numInputs || oldOutputs != numOutputs)
|
||||
{
|
||||
if (oldInputs == 0 && oldOutputs == 0)
|
||||
{
|
||||
sharedAudioDeviceManager->initialise (numInputChannels, numOutputChannels, nullptr, true, {}, nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
setup.useDefaultInputChannels = setup.useDefaultOutputChannels = false;
|
||||
|
||||
setup.inputChannels.clear();
|
||||
setup.outputChannels.clear();
|
||||
|
||||
setup.inputChannels.setRange (0, numInputs, true);
|
||||
setup.outputChannels.setRange (0, numOutputs, true);
|
||||
|
||||
if (oldInputs == 0 && numInputs > 0 && setup.inputDeviceName.isEmpty())
|
||||
setup.inputDeviceName = getCurrentDefaultAudioDeviceName (*sharedAudioDeviceManager, true);
|
||||
|
||||
if (oldOutputs == 0 && numOutputs > 0 && setup.outputDeviceName.isEmpty())
|
||||
setup.outputDeviceName = getCurrentDefaultAudioDeviceName (*sharedAudioDeviceManager, false);
|
||||
|
||||
sharedAudioDeviceManager->setAudioDeviceSetup (setup, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sharedAudioDeviceManager->initialise (numInputChannels, numOutputChannels, nullptr, true, {}, nullptr);
|
||||
}
|
||||
|
||||
return *sharedAudioDeviceManager;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void registerAllDemos() noexcept
|
||||
{
|
||||
registerDemos_One();
|
||||
registerDemos_Two();
|
||||
}
|
78
deps/juce/examples/DemoRunner/Source/Demos/JUCEDemos.h
vendored
Normal file
78
deps/juce/examples/DemoRunner/Source/Demos/JUCEDemos.h
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
This file is part of the JUCE library.
|
||||
Copyright (c) 2020 - Raw Material Software Limited
|
||||
|
||||
JUCE is an open source library subject to commercial or open-source
|
||||
licensing.
|
||||
|
||||
By using JUCE, you agree to the terms of both the JUCE 6 End-User License
|
||||
Agreement and JUCE Privacy Policy (both effective as of the 16th June 2020).
|
||||
|
||||
End User License Agreement: www.juce.com/juce-6-licence
|
||||
Privacy Policy: www.juce.com/juce-privacy-policy
|
||||
|
||||
Or: You may also use this code under the terms of the GPL v3 (see
|
||||
www.gnu.org/licenses).
|
||||
|
||||
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
|
||||
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
|
||||
DISCLAIMED.
|
||||
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
//==============================================================================
|
||||
#define FILE_EXT .h
|
||||
|
||||
#define EXPAND(x) x
|
||||
#define CREATE_FILEPATH(DemoName, category) JUCE_STRINGIFY(EXPAND(category)/EXPAND(DemoName)EXPAND(FILE_EXT))
|
||||
|
||||
#define REGISTER_DEMO(DemoName, category, heavyweight) JUCEDemos::registerDemo ([] { return new DemoName(); }, CREATE_FILEPATH(DemoName, category), JUCE_STRINGIFY (category), heavyweight);
|
||||
|
||||
//==============================================================================
|
||||
struct JUCEDemos
|
||||
{
|
||||
struct FileAndCallback
|
||||
{
|
||||
File demoFile;
|
||||
std::function<Component*()> callback;
|
||||
bool isHeavyweight;
|
||||
};
|
||||
|
||||
struct DemoCategory
|
||||
{
|
||||
String name;
|
||||
std::vector<FileAndCallback> demos;
|
||||
};
|
||||
|
||||
static std::vector<DemoCategory>& getCategories();
|
||||
static DemoCategory& getCategory (const String& name);
|
||||
|
||||
static void registerDemo (std::function<Component*()> constructorCallback, const String& filePath, const String& category, bool isHeavyweight);
|
||||
static File findExamplesDirectoryFromExecutable (File exec);
|
||||
};
|
||||
|
||||
void registerDemos_One() noexcept;
|
||||
void registerDemos_Two() noexcept;
|
||||
|
||||
//==============================================================================
|
||||
// used by child-process demo
|
||||
bool invokeChildProcessDemo (const String& commandLine);
|
||||
void registerAllDemos() noexcept;
|
||||
|
||||
Component* createIntroDemo();
|
||||
bool isComponentIntroDemo (Component*) noexcept;
|
||||
|
||||
CodeEditorComponent::ColourScheme getDarkColourScheme();
|
||||
CodeEditorComponent::ColourScheme getLightColourScheme();
|
||||
|
||||
//==============================================================================
|
||||
extern std::unique_ptr<AudioDeviceManager> sharedAudioDeviceManager;
|
||||
|
||||
AudioDeviceManager& getSharedAudioDeviceManager (int numInputChannels = -1, int numOutputChannels = -1);
|
||||
ApplicationCommandManager& getGlobalCommandManager();
|
Reference in New Issue
Block a user