Mema
Memory Matrix — multi-channel audio matrix monitor and router
Loading...
Searching...
No Matches
AudioSelectComponent.h
Go to the documentation of this file.
1/* Copyright (c) 2024, Christian Ahrens
2 *
3 * This file is part of Mema <https://github.com/ChristianAhrens/Mema>
4 *
5 * This tool is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License version 3.0 as published
7 * by the Free Software Foundation.
8 *
9 * This tool is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this tool; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19#pragma once
20
21#include <JuceHeader.h>
22
23namespace Mema
24{
25
27class AudioSelectComponent : public juce::AudioDeviceSelectorComponent
28{
29public:
32 {
34 {
35 devPtr = nullptr;
38 };
39 RelevantDeviceCharacteristics(juce::AudioIODevice* d)
40 {
41 devPtr = d;
42 if (nullptr != d)
43 {
44 numInputChannels = d->getInputChannelNames().size();
45 numOutputChannels = d->getOutputChannelNames().size();
46 }
47 else
48 {
51 }
52 };
53 RelevantDeviceCharacteristics(juce::AudioIODevice* d, int i, int o)
54 {
55 devPtr = d;
58 };
59
61 {
62 return devPtr == other.devPtr
65 };
67 {
68 return !(*this == other);
69 };
70
71 juce::String toString()
72 {
73 return juce::String::toHexString(std::uint64_t(devPtr)) + juce::String(":") + juce::String(numInputChannels) + juce::String(":") + juce::String(numOutputChannels);
74 }
75
76 juce::AudioIODevice* devPtr;
79 };
80
81public:
82 AudioSelectComponent(juce::AudioDeviceManager *deviceManager,
83 int minAudioInputChannels,
84 int maxAudioInputChannels,
85 int minAudioOutputChannels,
86 int maxAudioOutputChannels,
87 bool showMidiInputOptions,
88 bool showMidiOutputSelector,
89 bool showChannelsAsStereoPairs,
90 bool hideAdvancedOptionsWithButton);
92
93 //==========================================================================
94 void paint (juce::Graphics&) override;
95 void resized() override;
96 void visibilityChanged() override;
97
98 //==========================================================================
100
101protected:
102 //==========================================================================
104
105private:
106 RelevantDeviceCharacteristics m_selectedAudioDeviceWhenSelectionStarted; // only to use to compare if user changed the device at some point!
107
108 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioSelectComponent)
109};
110
111}
std::function< void()> onAudioDeviceChangedDuringAudioSelection
void paint(juce::Graphics &) override
Definition Mema.cpp:27
Snapshot of the currently selected device's relevant characteristics used to detect changes.
bool operator==(const RelevantDeviceCharacteristics &other) const
bool operator!=(const RelevantDeviceCharacteristics &other) const
RelevantDeviceCharacteristics(juce::AudioIODevice *d, int i, int o)