TracktionEngine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
engine::DeviceManager Class Reference

#include <tracktion_DeviceManager.h>

Inherits juce::ChangeBroadcaster, juce::ChangeListener, juce::AudioIODeviceCallback, juce::AsyncUpdater, and juce::Timer.

Classes

struct  TracktionEngineAudioDeviceManager
 Subclass of an AudioDeviceManager which can be used to avoid adding the system audio devices in plugin builds. More...
 

Public Member Functions

 ~DeviceManager () override
 
void initialise (int defaultNumInputChannelsToOpen=defaultNumChannelsToOpen, int defaultNumOutputChannelsToOpen=defaultNumChannelsToOpen)
 
void closeDevices ()
 
void saveSettings ()
 
void resetToDefaults (bool deviceSettings, bool resetInputDevices, bool resetOutputDevices, bool latencySettings, bool mixSettings)
 
void rescanMidiDeviceList ()
 
void rescanWaveDeviceList ()
 
int getMidiDeviceScanIntervalSeconds () const
 
void setMidiDeviceScanIntervalSeconds (int intervalSeconds)
 
double getSampleRate () const
 
int getBitDepth () const
 
int getBlockSize () const
 
TimeDuration getBlockLength () const
 
double getBlockSizeMs () const
 
double getOutputLatencySeconds () const
 
double getRecordAdjustmentMs ()
 
int getRecordAdjustmentSamples ()
 
float getCpuUsage () const noexcept
 
void setCpuLimitBeforeMuting (double newLimit)
 
PerformanceMeasurement::Statistics getCPUStatistics () const
 
void restCPUStatistics ()
 
void updateNumCPUs ()
 
void enableOutputClipping (bool clipOutput)
 If set to true, clips the output at 0.0.
 
bool hasOutputClipped (bool reset)
 Checks if the output has clipped.
 
HostedAudioDeviceInterfacegetHostedAudioDeviceInterface ()
 If you are using the engine in a plugin or an application that accesses the audio device directly, use this interface to pass audio and midi to the DeviceManager.
 
bool isHostedAudioDeviceInterfaceInUse () const
 Returns true if the hosted interface is available and in use.
 
void removeHostedAudioDeviceInterface ()
 Removes the hosted audio device.
 
int getNumInputDevices () const
 
InputDevicegetInputDevice (int index) const
 
int getNumOutputDevices () const
 
OutputDevicegetOutputDeviceAt (int index) const
 
InputDevicefindInputDeviceForID (const juce::String &id) const
 
InputDevicefindInputDeviceWithName (const juce::String &name) const
 
std::shared_ptr< MidiInputDevicefindMidiInputDeviceForID (const juce::String &id) const
 
OutputDevicefindOutputDeviceForID (const juce::String &id) const
 
OutputDevicefindOutputDeviceWithName (const juce::String &name) const
 
int getNumWaveOutDevices () const
 
WaveOutputDevicegetWaveOutDevice (int index) const
 
void setDefaultWaveOutDevice (juce::String deviceID)
 
WaveOutputDevicegetDefaultWaveOutDevice () const
 
juce::String getDefaultWaveOutDeviceID () const
 
int getNumWaveInDevices () const
 
WaveInputDevicegetWaveInDevice (int index) const
 
void setDefaultWaveInDevice (juce::String deviceID)
 
WaveInputDevicegetDefaultWaveInDevice () const
 
juce::String getDefaultWaveInDeviceID () const
 
std::vector< WaveOutputDevice * > getWaveOutputDevices ()
 
std::vector< WaveInputDevice * > getWaveInputDevices ()
 
void setDeviceEnabled (WaveOutputDevice &, bool)
 
void setDeviceEnabled (WaveInputDevice &, bool)
 
void setDeviceNumChannels (WaveOutputDevice &, uint32_t numChannels)
 
void setDeviceNumChannels (WaveInputDevice &, uint32_t numChannels)
 
