void ofxTLAudioTrack::draw(){
	
	if(!soundLoaded || player.getBuffer().size() == 0){
		ofPushStyle();
		ofSetColor(timeline->getColors().disabledColor);
		ofRectangle(bounds);
		ofPopStyle();
		return;
	}
		
	if(shouldRecomputePreview || viewIsDirty){
//		cout << "recomputing waveform for audio file " << getSoundfilePath() << endl;
		recomputePreview();
	}

    ofPushStyle();
    ofSetColor(timeline->getColors().keyColor);
    ofNoFill();
    
    for(int i = 0; i < previews.size(); i++){
        ofPushMatrix();
        ofTranslate( normalizedXtoScreenX(computedZoomBounds.min, zoomBounds) - normalizedXtoScreenX(zoomBounds.min, zoomBounds), 0, 0);
        ofScale(computedZoomBounds.span()/zoomBounds.span(), 1, 1);
        previews[i].draw();
        ofPopMatrix();
    }
    ofPopStyle();
	

    //fft draw in audioTrack
    if(bDrawFFT){
        ofPushStyle();
        
        //will refresh fft bins for other calls too
        vector<float>& bins = getFFT();
        float binWidth = bounds.width / bins.size();
        
        ofFill();
        ofSetColor(timeline->getColors().disabledColor, 120);
        for(int i = 0; i < bins.size(); i++){
            float height = MIN(bounds.height * bins[i], bounds.height);
            float y = bounds.y + bounds.height - height;
            ofRect(i*binWidth, y, binWidth, height);
        }
        
        ofPopStyle();
    }
}
Esempio n. 2
0
	FFTHolder(const Mat &im, const Point2f &absHint, const fftwf_plan &plan) {
		fft = getFFT(im.data, im.size(), plan);
	}