kopia lustrzana https://github.com/jameshball/osci-render
Add mic button to show when audio input is being used, and enable audio input if the audio device is changed
rodzic
04dab15870
commit
a078bd3865
|
@ -24,9 +24,21 @@ SosciPluginEditor::SosciPluginEditor(SosciAudioProcessor& p) : CommonPluginEdito
|
||||||
|
|
||||||
resized();
|
resized();
|
||||||
visualiserFullScreen->addListener(this);
|
visualiserFullScreen->addListener(this);
|
||||||
|
|
||||||
|
if (juce::JUCEApplication::isStandaloneApp()) {
|
||||||
|
juce::StandalonePluginHolder* standalone = juce::StandalonePluginHolder::getInstance();
|
||||||
|
juce::AudioDeviceManager& manager = standalone->deviceManager;
|
||||||
|
manager.addChangeListener(this);
|
||||||
|
currentInputDevice = getInputDeviceName();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SosciPluginEditor::~SosciPluginEditor() {
|
SosciPluginEditor::~SosciPluginEditor() {
|
||||||
|
if (juce::JUCEApplication::isStandaloneApp()) {
|
||||||
|
juce::StandalonePluginHolder* standalone = juce::StandalonePluginHolder::getInstance();
|
||||||
|
juce::AudioDeviceManager& manager = standalone->deviceManager;
|
||||||
|
manager.removeChangeListener(this);
|
||||||
|
}
|
||||||
audioProcessor.visualiserParameters.visualiserFullScreen->removeListener(this);
|
audioProcessor.visualiserParameters.visualiserFullScreen->removeListener(this);
|
||||||
menuBar.setModel(nullptr);
|
menuBar.setModel(nullptr);
|
||||||
}
|
}
|
||||||
|
@ -98,3 +110,28 @@ void SosciPluginEditor::parameterValueChanged(int parameterIndex, float newValue
|
||||||
}
|
}
|
||||||
|
|
||||||
void SosciPluginEditor::parameterGestureChanged(int parameterIndex, bool gestureIsStarting) {}
|
void SosciPluginEditor::parameterGestureChanged(int parameterIndex, bool gestureIsStarting) {}
|
||||||
|
|
||||||
|
void SosciPluginEditor::changeListenerCallback(juce::ChangeBroadcaster* source) {
|
||||||
|
if (juce::JUCEApplication::isStandaloneApp()) {
|
||||||
|
juce::String inputDevice = getInputDeviceName();
|
||||||
|
if (inputDevice != currentInputDevice) {
|
||||||
|
currentInputDevice = inputDevice;
|
||||||
|
// switch to getting audio from input if the user changes the input device
|
||||||
|
// because we assume they are debugging and want to hear the audio from mic
|
||||||
|
audioProcessor.stopAudioFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
juce::String SosciPluginEditor::getInputDeviceName() {
|
||||||
|
if (juce::StandalonePluginHolder::getInstance() == nullptr) {
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
juce::StandalonePluginHolder* standalone = juce::StandalonePluginHolder::getInstance();
|
||||||
|
juce::AudioDeviceManager& manager = standalone->deviceManager;
|
||||||
|
auto device = manager.getCurrentAudioDevice();
|
||||||
|
auto deviceType = manager.getCurrentDeviceTypeObject();
|
||||||
|
int inputIndex = deviceType->getIndexOfDevice(device, true);
|
||||||
|
auto inputName = deviceType->getDeviceNames(true)[inputIndex];
|
||||||
|
return inputName;
|
||||||
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "components/SosciMainMenuBarModel.h"
|
#include "components/SosciMainMenuBarModel.h"
|
||||||
#include "components/SvgButton.h"
|
#include "components/SvgButton.h"
|
||||||
|
|
||||||
class SosciPluginEditor : public CommonPluginEditor, public juce::FileDragAndDropTarget, public juce::AudioProcessorParameter::Listener {
|
class SosciPluginEditor : public CommonPluginEditor, public juce::FileDragAndDropTarget, public juce::AudioProcessorParameter::Listener, public juce::ChangeListener {
|
||||||
public:
|
public:
|
||||||
SosciPluginEditor(SosciAudioProcessor&);
|
SosciPluginEditor(SosciAudioProcessor&);
|
||||||
~SosciPluginEditor() override;
|
~SosciPluginEditor() override;
|
||||||
|
@ -21,10 +21,15 @@ public:
|
||||||
void visualiserFullScreenChanged();
|
void visualiserFullScreenChanged();
|
||||||
void parameterValueChanged(int parameterIndex, float newValue) override;
|
void parameterValueChanged(int parameterIndex, float newValue) override;
|
||||||
void parameterGestureChanged(int parameterIndex, bool gestureIsStarting) override;
|
void parameterGestureChanged(int parameterIndex, bool gestureIsStarting) override;
|
||||||
|
void changeListenerCallback(juce::ChangeBroadcaster* source) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SosciAudioProcessor& audioProcessor;
|
SosciAudioProcessor& audioProcessor;
|
||||||
|
|
||||||
|
juce::String getInputDeviceName();
|
||||||
|
|
||||||
|
juce::String currentInputDevice;
|
||||||
|
|
||||||
ScrollableComponent visualiserSettingsWrapper = ScrollableComponent(visualiserSettings);
|
ScrollableComponent visualiserSettingsWrapper = ScrollableComponent(visualiserSettings);
|
||||||
|
|
||||||
SosciMainMenuBarModel model{*this, audioProcessor};
|
SosciMainMenuBarModel model{*this, audioProcessor};
|
||||||
|
|
|
@ -109,6 +109,9 @@ void AudioPlayerComponent::setPaused(bool paused) {
|
||||||
void AudioPlayerComponent::parserChanged() {
|
void AudioPlayerComponent::parserChanged() {
|
||||||
setup();
|
setup();
|
||||||
repaint();
|
repaint();
|
||||||
|
if (onParserChanged != nullptr) {
|
||||||
|
onParserChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioPlayerComponent::resized() {
|
void AudioPlayerComponent::resized() {
|
||||||
|
|
|
@ -63,6 +63,9 @@ public:
|
||||||
void setup();
|
void setup();
|
||||||
void parserChanged() override;
|
void parserChanged() override;
|
||||||
void setPaused(bool paused);
|
void setPaused(bool paused);
|
||||||
|
bool isInitialised() const { return audioProcessor.wavParser.isInitialised(); }
|
||||||
|
|
||||||
|
std::function<void()> onParserChanged;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CommonAudioProcessor& audioProcessor;
|
CommonAudioProcessor& audioProcessor;
|
||||||
|
|
|
@ -115,8 +115,24 @@ VisualiserComponent::VisualiserComponent(
|
||||||
popoutWindow();
|
popoutWindow();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (visualiserOnly && juce::JUCEApplication::isStandaloneApp()) {
|
||||||
|
addAndMakeVisible(audioInputButton);
|
||||||
|
audioInputButton.setTooltip("Appears red when audio input is being used. Click to enable audio input and close any open audio files.");
|
||||||
|
audioInputButton.setClickingTogglesState(false);
|
||||||
|
audioInputButton.setToggleState(!audioPlayer.isInitialised(), juce::NotificationType::dontSendNotification);
|
||||||
|
audioPlayer.onParserChanged = [this] {
|
||||||
|
juce::MessageManager::callAsync([this] {
|
||||||
|
audioInputButton.setToggleState(!audioPlayer.isInitialised(), juce::NotificationType::dontSendNotification);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
audioInputButton.onClick = [this] {
|
||||||
|
audioProcessor.stopAudioFile();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
addAndMakeVisible(audioPlayer);
|
addAndMakeVisible(audioPlayer);
|
||||||
|
|
||||||
|
|
||||||
openGLContext.setRenderer(this);
|
openGLContext.setRenderer(this);
|
||||||
openGLContext.attachTo(*this);
|
openGLContext.attachTo(*this);
|
||||||
|
|
||||||
|
@ -441,6 +457,9 @@ void VisualiserComponent::resized() {
|
||||||
} else {
|
} else {
|
||||||
settingsButton.setVisible(false);
|
settingsButton.setVisible(false);
|
||||||
}
|
}
|
||||||
|
if (visualiserOnly && juce::JUCEApplication::isStandaloneApp()) {
|
||||||
|
audioInputButton.setBounds(buttons.removeFromRight(30));
|
||||||
|
}
|
||||||
#if SOSCI_FEATURES
|
#if SOSCI_FEATURES
|
||||||
sharedTextureButton.setBounds(buttons.removeFromRight(30));
|
sharedTextureButton.setBounds(buttons.removeFromRight(30));
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -87,6 +87,7 @@ private:
|
||||||
SvgButton fullScreenButton{ "fullScreen", BinaryData::fullscreen_svg, juce::Colours::white, juce::Colours::white };
|
SvgButton fullScreenButton{ "fullScreen", BinaryData::fullscreen_svg, juce::Colours::white, juce::Colours::white };
|
||||||
SvgButton popOutButton{ "popOut", BinaryData::open_in_new_svg, juce::Colours::white, juce::Colours::white };
|
SvgButton popOutButton{ "popOut", BinaryData::open_in_new_svg, juce::Colours::white, juce::Colours::white };
|
||||||
SvgButton settingsButton{ "settings", BinaryData::cog_svg, juce::Colours::white, juce::Colours::white };
|
SvgButton settingsButton{ "settings", BinaryData::cog_svg, juce::Colours::white, juce::Colours::white };
|
||||||
|
SvgButton audioInputButton{ "audioInput", BinaryData::microphone_svg, juce::Colours::white, juce::Colours::red };
|
||||||
|
|
||||||
#if SOSCI_FEATURES
|
#if SOSCI_FEATURES
|
||||||
SvgButton sharedTextureButton{ "sharedTexture", BinaryData::spout_svg, juce::Colours::white, juce::Colours::red };
|
SvgButton sharedTextureButton{ "sharedTexture", BinaryData::spout_svg, juce::Colours::white, juce::Colours::red };
|
||||||
|
|
Ładowanie…
Reference in New Issue