void setAllWaveInputsToNumChannels (uint32_t numChannels)
 
void setAllWaveOutputsToNumChannels (uint32_t numChannels)
 
juce::StringArray getPossibleChannelGroupsForDevice (WaveOutputDevice &, uint32_t maxNumChannels) const
 
juce::StringArray getPossibleChannelGroupsForDevice (WaveInputDevice &, uint32_t maxNumChannels) const
 
juce::XmlElement getCurrentWaveDeviceLayout () const
 Wave device channel-grouping layout presets.
 
void applyWaveDeviceLayout (const juce::XmlElement &)
 Applies a previously captured layout to the current device, rebuilding the wave devices.
 
juce::StringArray getWaveDeviceLayoutPresetNames ()
 Returns the names of all stored channel-layout presets.
 
void saveWaveDeviceLayoutPreset (const juce::String &name)
 Stores the current channel grouping as a named preset (overwriting any preset with the same name).
 
void loadWaveDeviceLayoutPreset (const juce::String &name)
 Recalls a named preset and applies it to the current device.
 
void deleteWaveDeviceLayoutPreset (const juce::String &name)
 Deletes a named preset.
 
int getNumMidiOutDevices () const
 
MidiOutputDevicegetMidiOutDevice (int index) const
 
void setDefaultMidiOutDevice (juce::String deviceID)
 
MidiOutputDevicegetDefaultMidiOutDevice () const
 
juce::String getDefaultMidiOutDeviceID () const
 
int getNumMidiInDevices () const
 
std::shared_ptr< MidiInputDevicegetMidiInDevice (int index) const
 
std::vector< std::shared_ptr< MidiInputDevice > > getMidiInDevices () const
 
void setDefaultMidiInDevice (juce::String deviceID)
 
MidiInputDevicegetDefaultMidiInDevice () const
 
juce::String getDefaultMidiInDeviceID () const
 
void injectMIDIMessageToDefaultDevice (const juce::MidiMessage &)
 
void broadcastMessageToAllVirtualDevices (PhysicalMidiInputDevice &, const juce::MidiMessage &)
 
void broadcastStreamTimeToMidiDevices (double streamTime)
 
bool shouldSendMidiTimecode () const noexcept
 
double getCurrentStreamTime () const noexcept
 Returns the current block's stream time.
 
bool isMSWavetableSynthPresent () const
 
void dispatchPendingUpdates ()
 Changes to the devices get applied asyncronously so this function can be called to trigger any pending updates to be flushed.
 
void checkDefaultDevicesAreValid ()
 
juce::Result createVirtualMidiDevice (const juce::String &name)
 
void deleteVirtualMidiDevice (VirtualMidiInputDevice &)
 
void addContext (EditPlaybackContext *)
 
void removeContext (EditPlaybackContext *)
 
void setGlobalOutputAudioProcessor (std::unique_ptr< juce::AudioProcessor >)
 Sets a global processor to be applied to the output.
 
juce::AudioProcessor * getGlobalOutputAudioProcessor () const
 Returns a previously set globalOutputAudioProcessor.
 

Static Public Member Functions

static juce::String getDefaultAudioOutDeviceName (bool translated)
 
static juce::String getDefaultMidiOutDeviceName (bool translated)
 
static juce::String getDefaultAudioInDeviceName (bool translated)
 
static juce::String getDefaultMidiInDeviceName (bool translated)
 

Public Attributes

Engineengine
 
TracktionEngineAudioDeviceManager deviceManager { engine }
 
std::unique_ptr< HostedAudioDeviceInterfacehostedAudioDeviceInterface
 
std::vector< std::shared_ptr< MidiInputDevice > > midiInputs
 
std::vector< std::shared_ptr< MidiOutputDevice > > midiOutputs
 
juce::OwnedArray< WaveInputDevicewaveInputs
 
juce::OwnedArray< WaveOutputDevicewaveOutputs
 
