11namespace tracktion {
inline namespace engine
14WaveOutputDevice::WaveOutputDevice (
Engine& e,
const WaveDeviceDescription& desc)
15 : OutputDevice (e,
NEEDS_TRANS(
"Wave Audio Output"), desc.name, desc.name),
16 deviceChannels (desc.channels),
18 ditheringEnabled (false),
19 leftRightReversed (false)
21 enabled = desc.enabled;
25WaveOutputDevice::~WaveOutputDevice()
27 notifyListenersOfDeletion();
31void WaveOutputDevice::resetToDefault()
33 engine.getPropertyStorage().removePropertyItem (SettingID::waveout,
getName());
37void WaveOutputDevice::setEnabled (
bool b)
43 engine.getDeviceManager().setWaveOutChannelsEnabled (deviceChannels, b);
53void WaveOutputDevice::closeDevice()
58void WaveOutputDevice::loadProps()
60 ditheringEnabled =
false;
61 leftRightReversed =
false;
63 if (
auto n = engine.getPropertyStorage().getXmlPropertyItem (SettingID::waveout,
getName()))
65 ditheringEnabled = n->getBoolAttribute (
"dithering", ditheringEnabled);
66 leftRightReversed = n->getBoolAttribute (
"reversed", leftRightReversed);
70void WaveOutputDevice::saveProps()
74 n.setAttribute (
"dithering", ditheringEnabled);
75 n.setAttribute (
"reversed", leftRightReversed);
77 engine.getPropertyStorage().setXmlPropertyItem (SettingID::waveout,
getName(), n);
80void WaveOutputDevice::reverseChannels (
bool shouldReverse)
84 if (leftRightReversed != shouldReverse)
86 leftRightReversed = shouldReverse;
92void WaveOutputDevice::setDithered (
bool dither)
94 if (ditheringEnabled != dither)
96 ditheringEnabled = dither;
103WaveOutputDeviceInstance* WaveOutputDevice::createInstance (EditPlaybackContext& c)
105 return new WaveOutputDeviceInstance (*
this, c);
109WaveOutputDeviceInstance::WaveOutputDeviceInstance (WaveOutputDevice& d, EditPlaybackContext& c)
110 : OutputDeviceInstance (d, c),
111 outputBuffer (1, 128)
115void WaveOutputDeviceInstance::prepareToPlay (
double,
int blockSize)
117 outputBuffer.setSize (2, blockSize);
119 int ditherDepth =
juce::jlimit (16, 32, edit.engine.getDeviceManager().getBitDepth());
121 ditherers[0].reset (ditherDepth);
122 ditherers[1].reset (ditherDepth);
126int WaveOutputDevice::getLeftChannel()
const
128 return deviceChannels.size() >= 1 ? deviceChannels[0].indexInDevice : -1;
131int WaveOutputDevice::getRightChannel()
const
133 return deviceChannels.size() >= 2 ? deviceChannels[1].indexInDevice : -1;
136bool WaveOutputDevice::isStereoPair()
const
138 return deviceChannels.size() == 2;
141void WaveOutputDevice::setStereoPair (
bool stereo)
143 auto& dm = engine.getDeviceManager();
145 if (deviceChannels.size() == 2)
146 dm.setDeviceOutChannelStereo (
std::max (getLeftChannel(), getRightChannel()), stereo);
147 else if (deviceChannels.size() == 1)
148 dm.setDeviceOutChannelStereo (getLeftChannel(), stereo);
#define NEEDS_TRANS(stringLiteral)
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
juce::String getName(LaunchQType t)
Retuns the name of a LaunchQType for display purposes.
juce::AudioChannelSet createChannelSet(const std::vector< ChannelIndex > &channels)
Creates an AudioChannelSet for a list of ChannelIndexes.