objective c - How to change MIDI TEMPO on the fly? [CoreMIDI] iOS -
i've got musictrack midi notes set musicsequence, ¡s being played musicplayer. problem comes when tried adjust tempo using;
musictracknewextendedtempoevent(musictrack, 0.0, newbpm);
apparently should change tempoevent in musictrack being played, doesn't. idea why happening?
you first have remove tempo events tempo track.
static void removetempoevents(musictrack tempotrack){ musiceventiterator tempiter; newmusiceventiterator(tempotrack, &tempiter); boolean hasevent; musiceventiteratorhascurrentevent(tempiter, &hasevent); while (hasevent) { musictimestamp stamp; musiceventtype type; const void *data = null; uint32 sizedata; musiceventiteratorgeteventinfo(tempiter, &stamp, &type, &data, &sizedata); if (type == kmusiceventtype_extendedtempo){ musiceventiteratordeleteevent(tempiter); musiceventiteratorhascurrentevent(tempiter, &hasevent); } else{ musiceventiteratornextevent(tempiter); musiceventiteratorhascurrentevent(tempiter, &hasevent); } } disposemusiceventiterator(tempiter); } static void settempo(musicsequence sequence,float64 tempo){ musictrack tempotrack; musicsequencegettempotrack(sequence ,&tempotrack); removetempoevents(tempotrack); musictracknewextendedtempoevent(tempotrack,0, tempo); }
Comments
Post a Comment