Hi,
I cannot seem to figure out how to specify the output channel I want an audio file to playback on. I've looked at using MixerAudioSource but it doesn't look like I can specify a channel number.
Can someone point me in the right direction?
Thanks!
EDIT:
This thread is getting quite long so I've removed some of my last edits.
It seems I'm still having trouble with this. With the following code I can map channels 1 and 2 but nothing higher. I'd like to have 24 separate channel outputs.
//create the players
for (int i = 0; i < 24; ++i){
MediaPlayer *player = new MediaPlayer();
// Connect the source player to the audio device.
deviceManager.addAudioCallback(player);
players.push_back(player);
}
String error = deviceManager.initialise(0, 24, nullptr, true);
if (error.isNotEmpty())
{
std::cout << error << std::endl;
}
//load files
for (int i = 0; i < players.size(); ++i){
String num = String(i + 1);
String file = "C:/Library/" + num + "_test.wav";
players[i]->setFile(file, i);
}
//lock to ensure sync
ScopedLock lock(deviceManager.getAudioCallbackLock());
//playback files
for (int i = 0; i < players.size(); ++i){
players[i]->playFromStart();
}
MediaPlayer looks like this:
MediaPlayer::MediaPlayer()
{
//CoInitialize(0);
// Configure the format manager to read common audio file types.
formatManager.registerBasicFormats();
// Connect the transport source to the remapping source
remappingSource = new ChannelRemappingAudioSource(&transportSource, true);
// Connect the remapping source to the source player.
sourcePlayer.setSource(remappingSource);
// Listen for changes
transportSource.addChangeListener(this);
}
void MediaPlayer::setFile(String filename, int channel)
{
File audioFile = File(filename);
// Create a reader from the selected file.
readerSource = new AudioFormatReaderSource(formatManager.createReaderFor(audioFile), true);
transportSource.setSource(readerSource);
remappingSource->clearAllMappings();
remappingSource->setOutputChannelMapping(0, channel);
}
