Esempio n. 1
0
//--------------------------------------------------------------
void testApp::setup(){

	ofSetFrameRate(60);
	ofSetVerticalSync(true);
    ofEnableAlphaBlending();
	
	ofBackground(90, 90, 90);
    
 
	
    startTime = ofGetElapsedTimeMillis(); // set the current time

    bpm = 20; // start at 120 bpm (use '+' and '-' to increase/decrease bpm's in multiples of 10) - see onKeyPressed()
    
    
    // set the time interval between ticks - calculate how many miliseconds we need to wait to move to the next step based on bpm
    intervalTime = (60.0/bpm/4)*1000;
    bTick = false;                          // this variable will be true when the tick happens - pulse -  super fast so we can barely see it
    nTicks = 0;                             // number of Ticks since we started
    
    
    // load the sound file and set its looping mode to false
    beat.loadSound("BT7AADA.WAV"); 
    beat.setLoop(false);

    // setting up the stpe buttons
    for(int i = 0; i< N_STEPS; i++){
        ofRectangle tempRectangle(100+(60*i), 250, 50, 50);
        myStep[i].setup(tempRectangle);
        
    }
    

}
Esempio n. 2
0
//------------------------------------------------------------------------------
void ofApp::draw()
{
    ofBackground(0);
    
    for(int i = 0; i < buttons.size(); i++)
    {
        ofFill();
        if(buttonState[i])
        {
            ofSetColor(onColors[i]);
        }
        else
        {
            ofSetColor(offColors[i]);
        }

        // draw the rectangle
        ofRect(buttons[i]);

        // record the virtual button state
        bool isOver = buttons[i].inside(ofGetMouseX(),ofGetMouseY());

        // draw a little highlight bar if the mouse is over
        if(isOver)
        {
            // make a new highlight bar rectangle, using the dimensions
            // of the button we are working with.
            ofRectangle tempRectangle(buttons[i].x,
                                      buttons[i].y+buttons[i].height+10,
                                      buttons[i].width,
                                      -10);
            // color and fill the highlight bar
            ofSetColor(255,127);
            ofFill();
            ofRect(tempRectangle);
        }
    }
}
Esempio n. 3
0
//--------------------------------------------------------------
void testApp::setup(){

	ofSetFrameRate(60);
	ofSetVerticalSync(true);
    ofEnableAlphaBlending();
	ofBackground(100); //set background color
    atimer = ofGetElapsedTimeMillis(); // set the current time
    bpm = 60; // start at 120 bpm (use '+' and '-' to increase/decrease bpm's in multiples of 10)
    // set the time interval between ticks - calculate how many miliseconds we need to wait to move to the next step based on bpm
    intervalTime = (60.0/bpm/4)*1000;
    nTicks = 2;
    currentChange = 0;

    // SAMPLE FILES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // yikes we should load these from the dir next time
    strarray = {
        "1.wav", "2.wav", "3.wav", "4.wav", "5.wav",
        "6.wav", "7.wav", "8.wav", "9.wav", "10.wav",
        "11.wav", "12.wav", "13.wav", "14.wav", "15.wav",
        "16.wav", "17.wav", "18.wav", "19.wav", "20.wav",
        "21.wav", "22.wav", "23.wav", "24.wav", "25.wav",
        "26.wav", "27.wav", "28.wav", "29.wav", "30.wav",
        "31.wav", "32.wav", "33.wav", "34.wav", "35.wav",
        "36.wav", "37.wav", "38.wav", "39.wav", "40.wav",
        "41.wav", "42.wav", "43.wav", "44.wav", "45.wav",
        "46.wav", "47.wav", "48.wav", "49.wav", "50.wav",
        "51.wav", "52.wav", "53.wav", "54.wav", "55.wav",
        "56.wav", "57.wav", "58.wav", "59.wav", "60.wav",
        "61.wav", "62.wav", "63.wav", "64.wav", "65.wav",
        "66.wav", "67.wav", "68.wav"
        };

    sampleVec = vector<string>(strarray, strarray + NUMSAMPLES);//making a vector of strings
    int jump = 0;
    for(int i=0;i<sampleVec.size();i++){
        if((i%18==0)&&(i!=0)){
            jump++;
        }
    sampleList[i].set(50*(i%18),50*jump,50,50);
    }

    //load current samples into beat array
    for(int jj=0;jj<GRIDY;jj++){
        beatArray[jj].loadSound(sampleVec[jj]); //load first samples
        beatArray[jj].setLoop(false);
    }
    //load ALL samples intop beat array full
    for(int jj=0;jj<NUMSAMPLES;jj++){
        beatArrayFull[jj].loadSound(sampleVec[jj]); //load all samples
        beatArrayFull[jj].setLoop(false);
    }

    selectSampleMode = false; //start off in play mode

    //calculate width and height of matrix based of X/Y input (GRIDX/GRIDY)
    wid = ofGetWidth()/(GRIDX+2);
    hei = (ofGetHeight()-30)/GRIDY;

    //create sample select rectangles
    for(int jj=0;jj<GRIDY;jj++){
        loadClipButton[jj].set(wid,hei*jj,wid,hei);
    }

    //create volume select rectangles
    for(int jj=0;jj<GRIDY;jj++){
        volumeSlider[jj].set(0,hei*jj,wid,hei);
        volumeSliderVal[jj] = 0.7;
    }

    //create matrix
    for(int jj=0;jj<GRIDY;jj++){
        for(int ii=0;ii<GRIDX;ii++){
            ofRectangle tempRectangle((wid*ii)+(wid*2),hei*jj,wid,hei);
            ssArray[jj][ii].setup(tempRectangle);
        }
    }

}
Esempio n. 4
0
//--------------------------------------------------------------
void testApp::draw(){

    if(selectSampleMode==true){ //this is the mode where you select your samples
        for(int i=0;i<sampleVec.size();i++){
            if(sampleListHover[i]==true){ //hover effect
                ofFill();
                ofSetColor(35,35,35);
            }
            else{
                ofFill();
                ofSetColor(55, 55, 55);
            }
            ofRect(sampleList[i]);
        }
        for(int i=0;i<sampleVec.size();i++){ //redraw outlines, annoying
            ofNoFill();
            ofSetColor(190,190,190);
            ofRect(sampleList[i]);
        }
    }
    else{ //this is the playback mode
        //draw matrix
        for(int jj=0;jj<GRIDY;jj++){
            for(int ii=0;ii<GRIDX;ii++){
                ofRectangle tempRectangle((wid*ii)+wid,hei*jj,wid,hei);
                ssArray[jj][ii].draw();
            }
        }
        //draw sample select with hover effects
        for(int jj=0;jj<GRIDY;jj++){
            if(loadClipHover[jj]==true){
                ofFill();
                ofSetColor(35,35,35);
            }
            else{
                ofFill();
                ofSetColor(55, 55, 55);
            }
            ofRect(loadClipButton[jj]);
        }
        //draw volume slider
        for(int jj=0;jj<GRIDY;jj++){
            ofFill();
            ofSetColor(55, 55, 55);
            ofRect(volumeSlider[jj]);
        }
        for(int jj=0;jj<GRIDY;jj++){//redraw outlines, annoying
            ofSetColor(25,25,25);
            float yv = (jj*hei) + (hei - (volumeSliderVal[jj]*hei));
            ofRect(0,yv,wid,4);
        }
        for(int jj=0;jj<GRIDY;jj++){//redraw outlines, annoying
            ofNoFill();
            ofSetColor(190,190,190);
            ofRect(0,hei*jj,wid,hei);
            ofRect(wid,hei*jj,wid,hei);
        }

        ofFill();
        ofSetColor(160, 160, 160, 150);
        ofRect(wid*nTicks, 0, wid, ofGetHeight()-30);

    }

    //footer text and instructions
    ofFill();
    ofSetColor(30,30,30);
    ofRect(0, ofGetHeight()-29, ofGetWidth(), 29);
    ofSetColor(200, 200, 200);
    if(selectSampleMode==true){
        ofDrawBitmapString("Left click to sample, right click to replace.", 10, ofGetHeight()-10);
    }
    else{
        ofDrawBitmapString("[+/-] to adjust BPM   [c] to clear", 10, ofGetHeight()-10);
    }

}