Mercurial > hg > beatroot
comparison at/ofai/music/util/MIDI2Matlab.java @ 2:4c3f5bc01c97
* Import BeatRoot v0.5.7
author | Chris Cannam |
---|---|
date | Fri, 08 Oct 2010 16:11:06 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1:4de8d7f01bd4 | 2:4c3f5bc01c97 |
---|---|
1 /* | |
2 Copyright (C) 2001, 2006 by Simon Dixon | |
3 | |
4 This program is free software; you can redistribute it and/or modify | |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 2 of the License, or | |
7 (at your option) any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License along | |
15 with this program (the file gpl.txt); if not, download it from | |
16 http://www.gnu.org/licenses/gpl.txt or write to the | |
17 Free Software Foundation, Inc., | |
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
19 */ | |
20 | |
21 package at.ofai.music.util; | |
22 | |
23 import java.util.ListIterator; | |
24 | |
25 class MIDI2Matlab { | |
26 | |
27 public static void main(String[] args) { | |
28 EventList e = EventList.readMidiFile(args[0]); | |
29 Event[] events = e.toArray(0x90); | |
30 int len = events.length; | |
31 double[] pitch = new double[len]; | |
32 double[] vel = new double[len]; | |
33 double[] onset = new double[len]; | |
34 double[] offset = new double[len]; | |
35 for (int i=0; i<len; i++) { | |
36 pitch[i] = events[i].midiPitch; | |
37 vel[i] = events[i].midiVelocity; | |
38 onset[i] = events[i].keyDown; | |
39 offset[i] = events[i].keyUp; | |
40 } | |
41 Format.init(1,5,3,false); | |
42 System.out.println("notes = zeros(" + len + ",4);"); | |
43 Format.matlab(onset, "notes(:,1)", System.out); | |
44 Format.matlab(offset, "notes(:,2)", System.out); | |
45 Format.matlab(pitch, "notes(:,3)", System.out); | |
46 Format.matlab(vel, "notes(:,4)", System.out); | |
47 // if (event.midiCommand == 0x90) | |
48 // count++; | |
49 // else | |
50 // System.out.println("*** Other command: " + event.midiCommand); | |
51 } // main() | |
52 } |