Skip to content

Commit 98e442c

Browse files
committed
WIP allowing devices to use more channels
1 parent fc819ac commit 98e442c

9 files changed

+17
-12
lines changed

modules/tracktion_engine/playback/devices/tracktion_WaveDeviceDescription.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,4 @@ struct WaveDeviceDescriptionList
8282
};
8383

8484

85-
}} // namespace tracktion::inline engine
85+
} // namespace tracktion::inline engine

modules/tracktion_engine/playback/devices/tracktion_WaveInputDevice.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ class WaveInputDeviceInstance : public InputDeviceInstance
390390
auto& wi = getWaveInput();
391391

392392
rc->fileWriter = std::make_unique<AudioFileWriter> (AudioFile (edit.engine, recordedFile), format,
393-
wi.isStereoPair() ? 2 : 1,
393+
(int) wi.getChannels().getNumChannels(),
394394
rc->sampleRate, wi.bitDepth, metadata, 0);
395395

396396
if (rc->fileWriter->isOpen())
@@ -431,7 +431,7 @@ class WaveInputDeviceInstance : public InputDeviceInstance
431431
{
432432
if ((rc->thumbnail = edit.engine.getRecordingThumbnailManager().getThumbnailFor (recordedFile)))
433433
{
434-
rc->thumbnail->reset (wi.isStereoPair() ? 2 : 1, rc->sampleRate);
434+
rc->thumbnail->reset ((int) wi.getChannels().getNumChannels(), rc->sampleRate);
435435
rc->thumbnail->punchInTime = punchRange.getStart();
436436
}
437437
}

modules/tracktion_engine/playback/devices/tracktion_WaveOutputDevice.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,15 @@ WaveOutputDeviceInstance::WaveOutputDeviceInstance (WaveOutputDevice& d, EditPla
113113

114114
void WaveOutputDeviceInstance::prepareToPlay (double, int blockSize)
115115
{
116-
outputBuffer.setSize (2, blockSize);
116+
const auto numChannels = (int) getWaveOutput().getChannels().getNumChannels();
117+
outputBuffer.setSize (numChannels, blockSize);
117118

118119
int ditherDepth = juce::jlimit (16, 32, edit.engine.getDeviceManager().getBitDepth());
119120

120-
ditherers[0].reset (ditherDepth);
121-
ditherers[1].reset (ditherDepth);
121+
ditherers.resize ((size_t) numChannels);
122+
123+
for (auto& d : ditherers)
124+
d.reset (ditherDepth);
122125
}
123126

124127
//==============================================================================

modules/tracktion_engine/playback/devices/tracktion_WaveOutputDevice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class WaveOutputDeviceInstance : public OutputDeviceInstance
7979
void prepareToPlay (double sampleRate, int blockSizeSamples);
8080

8181
protected:
82-
Ditherer ditherers[2];
82+
std::vector<Ditherer> ditherers;
8383
MidiMessageArray midiBuffer;
8484
juce::AudioBuffer<float> outputBuffer;
8585

modules/tracktion_engine/playback/graph/tracktion_EditNodeBuilder.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,10 @@ std::unique_ptr<tracktion::graph::Node> createNodeForPlugin (Plugin& plugin, con
12431243
// If there's a channel count mismatch, wrap in ChannelRemappingNode to handle:
12441244
// - Passthrough (input > processor): extra channels pass through unprocessed
12451245
// - Expansion (input < processor): processor outputs its full channel count
1246-
if (incomingChannels != pluginInputChannels)
1246+
// Skip if either config is empty - ChannelRemappingNode requires valid channel configs
1247+
if (incomingChannels != pluginInputChannels
1248+
&& incomingChannels > 0
1249+
&& pluginInputChannels > 0)
12471250
{
12481251
return tracktion::graph::makeNode<ChannelRemappingNode> (std::move (pluginNode),
12491252
ChannelConfiguration::discreteChannels (incomingChannels),

modules/tracktion_engine/playback/graph/tracktion_WaveInputDeviceNode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ tracktion::graph::NodeProperties WaveInputDeviceNode::getNodeProperties()
3535

3636
void WaveInputDeviceNode::prepareToPlay (const tracktion::graph::PlaybackInitialisationInfo& info)
3737
{
38-
auto numIncomingChannels = (waveInputDevice.isStereoPair()) ? 2u : 1u;
38+
auto numIncomingChannels = (uint32_t) waveInputDevice.getChannels().getNumChannels();
3939
audioFifo.setSize (numIncomingChannels, (uint32_t) info.blockSize * 8);
4040
lastCallbackTime = juce::Time::getMillisecondCounter();
4141

modules/tracktion_engine/playback/tracktion_DeviceManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class DeviceManager : public juce::ChangeBroadcaster,
234234
*/
235235
std::function<void(InputDevice*)> warnOfWastedMidiMessagesFunction;
236236

237-
static constexpr uint32_t maxNumChannelsPerDevice = 2; // Temporary limit until we support multichannel
237+
static constexpr uint32_t maxNumChannelsPerDevice = 2;
238238

239239
private:
240240
//==============================================================================

modules/tracktion_engine/tracktion_engine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
#include "../3rd_party/choc/containers/choc_Value.h"
7575
#include "../3rd_party/choc/containers/choc_SmallVector.h"
7676
#include "../3rd_party/choc/text/choc_JSON.h"
77-
#else
77+
#endif
7878

7979
#include "../3rd_party/expected/expected.hpp"
8080

modules/tracktion_engine/tracktion_engine_playback.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ namespace tracktion
160160

161161
#include "../3rd_party/choc/choc/platform/choc_ReenableAllWarnings.h"
162162
#include "../3rd_party/crill/seqlock_object.h"
163-
#include "../3rd_party/choc/text/choc_JSON.h"
164163

165164
//==============================================================================
166165
#if JUCE_LINUX || JUCE_WINDOWS

0 commit comments

Comments
 (0)