std::function< void(InputDevice *)> warnOfWastedMidiMessagesFunction
 If this is set, it will get called (possibly on the midi thread) when incoming messages seem to be unused.
 

Static Public Attributes

static constexpr int defaultNumChannelsToOpen = 512
 
static constexpr uint32_t maxNumChannelsPerDevice = 128
 

Constructor & Destructor Documentation

◆ ~DeviceManager()

engine::DeviceManager::~DeviceManager ( )
override

Member Function Documentation

◆ initialise()

void engine::DeviceManager::initialise ( int  defaultNumInputChannelsToOpen = defaultNumChannelsToOpen,
int  defaultNumOutputChannelsToOpen = defaultNumChannelsToOpen 
)

◆ closeDevices()

void engine::DeviceManager::closeDevices ( )

◆ saveSettings()

void engine::DeviceManager::saveSettings ( )

◆ resetToDefaults()

void engine::DeviceManager::resetToDefaults ( bool  deviceSettings,
bool  resetInputDevices,
bool  resetOutputDevices,
bool  latencySettings,
bool  mixSettings 
)

◆ rescanMidiDeviceList()

void engine::DeviceManager::rescanMidiDeviceList ( )

◆ rescanWaveDeviceList()

void engine::DeviceManager::rescanWaveDeviceList ( )

◆ getMidiDeviceScanIntervalSeconds()

int engine::DeviceManager::getMidiDeviceScanIntervalSeconds ( ) const

◆ setMidiDeviceScanIntervalSeconds()

void engine::DeviceManager::setMidiDeviceScanIntervalSeconds ( int  intervalSeconds)

◆ getSampleRate()

double engine::DeviceManager::getSampleRate ( ) const

◆ getBitDepth()

int engine::DeviceManager::getBitDepth ( ) const

◆ getBlockSize()

int engine::DeviceManager::getBlockSize ( ) const

◆ getBlockLength()

TimeDuration engine::DeviceManager::getBlockLength ( ) const

◆ getBlockSizeMs()

double engine::DeviceManager::getBlockSizeMs ( ) const

◆ getOutputLatencySeconds()

double engine::DeviceManager::getOutputLatencySeconds ( ) const

◆ getRecordAdjustmentMs()

double engine::DeviceManager::getRecordAdjustmentMs ( )

◆ getRecordAdjustmentSamples()

int engine::DeviceManager::getRecordAdjustmentSamples ( )

◆ getCpuUsage()

float engine::DeviceManager::getCpuUsage ( ) const
noexcept

◆ setCpuLimitBeforeMuting()

void engine::DeviceManager::setCpuLimitBeforeMuting ( double  newLimit)

◆ getCPUStatistics()

PerformanceMeasurement::Statistics engine::DeviceManager::getCPUStatistics ( ) const

◆ restCPUStatistics()

void engine::DeviceManager::restCPUStatistics ( )

◆ updateNumCPUs()

void engine::DeviceManager::updateNumCPUs ( )

◆ enableOutputClipping()

void engine::DeviceManager::enableOutputClipping ( bool  clipOutput)

If set to true, clips the output at 0.0.

◆ hasOutputClipped()

bool engine::DeviceManager::hasOutputClipped ( bool  reset)

Checks if the output has clipped.

Parameters
resetResets the clipped flag

◆ getHostedAudioDeviceInterface()

HostedAudioDeviceInterface & engine::DeviceManager::getHostedAudioDeviceInterface ( )

If you are using the engine in a plugin or an application that accesses the audio device directly, use this interface to pass audio and midi to the DeviceManager.

◆ isHostedAudioDeviceInterfaceInUse()

bool engine::DeviceManager::isHostedAudioDeviceInterfaceInUse ( ) const

Returns true if the hosted interface is available and in use.

◆ removeHostedAudioDeviceInterface()

void engine::DeviceManager::removeHostedAudioDeviceInterface ( )

