AudioTransportSource - resmapling, numChannels?


#1

Can we please add a parameter to AudioTransportSource::setSource so it can create a resampler with more than two channels? Currently, it creates a resampling audio source with the default two channels only.

void AudioTransportSource::setSource (PositionableAudioSource* const newSource, int readAheadBufferSize_, double sourceSampleRateToCorrectFor, int numChannels = 2)

if (sourceSampleRateToCorrectFor != 0) newMasterSource = newResamplerSource = new ResamplingAudioSource (newPositionableSource, false, numChannels);

Bruce


#2

Hmm, maybe a better solution would be to make the ResamplingAudioSource smarter about using the appropriate number of channels for its input source…?


#3

Hate to say it but maybe we want AudioSource::prepareToPlay() to take a numChannels? Because it is a bit of a hack to make channel adjustments in getNextAudioBlock() based on what is in the AudioSourceChannelInfo::buffer.


#4

PrepareToPlay wouldn’t work for me, since the fomat changes sometimes (new files being opened). I looked at how it might be ‘smart’ but the source doesn’t seem to know or care about channels.

It seems like an obvious place to make that change, to me. The block idea would be more flexible, but at the cost of complexity and possibly speed, to cover some really rare cases (someone changing format without changing rate or anything else?).

It looks a bit odd, but since that’s where the resampler is created, it makes sense to me.

Bruce


#5

Yes, fair point. I guess your original suggestion’s probably the best option.


#6

I can’t quite tell: is MixerAudioSource hard-coded to 2 channels as well?

It sets up with 2 channels, but then maybe it re-sizes based on how many the callback asks for?

Bruce


#7

Ok, some exploring. First I’ve learned some things about AudioDeviceManagers. It seems that if you ask for more channels (output, in this case) than the device has, the dialog looks fine, and you can test with as many channels as you assign, but when you come out, it counts as a fail, and your selected channels don’t get expressed into the XML state.

With that fixed, I believe I have a 12 channel audio device setup (Linux, Jack, FFADO firewire box). I can test it fine from an audio device setup component.

I’ve gone through:

AudioSourcePlayer
AudioMixerSource
BufferingAudioSource

All appeared to be hard-coded for 2 channels - couldn’t tell which would auto-switch. I added a constructor param for AudioMixerSource, and changed the others to 32.

Am I making this too hard somehow? Looking in the wrong place? Or is stereo so much the norm I’m out on the ice here?

Bruce


#8

OK, what I think I’m seeing is that AudioTransportSource creates Resampling and Buffering Audio Sources. In the change discussed in this thread, Resampling got changed to use a numChannels parameter, somehow I missed that Buffering needs it too.

Please can you change BufferingAudioSource to have: const int numChannels; and construct with int numChannels_ = 2, like Resampling. Then there’s a couple of hardcoded '2’s. I hope that every other audio source uses the callback buffers and therefore scales?

But I would still love some confirmation that multichannel works using the full AudioSource chain?

Bruce


#9

Yes, there’s a lot of hard-coded 2s in the BufferingAudioSource… sorry, that’s not like me at all! Will tidy that up, ta.


#10

Great, thanks. I made that change myself, and I’m rocking 8 channels now.

It’s the AudioTransportSource setSource that needs to set it, as above.

Bruce