On how to use stereo input

I’m quite confused about how to add wave inputs to audio tracks.
Specifically, having an audio interface with two inputs, I would like to be able to set the inputs of a track to one of three options: input 1, input 2 or input 1-2.
The problem is how to use the two inputs combined as a stereo pair.
First, I tried simply:

input1->setTargetTrack (*track, 0, false);
input2->setTargetTrack (*track, 0, false);
input1->setRecordingEnabled (*track, true);
input2->setRecordingEnabled (*track, true);

(Where input1 and input2 are of the type InputDeviceInstance*).
But when recording I end with two audio clips with mono source files on the track.

Then I discovered WaveInputDevice::setStereoPair, but it seems that this will combine the two inputs in a way, so that I can then only use them as a stereo pair.

This probably comes down me not quite understanding the distinction between InputDevices and InputDeviceInstances

Is it possible to use the same physical inputs as mono inputs and stereo pairs at the same time?

That is a limitation of the engine. Inputs are either mono or stereo. What are you trying to do? Maybe I can think of another way to accomplish it.

Ah ok. I’m creating a daw and I want the user to be able to do something like this:
Create two tracks.
Set input 1 to the first.
Set input 1-2 to the second.
Record enabling track 1 should record a mono audio file and doing so for track 2 should record a stereo file.
(Similar to how it works in Logic)

The inputs don’t need to be active / sounding until the user chooses to record enable a track and it shouldn’t be possible to record enable the same input in more than one track at a time.
So the solution might be something like not actually calling input->setTargetTrack before user clicks record enable?

I don’t think this can be done at the moment as it’s the devices that have the stereo/mono setting, not the instance that the Edits get.

Eventually we’ll want to add user-definable busses for inputs (so you can make your own inputs from any hardware device) but we’re not quite there yet I’m afraid. You might just have to record in stereo on both tracks and make the second one mono when recording is stopped?

Eventually we’ll want to add user-definable busses for inputs (so you can make your own inputs from any hardware device)

That sounds great, I’ll look forward to that! I have a deadline for this project somewhere in the fall - is there a chance you’ll get to that before then?

You might just have to record in stereo on both tracks and make the second one mono when recording is stopped?

By “making it mono”, do you mean something like converting the clip (and source file) to a mono file using only the channel chosen by the user? In the example above that would be the left channel.

I’m thinking for my case a cleaner solution might be to just change the stereo pair configuration on the fly. Cause I don’t need e.g. 1-2 and 1 and 2 at the same time anyway.
So that whenever the user wants to turn on input monitoring for a track og record enable it, then I’ll pair up the inputs if needed.

That might be easier.

I’ll try it out now

Can I ask how you solved this in the end?

I’m struggling to understand how to use stereo input and in general how to reliably choose inputs. WaveInputDevice vs WaveInputDeviceInstance etc confuses me…

Can I ask exactly what you’re trying to do?

WaveInputDevice is global i.e. per Engine instance.
Each Edit has a set of WaveInputDeviceInstances that it can assign to tracks etc.

What I would like to do is to present the user with a list of the available audio inputs and let them choose exactly one, mono OR stereo. Something like this, if the used audio device has four input channels:

Input 1–2 (stereo)
Input 1 (mono)
Input 2 (mono)
Input 3–4 (stereo)
Input 3 (mono)
Input 4 (mono)

Hi Erik, I’m travelling at the moment so I cant show you any specific code. From memory, I think it went somewhat like this:

I first generate the list of possible inputs to present to the user (go through the list of WaveInputDevices and beware that some might be stereo - e.g. input 1-2 is just counted as one inputdevice).

When the user selects one, I find the corresponding WaveInputDevice, change the stereo pair config if needed (setStereoPair (IIRC)) and then attach it to the track as usual.

As I recall, I think you need to beware that when you change the stereo pair configuration of an input device, all input device instances will be remapped/reconstructed so you easily end up with a dangling pointer or a wrong index. So you will need to find the inputdevice again after you’ve changed its stereo configuration.

I hope this makes sense!
-------- Oprindelig besked --------

Many thanks!

you need to beware that when you change the stereo pair configuration of an input device, all input device instances will be remapped/reconstructed so you easily end up with a dangling pointer or a wrong index

Yeah, I hit that one yesterday… :smirk:

1 Like

At the moment input devices can’t both be mono and stereo at the same time, as @chrhaase points out, you have to choose a mono/mono or stereo pair configuration.

I think that should be ok though as I can’t see why you would want the same input as mono and stereo at the same time.