Removes the hosted audio device.

You shouldn't normally need to call this but can be useful for running tests. Afterwards, you'll need to call initialise again.

◆ getNumInputDevices()

int engine::DeviceManager::getNumInputDevices ( ) const

◆ getInputDevice()

InputDevice * engine::DeviceManager::getInputDevice ( int  index) const

◆ getNumOutputDevices()

int engine::DeviceManager::getNumOutputDevices ( ) const

◆ getOutputDeviceAt()

OutputDevice * engine::DeviceManager::getOutputDeviceAt ( int  index) const

◆ findInputDeviceForID()

InputDevice * engine::DeviceManager::findInputDeviceForID ( const juce::String &  id) const

◆ findInputDeviceWithName()

InputDevice * engine::DeviceManager::findInputDeviceWithName ( const juce::String &  name) const

◆ findMidiInputDeviceForID()

std::shared_ptr< MidiInputDevice > engine::DeviceManager::findMidiInputDeviceForID ( const juce::String &  id) const

◆ findOutputDeviceForID()

OutputDevice * engine::DeviceManager::findOutputDeviceForID ( const juce::String &  id) const

◆ findOutputDeviceWithName()

OutputDevice * engine::DeviceManager::findOutputDeviceWithName ( const juce::String &  name) const

◆ getNumWaveOutDevices()

int engine::DeviceManager::getNumWaveOutDevices ( ) const

◆ getWaveOutDevice()

WaveOutputDevice * engine::DeviceManager::getWaveOutDevice ( int  index) const

◆ setDefaultWaveOutDevice()

void engine::DeviceManager::setDefaultWaveOutDevice ( juce::String  deviceID)

◆ getDefaultWaveOutDevice()

WaveOutputDevice * engine::DeviceManager::getDefaultWaveOutDevice ( ) const

◆ getDefaultWaveOutDeviceID()

juce::String engine::DeviceManager::getDefaultWaveOutDeviceID ( ) const

◆ getNumWaveInDevices()

int engine::DeviceManager::getNumWaveInDevices ( ) const

◆ getWaveInDevice()

WaveInputDevice * engine::DeviceManager::getWaveInDevice ( int  index) const

◆ setDefaultWaveInDevice()

void engine::DeviceManager::setDefaultWaveInDevice ( juce::String  deviceID)

◆ getDefaultWaveInDevice()

WaveInputDevice * engine::DeviceManager::getDefaultWaveInDevice ( ) const

◆ getDefaultWaveInDeviceID()

juce::String engine::DeviceManager::getDefaultWaveInDeviceID ( ) const

◆ getWaveOutputDevices()

std::vector< WaveOutputDevice * > engine::DeviceManager::getWaveOutputDevices ( )

◆ getWaveInputDevices()

std::vector< WaveInputDevice * > engine::DeviceManager::getWaveInputDevices ( )

◆ setDeviceEnabled() [1/2]

void engine::DeviceManager::setDeviceEnabled ( WaveOutputDevice ,
bool   
)

◆ setDeviceEnabled() [2/2]

void engine::DeviceManager::setDeviceEnabled ( WaveInputDevice ,
bool   
)

◆ setDeviceNumChannels() [1/2]

void engine::DeviceManager::setDeviceNumChannels ( WaveOutputDevice ,
uint32_t  numChannels 
)

◆ setDeviceNumChannels() [2/2]

void engine::DeviceManager::setDeviceNumChannels ( WaveInputDevice ,
uint32_t  numChannels 
)

◆ setAllWaveInputsToNumChannels()

void engine::DeviceManager::setAllWaveInputsToNumChannels ( uint32_t  numChannels)

◆ setAllWaveOutputsToNumChannels()

void engine::DeviceManager::setAllWaveOutputsToNumChannels ( uint32_t  numChannels)

◆ getPossibleChannelGroupsForDevice() [1/2]

