Last active
November 19, 2015 00:27
-
-
Save joshuajnoble/ee301884102257ce66f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define NUMBER_OF_FILE_PLAYERS 8 | |
#define NUMBER_OF_CHANNELS 8 | |
//-------------------------------------------------------------- | |
void ofApp::setup() | |
{ | |
// Example of how to set matrix mixer levels | |
Float32 levels[NUMBER_OF_FILE_PLAYERS * 2 + 1][NUMBER_OF_CHANNELS + 1] = {1.0}; | |
levels[0][NUMBER_OF_CHANNELS] = 0.8; | |
levels[1][NUMBER_OF_CHANNELS] = 0.8; | |
levels[2][NUMBER_OF_CHANNELS] = 0.8; | |
levels[3][NUMBER_OF_CHANNELS] = 0.8; | |
levels[4][NUMBER_OF_CHANNELS] = 0.8; | |
levels[5][NUMBER_OF_CHANNELS] = 0.8; | |
levels[6][NUMBER_OF_CHANNELS] = 0.8; | |
levels[7][NUMBER_OF_CHANNELS] = 0.8; | |
// levels[0][NUMBER_OF_CHANNELS] = 0.5; // set the input volume of file player 0 to 0.777 | |
// | |
// levels[0][5] = 0.999; // set the level of file player 0 in channel 5 to 0.999 | |
// levels[NUMBER_OF_FILE_PLAYERS * 2][5] = 0.5; // set the output volume of channel 5 to 0.888 | |
// | |
// levels[0][3] = 0.666; // set the level of file player 0 in channel 3 to 0.666 | |
// levels[NUMBER_OF_FILE_PLAYERS * 2][3] = 0.5; // set the output volume of channel 3 to 0.555 | |
// | |
levels[NUMBER_OF_FILE_PLAYERS * 2][NUMBER_OF_CHANNELS] = 1.0; // setting the global volume to 1 | |
// Note: I've been trying to get the file player to produce mono audio, to no avail. | |
// It seems to refuse any attempt to set the channel count to 1. So, we'll need to keep the "* 2" | |
// going on in the levels array. So, setting file player 3's level on channel 8 would be: | |
// levels[3 * 2][8] = 0.5; | |
mixer.connectTo(output); | |
// Setting the output unit and the matrix mixer to use the same stream format (in this case, 16 channel audio) | |
output.setDevice("M-Track Eight"); // <- should set the device before the stream format | |
AudioStreamBasicDescription ASBD = { | |
.mSampleRate = 44100, | |
.mFormatID = kAudioFormatLinearPCM, | |
.mFormatFlags = kAudioFormatFlagsAudioUnitCanonical, | |
.mChannelsPerFrame = 8, // <- change this to 24 in your case | |
.mFramesPerPacket = 1, | |
.mBitsPerChannel = sizeof(AudioUnitSampleType) * 8, | |
.mBytesPerPacket = sizeof(AudioUnitSampleType), | |
.mBytesPerFrame = sizeof(AudioUnitSampleType) | |
}; | |
// setting mixer to have 960 input busses, 1 output bus and use the | |
// 16 channel stream format on its output bus | |
mmixer.setChannelLayout(NUMBER_OF_FILE_PLAYERS, 1, NULL, &ASBD); | |
//for(size_t i = 0; i < filePlayers.size(); ++i) { | |
for(size_t i = 0; i < 8; ++i) { | |
filePlayers[i].setFile(ofToDataPath("entertainer.mp3")); | |
filePlayers[i].loop(); | |
filePlayers[i].connectTo(mixer, i); // connect file player 0 to mixer input bus 0, etc | |
// filePlayers[i].play(); | |
} | |
// this is 2 values for each filePlayer | |
levels[0][NUMBER_OF_CHANNELS] = 0.8; | |
levels[1][NUMBER_OF_CHANNELS] = 0.8; | |
levels[2][NUMBER_OF_CHANNELS] = 0.8; | |
levels[3][NUMBER_OF_CHANNELS] = 0.8; | |
levels[4][NUMBER_OF_CHANNELS] = 0.8; | |
levels[5][NUMBER_OF_CHANNELS] = 0.8; | |
levels[6][NUMBER_OF_CHANNELS] = 0.8; | |
levels[7][NUMBER_OF_CHANNELS] = 0.8; | |
levels[8][NUMBER_OF_CHANNELS] = 0.8; | |
levels[9][NUMBER_OF_CHANNELS] = 0.8; | |
output.start(); | |
ofSetVerticalSync(true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment