MultiChannel Problems

Ok, let’s make it easy…
I have my MyPosAudioSource (that works), an AudioTransportSource called transportSource and the AudioSourcePlayer called audioSourcePlayer. In the constructor of my class I do this:

...
transportSource.addChangeListener (this);
...
audioSourcePlayer.setSource (&transportSource);
...
transportSource.setSource ( myPos , 32768, 0);   
...

where myPos is a pointer to an instance of MyPosAudioSource.
I do play audio, I can stop, play again, set the start position etc. Everything seems to be all right.
I have also an AudioDeviceSelectorComponent and I can choose other audio device. All good. I can play with my asio device as before.
BUT, if i try to open, with the selectorComponent, a number of channel not equals to 2 the info.buffer->getNumChannels() in the getNextAudioBlock(…) of myPos returns always 2.

Am I clear?

However, if I do:

...
transportSource.addChangeListener (this);
...
transportSource.setSource ( myPos , 32768, 0);   
...
audioSourcePlayer.setSource (&myPos);   <------------------------- 
...

I cannot play, stop anymore (I think becouse the source of the audioSourcePlayer is no more the transportSource) but (wow) the info.buffer->getNumChannels() in the getNextAudioBlock(…) of myPos returns the number of channels that I choose in the selectorComponent.

How can I combine transportSource and myPos to select the right channel number and control playing, stopping etc…???

So what you mean is that the audiotransportsource doesn’t seem to handle more than 2 channels?

Have you stepped through the getNextAudioBlock method to track down where this limitation is getting applied? Because it looks to me like it doesn’t affect the number of channels at all.

so, what I mean is this or maybe that MyPositionableAudioSource doesn’t inherit the information about the channel number from audiotransportsource.

But I don’t know, since i was not able to debug the getNextAudioBlock(…) of the AudioTransportSource and so I don’t know if it has a buffer with the rightr channel number.

Tell me, is right that i suppose MyPositionableAudioSource should inherit the number of channel from AudioTransportSource???
Or, maybe, there’ll be a better solution???

thanks

I debugged the getNextAudioBlock method in the AudioTransportSource class… and the info.buffer->getNumChannels() returns the right channel number…
So, I think the problem is that, i don’t know how, MyPos has to change the info.buffer channel number in order to do things right. It has to reflects the changes made in his “container” (i use container to mean that i did: transportSource->setSource(myPos);).

Let me know…

what information? (And when you say “channel number”, I presume you actually mean “number of channels”, and not the index of a channel?)

Yes Jules, forgive me for my english…
I mean the number of channels.

Now, I work debugging all the stuff and I find something strange:

Situation 1)

...
transportSource2.setSource ( myPos ,
                             32768, // tells it to buffer this many samples ahead
                             0);
...

the info.buffer->getNumChannels in the AudioTransportSource::getNextAudioBlock(…) returns the right number of channels. But info.buffer->getNumChannels in the MyPositionable::getNextAudioBlock(…) returns always 2.

Now, if I do (Situation 2):

...
transportSource2.setSource ( myPos ,
                              0, // <------------no samples ahead buffering
                              0);
...

both return the right number of channel.

I don’t think it’s right… Why does it go wrong if i change the number of samples to buffer???

Ok, we’re finally getting somewhere here…

What this all comes down to is that the bufferingaudiosource only buffers 2 channels of its input source.

It’s actually quite tricky to change this because it doesn’t know how many channels it needs until it’s actually playing, and it might start buffering before that. I’ll have to have a think about it…

I hope I was useful with this topic.
Jules, maybe this is not a great question but what’s the main difference using buffered or not-buffered source (like the 2 situation above)?

When I have to choose buffered or when it’s supposed to use not-buffered?
I’m a littel bit confused…

thanks

Read the comments for BufferingAudioSource. It buffers its source on a background thread, so is good for reading from disk.

If you’re running in an audio interrupt, you wouldn’t want to hit the disks to read a file 100 times a second, so the buffer acts as an intermediary.

Since I’m reading audio data from memory… now I use no buffering and all seems to be ok… thanks jules

However, let us know if you find a solution to make it works with bufferingaudiosource to.

Bye