Skip to content

Instantly share code, notes, and snippets.

@unohee
Last active May 3, 2016 01:25
Show Gist options
  • Save unohee/f6962201ff52516c0c2d20da3873615f to your computer and use it in GitHub Desktop.
Save unohee/f6962201ff52516c0c2d20da3873615f to your computer and use it in GitHub Desktop.
int InfinityMatrix::play(bool trigger, bool random, int mode){
bool output = false;
//instead of calling elements by rows & cols. this gives serialistic method to play over matrices.
//1. Prime (original sequence)
//2. Retrograde (reversed sequence)
//3. Inverted Prime (vertically inversed Prime sequence)
//4. Inverted Retrograde (vertically inverssed Retrograde)
//--------
//Get size of 2d array first.
// int w = matrix.size(); //size of column
// int h = matrix[matrix.size()-1].size(); //and its row.
// int numElements = w * h;
if(!random){
//Serialistic method to play note
if(trigger==true){
//Prime scale (plays left to right)
playHead ++;
//playhead iteration
if(playHead == matrixW){
playHead = 0; //reset playHead
level ++; //then this points next row.
}
if (output) {
//check outputs
cout<<"Played Note : "<<noteOut<<endl;
cout<<"PlayHead : "<<playHead<<endl;
cout<<"Level : " << level<<endl;
}
noteOut = returnVal(playHead, level);
return noteOut;
if(mode ==1){
//PRIME Scale mode.
if(playHead == matrixW && level == matrixW){
//when it reaches at the end..
//case 1 : looping
playHead = 0;
level = 0;
}
}
}else{
return 0;
}
}else{
if(trigger){
noteOut=returnVal(ofRandom(0,matrixW),ofRandom(0,matrixH));
}
return noteOut;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment