Midi Toolkit Ver 1.0. (22.May.2000) The Midi toolkit consists of two objects: 1. Notes 2. Notetrack notes object is a collection of tracks and is used to load and save a complete midi file. notetrack object stores note events and makes it easy to access and modify information. A typical session would look like: >> ns = notes('snd/stella.mid') % Load a midi file Track Count Len 1 832 159.253 2 546 159.244 3 464 159.247 4 187 156.136 5 546 159.250 6 1215 156.957 >> nt = ns{1}; >> nt(1:5) % List the first 5 events Time Dur Pitch Vol Chan ---- --- ----- --- ---- 1.09 0.62 70 76 0 1.09 0.57 63 85 0 1.09 0.55 74 93 0 1.09 0.55 67 89 0 1.09 0.56 58 73 0 159.25 *************************** >> nt{1,3} % List events between t=1 and t=3 ... >> nt{1,3}.pitch % Get pitches of events between t=1 and t=3 ... >> % Create a new track with same times with pitches transposed a forth up >> nt2 = notetrack('t',nt{1,3}.t,'pitch',nt{1,3}.pitch+5) ... >> % Same operation which uses original midi velocity and channel information >> nt2 = nt{1,3}^4 % Use -4 to transpose down ... >> mj = [0 2 4 5 7 9 11 12]; % Create a Major (ionian) scale >> nt1 = notetrack('pitch',60+mj,'t',linspace(0,5,length(mj)), 'len',6); >> mn = [0 2 3 5 7 8 10 12] % Create a minor (aeolian) scale >> nt2 = notetrack('pitch',69+mn,'t',linspace(0,5,length(mj)), 'len',6); >> nt_harm = [nt1 nt2]; % merge two tracks >> nt_mel = [nt1; nt2]; % Append The minor scale ater the major scale >> save(nt_harm, 'sil.mid', 120); % Create a midi file with 120 bpm metronome Note: Saving and loading midi files depends on linux mex-binaries in @notes/private. notes2midi.mexlx % Save midi2notes.mexlx % Load (Binaries for windows95/98 have the extension dll). If there are problems, you need to compile the c++ sources. Original c++ sources can be downloaded from http:///www.mbfys.kun.nl/~cemgil/matlab/midisong4matlab.tar.gz Listing of all methods in Notetrack SUBSREF Subscripted Reference to Notetrack Objects SUBSASGN Subscripted assignment HORZCAT Merges two notetracks VERTCAT Concatenation of two tracks in time PLUS Shifts Note forward by delta time MINUS Shifts Note by backward by delta time MTIMES Scales durations and onset times by factor MRDIVIDE Scales durations and onset times by factor MPOWER Transpose the pitches by halfnote steps NOTETRACK Constructor (load) SAVE Saves as a midi File PLOT Plot Function DISPLAY Display Function LENGTH Number of Note events PLAY Plays a NoteTrack (needs an external program) Author Ali Taylan Cemgil, SNN - University of Nijmegen, Department of Medical Physics and Biophysics e-mail : cemgil@mbfys.kun.nl 22-May-2000 5:14 PM ATC Created under MATLAB 5.3.1.29215a (R11.1) -------------------------------------------------------------------- This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.