juce::StringArray engine::DeviceManager::getPossibleChannelGroupsForDevice ( WaveOutputDevice ,
uint32_t  maxNumChannels 
) const

◆ getPossibleChannelGroupsForDevice() [2/2]

juce::StringArray engine::DeviceManager::getPossibleChannelGroupsForDevice ( WaveInputDevice ,
uint32_t  maxNumChannels 
) const

◆ getCurrentWaveDeviceLayout()

juce::XmlElement engine::DeviceManager::getCurrentWaveDeviceLayout ( ) const

Wave device channel-grouping layout presets.

The way a physical device's channels are grouped into WaveInputDevice and WaveOutputDevice instances is normally stored per-device-type and lost when the device changes. These methods let that grouping be captured as a named preset (stored in the global PropertyStorage) and recalled at any time, even onto a different device - the recalled layout is fitted to whatever device is currently active. Returns the current channel grouping as an XML layout (an AUDIODEVICE_LAYOUT element).

◆ applyWaveDeviceLayout()

void engine::DeviceManager::applyWaveDeviceLayout ( const juce::XmlElement &  )

Applies a previously captured layout to the current device, rebuilding the wave devices.

◆ getWaveDeviceLayoutPresetNames()

juce::StringArray engine::DeviceManager::getWaveDeviceLayoutPresetNames ( )

Returns the names of all stored channel-layout presets.

◆ saveWaveDeviceLayoutPreset()

void engine::DeviceManager::saveWaveDeviceLayoutPreset ( const juce::String &  name)

Stores the current channel grouping as a named preset (overwriting any preset with the same name).

◆ loadWaveDeviceLayoutPreset()

void engine::DeviceManager::loadWaveDeviceLayoutPreset ( const juce::String &  name)

Recalls a named preset and applies it to the current device.

◆ deleteWaveDeviceLayoutPreset()

void engine::DeviceManager::deleteWaveDeviceLayoutPreset ( const juce::String &  name)

Deletes a named preset.

◆ getNumMidiOutDevices()

int engine::DeviceManager::getNumMidiOutDevices ( ) const

◆ getMidiOutDevice()

MidiOutputDevice * engine::DeviceManager::getMidiOutDevice ( int  index) const

◆ setDefaultMidiOutDevice()

void engine::DeviceManager::setDefaultMidiOutDevice ( juce::String  deviceID)

◆ getDefaultMidiOutDevice()

MidiOutputDevice * engine::DeviceManager::getDefaultMidiOutDevice ( ) const

◆ getDefaultMidiOutDeviceID()

juce::String engine::DeviceManager::getDefaultMidiOutDeviceID ( ) const

◆ getNumMidiInDevices()

int engine::DeviceManager::getNumMidiInDevices ( ) const

◆ getMidiInDevice()

std::shared_ptr< MidiInputDevice > engine::DeviceManager::getMidiInDevice ( int  index) const

◆ getMidiInDevices()

std::vector< std::shared_ptr< MidiInputDevice > > engine::DeviceManager::getMidiInDevices ( ) const

◆ setDefaultMidiInDevice()

void engine::DeviceManager::setDefaultMidiInDevice ( juce::String  deviceID)

◆ getDefaultMidiInDevice()

MidiInputDevice * engine::DeviceManager::getDefaultMidiInDevice ( ) const

◆ getDefaultMidiInDeviceID()

juce::String engine::DeviceManager::getDefaultMidiInDeviceID ( ) const

◆ injectMIDIMessageToDefaultDevice()

void engine::DeviceManager::injectMIDIMessageToDefaultDevice ( const juce::MidiMessage &  )

◆ broadcastMessageToAllVirtualDevices()

void engine::DeviceManager::broadcastMessageToAllVirtualDevices ( PhysicalMidiInputDevice ,
const juce::MidiMessage &   
)

◆ broadcastStreamTimeToMidiDevices()

