comparison util/matlab_midi/getTempoChanges.m @ 81:a30e8bd6d948

matlab_midi scripts
author Ivan <ivan.damnjanovic@eecs.qmul.ac.uk>
date Mon, 28 Mar 2011 17:35:01 +0100
parents
children
comparison
equal deleted inserted replaced
80:16df822019f1 81:a30e8bd6d948
1 function [tempos,tempos_time]=getTempoChanges(midi)
2 % [tempos,tempos_time]=getTempoChanges(midi)
3 %
4 % input: a midi struct from readmidi.m
5 % output:
6 % tempos = tempo values indexed by tempos_time
7 % tempos_time is in units of ticks
8 %
9 % should tempo changes effect across tracks? across channels?
10 %
11
12 % Copyright (c) 2009 Ken Schutte
13 % more info at: http://www.kenschutte.com/midi
14
15 tempos = [];
16 tempos_time = [];
17 for i=1:length(midi.track)
18 cumtime=0;
19 for j=1:length(midi.track(i).messages)
20 cumtime = cumtime+midi.track(i).messages(j).deltatime;
21 % if (strcmp(midi.track(i).messages(j).name,'Set Tempo'))
22 if (midi.track(i).messages(j).midimeta==0 && midi.track(i).messages(j).type==81)
23 tempos_time(end+1) = cumtime;
24 d = midi.track(i).messages(j).data;
25 tempos(end+1) = d(1)*16^4 + d(2)*16^2 + d(3);
26 end
27 end
28 end
29
30
31