void ofxTLInOut::mouseMoved(ofMouseEventArgs& args){ if(!bounds.inside(args.x,args.y)) return; hoveringIn = abs( normalizedXtoScreenX( timeline->getInOutRange().min ) - args.x) < 7; hoveringOut = abs( normalizedXtoScreenX( timeline->getInOutRange().max ) - args.x) < 7; }
void ofxTLAudioTrack::draw(){ if(!soundLoaded || player.getBuffer().size() == 0){ ofPushStyle(); ofSetColor(timeline->getColors().disabledColor); ofRectangle(bounds); ofPopStyle(); return; } if(shouldRecomputePreview || viewIsDirty){ 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(); }
void ofxTLInOut::mousePressed(ofMouseEventArgs& args){ if(!bounds.inside(args.x,args.y)) return; float distToIn = normalizedXtoScreenX( timeline->getInOutRange().min ) - args.x; if(abs(distToIn) < 7){ draggingIn = true; dragOffset = distToIn; } float distToOut = normalizedXtoScreenX( timeline->getInOutRange().max ) - args.x; if(!draggingIn && abs(distToOut) < 7){ draggingOut = true; dragOffset = distToOut; } if(!draggingIn && !draggingOut){ if(abs(distToOut) > abs(distToIn)){ draggingIn = true; dragOffset = 0; timeline->setInPointAtPercent(screenXtoNormalizedX(args.x)); } else{ draggingOut = true; dragOffset = 0; timeline->setOutPointAtPercent(screenXtoNormalizedX(args.x)); } } //cout << "dist to in " << abs(distToIn) << " out " << abs(distToOut) << " " << draggingIn << " " << draggingOut << endl; }
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(); if(getIsPlaying() || timeline->getIsPlaying()){ ofPushStyle(); //will refresh fft bins for other calls too vector<float>& bins = getFFTSpectrum(defaultFFTBins); float binWidth = bounds.width / bins.size(); //find max float averagebin = 0 ; for(int i = 0; i < bins.size(); i++){ maxBinReceived = MAX(maxBinReceived, bins[i]); averagebin += bins[i]; } averagebin /= bins.size(); ofFill(); ofSetColor(timeline->getColors().disabledColor, 120); for(int i = 0; i < bins.size(); i++){ float height = bounds.height * bins[i]/maxBinReceived; float y = bounds.y + bounds.height - height; ofRect(i*binWidth, y, binWidth, height); } ofPopStyle(); } }
void ofxTLZoomer::mousePressed(ofMouseEventArgs& args) { if(!enabled) return; minSelected = maxSelected = midSelected = focused = false; if (pointInScreenBounds(ofVec2f(args.x, args.y))) { mouseIsDown = true; focused = true; //did we click on the min-left handle? float minScreenX = normalizedXtoScreenX(currentViewRange.min); minGrabOffset = args.x - minScreenX; if(fabs(minScreenX - args.x) < 5){ minSelected = true; notifyZoomStarted(); return; } //did we click on the max-right handle? float maxScreenX = normalizedXtoScreenX(currentViewRange.max); maxGrabOffset = args.x - maxScreenX; if(fabs(maxScreenX - args.x) < 5){ maxSelected = true; notifyZoomStarted(); return; } //did we click in the middle? if(args.x > minScreenX && args.x < maxScreenX){ notifyZoomStarted(); midSelected = true; return; } //did we click to the right? if(args.x > maxScreenX){ maxSelected = true; maxGrabOffset = 0; currentViewRange.max = screenXtoNormalizedX(args.x); notifyZoomStarted(); return; } //did we click to the left? if(args.x < minScreenX){ minSelected = true; minGrabOffset = 0; currentViewRange.min = screenXtoNormalizedX(args.x); notifyZoomStarted(); return; } } }
void ofxTLInOut::draw(){ ofPushStyle(); ofRange screenXRange(bounds.getMinX(),bounds.getMaxX()); if(bounds.height > 2){ ofSetLineWidth(3); int inScreenX = normalizedXtoScreenX( timeline->getInOutRange().min ); int outScreenX = normalizedXtoScreenX( timeline->getInOutRange().max ); if(screenXRange.contains(inScreenX)){ if(hoveringIn){ ofSetColor(timeline->getColors().highlightColor); } else{ ofSetColor(timeline->getColors().keyColor); } ofLine(inScreenX, bounds.y, inScreenX, bounds.y+bounds.height); } if(screenXRange.contains(outScreenX)){ if(hoveringOut){ ofSetColor(timeline->getColors().highlightColor); } else{ ofSetColor(timeline->getColors().keyColor); } ofLine(outScreenX, bounds.y, outScreenX, bounds.y+bounds.height); } } //draw inout over the whole thing ofFill(); ofSetLineWidth(1); //draw in/out point float inPointX = ofClamp(normalizedXtoScreenX(timeline->getInOutRange().min), screenXRange.min, screenXRange.max); float outPointX = ofClamp(normalizedXtoScreenX(timeline->getInOutRange().max),screenXRange.min, screenXRange.max); if(bounds.x < inPointX){ ofSetColor(timeline->getColors().disabledColor,120); ofRect(bounds.x, pageRect.y, inPointX - bounds.x, pageRect.height); ofSetColor(timeline->getColors().highlightColor); ofLine(inPointX, pageRect.y, inPointX, pageRect.y+pageRect.height); } if(bounds.x+bounds.width > outPointX){ ofSetColor(timeline->getColors().disabledColor,120); ofRect(outPointX, pageRect.y, (bounds.x+bounds.width) - outPointX, pageRect.height); ofSetColor(timeline->getColors().highlightColor); ofLine(outPointX, pageRect.y, outPointX, pageRect.y+pageRect.height); } ofPopStyle(); }
void ofxTLZoomer::draw(){ ofPushStyle(); ofSetColor(timeline->getColors().textColor); //draw min float screenY = bounds.y + bounds.height/2.0; float minScreenX = normalizedXtoScreenX(currentViewRange.min, ofRange(0,1.0)); float maxScreenX = normalizedXtoScreenX(currentViewRange.max, ofRange(0,1.0)); if(midSelected){ ofSetLineWidth(2); } else{ ofSetLineWidth(1); } ofLine(minScreenX, screenY, maxScreenX, screenY); ofSetLineWidth(1); if(minSelected){ ofFill(); } else{ ofNoFill(); } ofCircle(minScreenX, screenY, 5); if(maxSelected){ ofFill(); } else{ ofNoFill(); } ofCircle(maxScreenX, screenY, 5); // cout << "zoomer bounds width " << bounds.width << endl; //draw playhead reference ofLine(bounds.x+bounds.width*timeline->getPercentComplete(), bounds.y, bounds.x+bounds.width*timeline->getPercentComplete(), bounds.y+bounds.height); //draw zoom region reference ofSetColor(timeline->getColors().backgroundColor); ofRange actualZoom = getViewRange(); ofRectangle zoomRegion = ofRectangle(bounds.x + bounds.width*actualZoom.min, bounds.y, bounds.width*actualZoom.span(),bounds.height); ofFill(); ofSetColor(timeline->getColors().keyColor, 50); ofRect(zoomRegion); ofPopStyle(); }
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(); } }
void ofxTLZoomer::draw(){ ofPushStyle(); ofEnableSmoothing(); ofNoFill(); if(focused){ ofSetColor(255, 200, 0); //focused outline color } else{ ofSetColor(150, 150, 0); //unfocused outline color } ofRect(bounds.x, bounds.y, bounds.width, bounds.height); //draw min float screenY = bounds.y + bounds.height/2.0; float minScreenX = normalizedXtoScreenX(currentViewRange.min); float maxScreenX = normalizedXtoScreenX(currentViewRange.max); if(midSelected){ ofSetLineWidth(2); } else{ ofSetLineWidth(1); } ofLine(minScreenX, screenY, maxScreenX, screenY); ofSetLineWidth(1); if(minSelected){ ofFill(); } else{ ofNoFill(); } ofCircle(minScreenX, screenY, 5); if(maxSelected){ ofFill(); } else{ ofNoFill(); } ofCircle(maxScreenX, screenY, 5); ofPopStyle(); }
Trigger* ofxTLTrigger::getTriggerForScreenPosition(float screenx, int& offset){ for(int i = 0; i < triggers.size(); i++){ offset = screenx - normalizedXtoScreenX(triggers[i].pt, zoomBounds); if (abs(offset) < 10) { return &triggers[i]; } } return NULL; }
void ofxTLInOut::mousePressed(ofMouseEventArgs& args) { //cout << "TLInout : mouse Press " << endl; if(!bounds.inside(args.x,args.y)) return; // void presentedModalContent(ofxTLTrack* modalTrack); // void dismissedModalContent(); // operate in modal content mode !! timeline->presentedModalContent(((ofxTLTrack*)this)); float distToIn = normalizedXtoScreenX( timeline->getInOutRange().min ) - args.x; if(abs(distToIn) < 7){ draggingIn = true; dragOffset = distToIn; } float distToOut = normalizedXtoScreenX( timeline->getInOutRange().max ) - args.x; if(!draggingIn && abs(distToOut) < 7){ draggingOut = true; dragOffset = distToOut; } if(!draggingIn && !draggingOut){ if(abs(distToOut) > abs(distToIn)){ draggingIn = true; dragOffset = 0; timeline->setInPointAtPercent(screenXtoNormalizedX(args.x)); } else{ draggingOut = true; dragOffset = 0; timeline->setOutPointAtPercent(screenXtoNormalizedX(args.x)); } } //cout << "dist to in " << abs(distToIn) << " out " << abs(distToOut) << " " << draggingIn << " " << draggingOut << endl; }
void ofxTLTrigger::draw(){ if(bounds.height < 2){ return; } ofPushStyle(); ofNoFill(); if(hover){ ofSetColor(timeline->getColors().highlightColor); } else if(focused){ ofSetColor(timeline->getColors().highlightColor); } else{ ofSetColor(timeline->getColors().outlineColor); } ofRect(bounds.x, bounds.y, bounds.width, bounds.height); ofFill(); ofSetLineWidth(5); for(int i = triggers.size()-1; i >= 0; i--){ int screenX = normalizedXtoScreenX(triggers[i].pt, zoomBounds); if(&triggers[i] == selectedTrigger){ ofSetColor(timeline->getColors().textColor); } else if(&triggers[i] == hoverTrigger){ ofSetColor(timeline->getColors().highlightColor); } else{ ofSetColor(timeline->getColors().keyColor); } int textHeight = bounds.y + 10 + ( (20*i) % int(bounds.height) ); ofLine(screenX, bounds.y, screenX, bounds.y+bounds.height); ofSetColor(timeline->getColors().backgroundColor); ofRect(screenX+2.5, textHeight-10, 100, 15); ofSetColor(timeline->getColors().textColor); if(enterText && &triggers[i] == selectedTrigger){ textfield.draw(screenX, textHeight-10); //-10 accounts for textfield's offset } else { string timeString = timeline->getIsFrameBased() ? ofToString(indexForScreenX(screenX)) : ofToString(triggers[i].pt * timeline->getDurationInSeconds()); ofDrawBitmapString(timeString+"|" +triggers[i].name, screenX+5, textHeight); } } ofPopStyle(); }
void ofxTLAudioTrack::mouseMoved(ofMouseEventArgs& args, long millis){ if (!bounds.inside(args.x, args.y)) return; for (vector<AlignMarker>::iterator m = markers.begin(); m != markers.end(); m++) { if (m->selected) { cout << "ms selected changin from " << m->ms << endl; m->ms = screenXToMillis(normalizedXtoScreenX(screenXtoNormalizedX(args.x, zoomBounds))); cout << " to: " << m->ms << endl; } } }
void ofxTLVideoDepthAlignmentScrubber::draw(){ if(!ready()){ ofPushStyle(); ofSetColor(255, 100, 0, 30); ofRect(bounds); ofPopStyle(); return; } ofPushStyle(); vector<VideoDepthPair>& alignedFrames = getPairs(); for(int i = 0; i < alignedFrames.size(); i++){ // long vid; // if(depthSequence->doFramesHaveTimestamps()){ // float videoPercent = alignedFrames[i].videoMillis / (videoSequence->getPlayer()->getDuration()*1000.0); // videoFrame = videoPercent * videoSequence->getPlayer()->getTotalNumFrames(); // } // else{ // videoFrame = alignedFrames[i].videoMillis; // } // int screenX = millisToScreenX( alignedFrames[i].videoMillis ); if(i == selectedPairIndex){ ofSetColor(timeline->getColors().textColor); } else{ ofSetColor(timeline->getColors().keyColor); } ofLine(screenX, bounds.y, screenX, bounds.y+bounds.height); ofDrawBitmapString("video: " + ofToString(ofxTimecode::timecodeForMillis(alignedFrames[i].videoMillis)), ofPoint(screenX+10, bounds.y+15)); ofDrawBitmapString("depth: " + ofToString(ofxTimecode::timecodeForMillis(alignedFrames[i].depthMillis)), ofPoint(screenX+10, bounds.y+35)); } ofSetColor(0, 125, 255); int selectedScreenX = normalizedXtoScreenX(selectedPercent); ofLine(selectedScreenX, bounds.y, selectedScreenX, bounds.y+bounds.height); ofDrawBitmapString("sel.video: " + ofToString(selectedVideoMillis), ofPoint(selectedScreenX+10, bounds.y+55)); ofDrawBitmapString("sel.depth: " + ofToString(selectedDepthMillis), ofPoint(selectedScreenX+10, bounds.y+75)); ofPopStyle(); }
void ofxTLInOut::draw(){ ofPushStyle(); ofSetColor(0); ofFill(); ofRect(bounds); ofRange screenXRange(bounds.getMinX(),bounds.getMaxX()); if(bounds.height > 2) { ofSetLineWidth(1); int inScreenX = normalizedXtoScreenX( timeline->getInOutRange().min ); int outScreenX = normalizedXtoScreenX( timeline->getInOutRange().max ); // rectangle all over the in-out ofSetColor(64); ofRect(inScreenX,bounds.y,outScreenX-inScreenX,bounds.height); if(inScreenX<0) inScreenX = 0; if(outScreenX>timeline->getWidth()) outScreenX = timeline->getWidth()-1; // if(screenXRange.contains(inScreenX)) // { // if(hoveringIn){ // ofSetColor(timeline->getColors().highlightColor); // } // else{ //// ofSetColor(timeline->getColors().keyColor); // ofSetColor(255); // // } ofSetColor(220); ofRect(inScreenX,bounds.y,10,bounds.height); // ofLine(inScreenX, bounds.y, inScreenX, bounds.y+bounds.height); // } // if(screenXRange.contains(outScreenX)) // { // if(hoveringOut){ // ofSetColor(timeline->getColors().highlightColor); // } // else{ // //// ofSetColor(timeline->getColors().keyColor); // ofSetColor(255); // } ofSetColor(220); ofRect(outScreenX,bounds.y,-10,bounds.height); // // ofLine(outScreenX, bounds.y, outScreenX, bounds.y+bounds.height); // } } //draw inout over the whole thing ofFill(); ofSetLineWidth(1); //draw in/out point float inPointX = ofClamp(normalizedXtoScreenX(timeline->getInOutRange().min), screenXRange.min, screenXRange.max); float outPointX = ofClamp(normalizedXtoScreenX(timeline->getInOutRange().max),screenXRange.min, screenXRange.max); if(bounds.x < inPointX){ // ofSetColor(timeline->getColors().disabledColor,60); ofSetColor(0,0,0,64); ofRect(bounds.x, pageRect.y, inPointX - bounds.x, pageRect.height); ofSetColor(timeline->getColors().highlightColor); ofLine(inPointX, pageRect.y, inPointX, pageRect.y+pageRect.height); } if(bounds.x+bounds.width > outPointX){ // ofSetColor(timeline->getColors().disabledColor,60); ofSetColor(0,0,0,64); ofRect(outPointX, pageRect.y, (bounds.x+bounds.width) - outPointX, pageRect.height); ofSetColor(timeline->getColors().highlightColor); ofLine(outPointX, pageRect.y, outPointX, pageRect.y+pageRect.height); } ofPopStyle(); }
void ofxTLTicker::draw(){ ofPushStyle(); int textH, textW; string text; if(timeline->getIsFrameBased()){ int curStartFrame = ofMap(zoomBounds.min, 0, 1.0, 0, timeline->getDurationInFrames()); int curEndFrame = ofMap(zoomBounds.max, 0, 1.0, 0, timeline->getDurationInFrames()); int framesInView = curEndFrame-curStartFrame; float framesPerPixel = framesInView / bounds.width; int frameStepSize = 1; //TODO make adaptive if we are way zoomed in don't draw so many //draw ticker marks for(int i = curStartFrame; i <= curEndFrame; i++){ float x = ofMap(i, curStartFrame, curEndFrame, totalDrawRect.x, totalDrawRect.x+totalDrawRect.width, true); ofSetColor(200, 180, 40); float heightMultiplier = 0.0; if(i % 10 == 0){ ofSetLineWidth(3); heightMultiplier = .5; } else { ofSetLineWidth(1); heightMultiplier = .75; } ofLine(x, bounds.y+bounds.height*heightMultiplier, x, bounds.y+bounds.height); } } //Time based else { //draw tickers with time float startTime = zoomBounds.min * timeline->getDurationInSeconds(); float endTime = zoomBounds.max * timeline->getDurationInSeconds(); float durationInview = endTime-startTime; float secondsPerPixel = durationInview / bounds.width; //draw ticker marks ofSetLineWidth(1); ofSetColor(200, 180, 40); float heightMultiplier = .75; for(float i = startTime; i <= endTime; i += secondsPerPixel*5){ //float x = ofMap(i, curStartFrame, curEndFrame, totalDrawRect.x, totalDrawRect.x+totalDrawRect.width, true); float x = screenXForTime(i); ofLine(x, bounds.y+bounds.height*heightMultiplier, x, bounds.y+bounds.height); } //draw regular increments int bigTickStep; if(durationInview < 1){ //draw big tick every 100 millis bigTickStep = .1; } else if(durationInview < 60){ // draw big tick every second bigTickStep = 1; } else { bigTickStep = 60; } ofSetLineWidth(3); heightMultiplier = .5; for(float i = startTime-fmod(startTime, bigTickStep); i <= endTime; i+=bigTickStep){ float x = screenXForTime(i); ofLine(x, bounds.y+bounds.height*heightMultiplier, x, bounds.y+bounds.height); } if(drawBPMGrid){ updateBPMPoints(); ofPushStyle(); ofSetColor(255, 255, 255, 50); for(int i = 0; i < bpmScreenPoints.size(); i++){ ofSetLineWidth(bpmScreenPoints[i].weight); ofLine(bpmScreenPoints[i].screenX, totalDrawRect.y, bpmScreenPoints[i].screenX, totalDrawRect.y+totalDrawRect.height-20); } ofPopStyle(); } } //highlite current mouse position if(hover){ //draw background rect ofSetColor(timeline->getColors().backgroundColor); if (timeline->getIsFrameBased()) { text = ofToString(indexForScreenX(ofGetMouseX())); } else{ //text = ofToString(); text = timeline->formatTime(timeForScreenX(ofGetMouseX())); } textH = 10; textW = (text.size()+1)*7; ofRect(ofGetMouseX(), bounds.y+textH, textW, textH); //draw playhead line ofSetColor(timeline->getColors().textColor); ofDrawBitmapString(text, ofGetMouseX()+5, bounds.y+textH*2); ofSetColor(timeline->getColors().highlightColor); ofSetLineWidth(1); ofLine(ofGetMouseX(), totalDrawRect.y, ofGetMouseX(), totalDrawRect.y+totalDrawRect.height); } //draw current frame int currentFrameX; if (timeline->getIsFrameBased()) { text = ofToString(timeline->getCurrentFrame()); currentFrameX = screenXForIndex(timeline->getCurrentFrame()); } else{ //text = ofToString(); text = timeline->formatTime(timeline->getCurrentTime()); currentFrameX = screenXForTime(timeline->getCurrentTime()); } textH = 10; textW = (text.size()+1)*7; ofSetColor(timeline->getColors().backgroundColor); ofRect(currentFrameX, bounds.y, textW, textH); ofSetColor(timeline->getColors().textColor); ofDrawBitmapString(text, currentFrameX+5, bounds.y+textH); if(timeline->getIsPlaying()){ ofSetColor(timeline->getColors().keyColor); } else{ ofSetColor(timeline->getColors().outlineColor); } //draw playhead line ofSetLineWidth(1); ofLine(currentFrameX, totalDrawRect.y, currentFrameX, totalDrawRect.y+totalDrawRect.height); //draw in/out point float inPointX = normalizedXtoScreenX(timeline->getInOutRange().min, zoomBounds); float outPointX = normalizedXtoScreenX(timeline->getInOutRange().max, zoomBounds); if(bounds.x < inPointX){ ofSetColor(timeline->getColors().disabledColor,120); ofRect(bounds.x, bounds.y, inPointX - bounds.x, totalDrawRect.height); ofSetColor(timeline->getColors().highlightColor); ofLine(inPointX, bounds.y, inPointX, bounds.y+totalDrawRect.height); } if(bounds.x+bounds.width > outPointX){ ofSetColor(timeline->getColors().disabledColor,120); ofRect(outPointX, bounds.y, (bounds.x+bounds.width) - outPointX, totalDrawRect.height); ofSetColor(timeline->getColors().highlightColor); ofLine(outPointX, bounds.y, outPointX, bounds.y+totalDrawRect.height); } //draw bounds ofNoFill(); ofSetColor(200, 180, 40); ofRect(bounds); ofPopStyle(); }
void ofxTLAudioTrack::draw(){ if(!soundLoaded || player.getBuffer().size() == 0){ ofPushStyle(); ofSetColor(timeline->getColors().disabledColor); ofRectangle(bounds); ofPopStyle(); return; } if(shouldRecomputePreview || viewIsDirty){ recomputePreview(); } //cout << "ofxTLAudioTrack::draw" << endl; ofSetColor(255, 255, 255, 205); ofFill(); ofRect(bounds); ofPushStyle(); //ofSetColor(timeline->getColors().keyColor); ofSetColor(0, 0 , 0, 255); 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(); if(getIsPlaying() || timeline->getIsPlaying()){ ofPushStyle(); //will refresh fft bins for other calls too vector<float>& bins = getFFTSpectrum(defaultFFTBins); float binWidth = bounds.width / bins.size(); //find max float averagebin = 0 ; for(int i = 0; i < bins.size(); i++){ maxBinReceived = MAX(maxBinReceived, bins[i]); averagebin += bins[i]; } averagebin /= bins.size(); ofFill(); ofSetColor(timeline->getColors().disabledColor, 120); for(int i = 0; i < bins.size(); i++){ float height = bounds.height * bins[i]/maxBinReceived; float y = bounds.y + bounds.height - height; ofRect(bounds.x + i*binWidth, y, binWidth, height); } ofPopStyle(); } // playhead ofPushStyle(); ofSetColor(0, 0, 0, 255); float x = normalizedXtoScreenX( oldpos, zoomBounds); ofLine(x, bounds.y, x, bounds.y + bounds.height); ofSetLineWidth(3); ofPopStyle(); /* float pos = player.getPosition(); if (pos) { ofxTLZoomer2D *zoom = (ofxTLZoomer2D*)timeline->getZoomer(); ofRange z = zoom->getViewRange(); ofRange oldz = z; float c = z.center(); float d = pos - c; z.min = ofClamp(z.min + d, 0, 1); z.max = ofClamp(z.max + d, 0, 1); if (z.min == .0 && z.span() < oldz.span()) z.max = oldz.max - oldz.min; if (z.max == 1. && z.span() < oldz.span()) z.min = z.max - oldz.max + oldz.min; }*/ // draw markers: for (vector<AlignMarker>::iterator m = markers.begin(); m != markers.end(); m++) { float xn = screenXtoNormalizedX(millisToScreenX(m->ms)); if (zoomBounds.contains(xn)) { float x = timeline->normalizedXtoScreenX(xn, zoomBounds); if (m->selected) ofSetColor(255, 0, 0, 255); else ofSetColor(0, 0, 0, 255); ofLine(x, bounds.y, x, bounds.y+bounds.height); m->rect = ofRectangle(x - 5, bounds.y + bounds.height - 12, 10, 10); ofSetColor(10, 0, 200, 100); ofFill(); ofRect(m->rect); //cout << "m:" << m->ms << endl; ofSetColor(0, 0, 0, 255); timeline->getFont().drawString(ofToString(m->ms), x+1, bounds.y + 30); } } }