void engine::DeviceManager::broadcastStreamTimeToMidiDevices ( double  streamTime)

◆ shouldSendMidiTimecode()

bool engine::DeviceManager::shouldSendMidiTimecode ( ) const
noexcept

◆ getCurrentStreamTime()

double engine::DeviceManager::getCurrentStreamTime ( ) const
noexcept

Returns the current block's stream time.

This shouldn't really be used and may be removed in future.

◆ isMSWavetableSynthPresent()

bool engine::DeviceManager::isMSWavetableSynthPresent ( ) const

◆ dispatchPendingUpdates()

void engine::DeviceManager::dispatchPendingUpdates ( )

Changes to the devices get applied asyncronously so this function can be called to trigger any pending updates to be flushed.

◆ checkDefaultDevicesAreValid()

void engine::DeviceManager::checkDefaultDevicesAreValid ( )

◆ getDefaultAudioOutDeviceName()

static juce::String engine::DeviceManager::getDefaultAudioOutDeviceName ( bool  translated)
static

◆ getDefaultMidiOutDeviceName()

static juce::String engine::DeviceManager::getDefaultMidiOutDeviceName ( bool  translated)
static

◆ getDefaultAudioInDeviceName()

static juce::String engine::DeviceManager::getDefaultAudioInDeviceName ( bool  translated)
static

◆ getDefaultMidiInDeviceName()

static juce::String engine::DeviceManager::getDefaultMidiInDeviceName ( bool  translated)
static

◆ createVirtualMidiDevice()

juce::Result engine::DeviceManager::createVirtualMidiDevice ( const juce::String &  name)

◆ deleteVirtualMidiDevice()

void engine::DeviceManager::deleteVirtualMidiDevice ( VirtualMidiInputDevice )

◆ addContext()

void engine::DeviceManager::addContext ( EditPlaybackContext )

◆ removeContext()

void engine::DeviceManager::removeContext ( EditPlaybackContext )

◆ setGlobalOutputAudioProcessor()

void engine::DeviceManager::setGlobalOutputAudioProcessor ( std::unique_ptr< juce::AudioProcessor >  )

Sets a global processor to be applied to the output.

This can be used to set a limiter or similar on the whole ouput. It shouldn't be used for musical effects.

◆ getGlobalOutputAudioProcessor()

juce::AudioProcessor * engine::DeviceManager::getGlobalOutputAudioProcessor ( ) const

Returns a previously set globalOutputAudioProcessor.

Member Data Documentation

◆ defaultNumChannelsToOpen

constexpr int engine::DeviceManager::defaultNumChannelsToOpen = 512
staticconstexpr

◆ engine

Engine& engine::DeviceManager::engine

◆ deviceManager

TracktionEngineAudioDeviceManager engine::DeviceManager::deviceManager { engine }

◆ hostedAudioDeviceInterface

std::unique_ptr<HostedAudioDeviceInterface> engine::DeviceManager::hostedAudioDeviceInterface

◆ midiInputs

std::vector<std::shared_ptr<MidiInputDevice> > engine::DeviceManager::midiInputs

◆ midiOutputs

std::vector<std::shared_ptr<MidiOutputDevice> > engine::DeviceManager::midiOutputs

◆ waveInputs

juce::OwnedArray<WaveInputDevice> engine::DeviceManager::waveInputs

◆ waveOutputs

juce::OwnedArray<WaveOutputDevice> engine::DeviceManager::waveOutputs

◆ warnOfWastedMidiMessagesFunction

std::function<void(InputDevice*)> engine::DeviceManager::warnOfWastedMidiMessagesFunction

If this is set, it will get called (possibly on the midi thread) when incoming messages seem to be unused.

May want to use it to warn the user.

◆ maxNumChannelsPerDevice

constexpr uint32_t engine::DeviceManager::maxNumChannelsPerDevice = 128
staticconstexpr

The documentation for this class was generated from the following file: