annotate util/matlab_midi/getTempoChanges.m @ 203:f3b6ddd2f04f luisf_dev

checks if the variable SMALL_path exists, and exits otherwise.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Tue, 20 Mar 2012 15:52:22 +0000
parents a30e8bd6d948
children
rev   line source
ivan@81 1 function [tempos,tempos_time]=getTempoChanges(midi)
ivan@81 2 % [tempos,tempos_time]=getTempoChanges(midi)
ivan@81 3 %
ivan@81 4 % input: a midi struct from readmidi.m
ivan@81 5 % output:
ivan@81 6 % tempos = tempo values indexed by tempos_time
ivan@81 7 % tempos_time is in units of ticks
ivan@81 8 %
ivan@81 9 % should tempo changes effect across tracks? across channels?
ivan@81 10 %
ivan@81 11
ivan@81 12 % Copyright (c) 2009 Ken Schutte
ivan@81 13 % more info at: http://www.kenschutte.com/midi
ivan@81 14
ivan@81 15 tempos = [];
ivan@81 16 tempos_time = [];
ivan@81 17 for i=1:length(midi.track)
ivan@81 18 cumtime=0;
ivan@81 19 for j=1:length(midi.track(i).messages)
ivan@81 20 cumtime = cumtime+midi.track(i).messages(j).deltatime;
ivan@81 21 % if (strcmp(midi.track(i).messages(j).name,'Set Tempo'))
ivan@81 22 if (midi.track(i).messages(j).midimeta==0 && midi.track(i).messages(j).type==81)
ivan@81 23 tempos_time(end+1) = cumtime;
ivan@81 24 d = midi.track(i).messages(j).data;
ivan@81 25 tempos(end+1) = d(1)*16^4 + d(2)*16^2 + d(3);
ivan@81 26 end
ivan@81 27 end
ivan@81 28 end
ivan@81 29
ivan@81 30
ivan@81 31