33 void initialise (
int defaultNumInputChannelsToOpen = 512,
34 int defaultNumOutputChannelsToOpen = 512);
38 void resetToDefaults (
bool deviceSettings,
39 bool resetInputDevices,
40 bool resetOutputDevices,
44 void rescanMidiDeviceList();
45 void rescanWaveDeviceList();
47 int getMidiDeviceScanIntervalSeconds()
const {
return midiRescanIntervalSeconds; }
48 void setMidiDeviceScanIntervalSeconds (
int intervalSeconds);
51 double getSampleRate()
const;
52 int getBitDepth()
const;
53 int getBlockSize()
const;
55 double getBlockSizeMs()
const;
56 double getOutputLatencySeconds()
const;
59 double getRecordAdjustmentMs();
60 int getRecordAdjustmentSamples();
63 float getCpuUsage()
const noexcept {
return (
float) currentCpuUsage; }
67 void setCpuLimitBeforeMuting (
double newLimit) {
jassert (newLimit > 0); cpuLimitBeforeMuting = newLimit; }
69 PerformanceMeasurement::Statistics getCPUStatistics()
const;
70 void restCPUStatistics();
102 int getNumInputDevices()
const;
105 int getNumOutputDevices()
const;
116 int getNumWaveOutDevices()
const {
return waveOutputs.size(); }
117 WaveOutputDevice* getWaveOutDevice (
int index)
const {
return waveOutputs[index]; }
121 juce::String getDefaultWaveOutDeviceID()
const {
return defaultWaveOutID; }
123 int getNumWaveInDevices()
const {
return waveInputs.size(); }
124 WaveInputDevice* getWaveInDevice (
int index)
const {
return waveInputs[index]; }
128 juce::String getDefaultWaveInDeviceID()
const {
return defaultWaveInID; }
131 void setDeviceOutChannelStereo (
int channelNum,
bool isStereoPair);
132 bool isDeviceOutChannelStereo (
int chan)
const {
return ! outMonoChans[chan / 2]; }
133 bool isDeviceOutEnabled (
int chanNum) {
return outEnabled[chanNum]; }
136 void setDeviceInChannelStereo (
int channelNum,
bool isStereoPair);
137 bool isDeviceInChannelStereo (
int chan)
const {
return inStereoChans[chan / 2]; }
138 bool isDeviceInEnabled (
int chanNum) {
return inEnabled[chanNum]; }
141 int getNumMidiOutDevices()
const {
return (
int) midiOutputs.size(); }
142 MidiOutputDevice* getMidiOutDevice (
int index)
const {
return index >= 0 && index < (
int) midiOutputs.size() ? midiOutputs[(
size_t) index].get() :
nullptr; }
146 juce::String getDefaultMidiOutDeviceID()
const {
return defaultMidiOutID; }
148 int getNumMidiInDevices()
const;
155 juce::String getDefaultMidiInDeviceID()
const {
return defaultMidiInID; }
160 void broadcastStreamTimeToMidiDevices (
double streamTime);
161 bool shouldSendMidiTimecode()
const noexcept {
return sendMidiTimecode; }
168 bool isMSWavetableSynthPresent()
const;
174 void checkDefaultDevicesAreValid();
176 static juce::String getDefaultAudioOutDeviceName (
bool translated);
177 static juce::String getDefaultMidiOutDeviceName (
bool translated);
179 static juce::String getDefaultAudioInDeviceName (
bool translated);
180 static juce::String getDefaultMidiInDeviceName (
bool translated);
234 bool finishedInitialising =
false;
235 bool sendMidiTimecode =
false;
237 std::atomic<double> currentCpuUsage { 0 }, streamTime { 0 }, cpuLimitBeforeMuting { 0.98 };
238 std::atomic<bool> isSuspended {
true }, outputHasClipped {
false }, outputClippingEnabled {
false };
239 double currentLatencyMs = 0, outputLatencyTime = 0, currentSampleRate = 0;
240 int maxBlockSize = 0;
242 int defaultNumInputChannelsToOpen = 512, defaultNumOutputChannelsToOpen = 512;
243 juce::BigInteger outEnabled, inEnabled, activeOutChannels, outMonoChans, inStereoChans;
244 juce::String defaultWaveOutID, defaultMidiOutID, defaultWaveInID, defaultMidiInID;
246 int midiRescanIntervalSeconds = 4;
247 bool onlyRescanMidiOnHardwareChange =
true;
249 struct MIDIDeviceList;
252 struct AvailableWaveDeviceList;
255 struct PrepareToStartCaller;
267 ScopedSteadyLoad::Context steadyLoadContext;
270 PerformanceMeasurement performanceMeasurement {
"tracktion_engine::DeviceManager", -1,
false };
271 crill::seqlock_object<PerformanceMeasurement::Statistics> performanceStats;
274 void applyNewMidiDeviceList();
275 void restartMidiCheckTimer();
277 void clearAllContextDevices();
278 void reloadAllContextDevices();
281 void sanityCheckEnabledChannels();
283 bool usesHardwareMidiDevices();
284 void timerCallback()
override;
286 void handleAsyncUpdate()
override;
289 void audioDeviceIOCallbackWithContext (
const float*
const* inputChannelData,
int totalNumInputChannels,
290 float*
const* outputChannelData,
int totalNumOutputChannels,
int numSamples,
293 void audioDeviceStopped()
override;
294 void prepareToStart();
296 void audioDeviceIOCallbackInternal (
const float*
const* inputChannelData,
int numInputChannels,
297 float*
const* outputChannelData,
int totalNumOutputChannels,