ofxThreadedMidiPlayer icon indicating copy to clipboard operation
ofxThreadedMidiPlayer copied to clipboard

playback speed

Open s373 opened this issue 7 years ago • 1 comments

great addon! works great under linux/oF0.9.8. stop is not working so well, could not start after stop. any ideas how to implement playback speed? i had a look at jdksmidi::MIDISequencer.setState, but was not obvious how to implement a changeTempo(float bpm); thanks

s373 avatar Oct 23 '17 12:10 s373

this seems to be working nice;)

	float getBpm(){
		float bpm = -1.0f;
		if(sequencer){
			MIDISequencerState *state = sequencer->GetState();
			if(state)
			for(size_t i=0; i<state->num_tracks; i++){
				if(state->track_state[i]){
					bpm = state->track_state[i]->tempobpm;
					cout << " tempo " << i << " "<< bpm << endl;
				}
			}
		}
		return bpm;
	}

	bool setBpm(float bpm){
		if(!sequencer){
			return false;
		}

		MIDISequencerState *state = sequencer->GetState();
		if(state)
		for(size_t i=0; i<state->num_tracks; i++){
			if(state->track_state[i]){
				state->track_state[i]->tempobpm = bpm;
				cout << " tempo " << i << " "<< bpm << endl;
			}
		}
		return true;
	}

s373 avatar Oct 23 '17 13:10 s373