function run_mirex(filename,outfilename,chromafilename)
%%
warning off
path(path,genpath('.'));
warning on

fprintf(2,'[MATLAB] initialising parameters...');
param = param_mirex(chromafilename);
song = song_skeleton(filename);
fprintf(2,'done.\n');

fprintf(2,'[MATLAB] building DBN...');
bnet = dbn_ISMIR2010(param);
fprintf(2,'done.\n');

fprintf(2,'[MATLAB] reading chroma...');
song = song_chroma(song, param);
fprintf(2,'done.\n');

fprintf(2,'[MATLAB] beat tracking (M Davies)...');
song = song_beat(song, param);
fprintf(2,'done.\n');

fprintf(2,'[MATLAB] beat-synchronising chroma...');
song = song_syncchroma(song,param);
fprintf(2,'done.\n');

fprintf(2,'[MATLAB] segmentation...');
song = song_segment(song, param);
song = song_segchroma(song,param);
fprintf(2,'.\n');

fprintf(2,'[MATLAB] DBN inference...');
song = inference(song, bnet, param);
fprintf(2,'.\n');
%%
fprintf(2,'[MATLAB] writing output files...');
% fprintf(1,'writing to %s\n', outfilename)
write_song(song, bnet, param, outfilename, 'chordlab', 1);
write_song(song, bnet, param, [outfilename(1:end-3) 'keylab'], 'keylab', 1);
% parts2csv(song, [outfilename(1:end-3) 'csv']);
parts2csv(song, [outfilename(1:end-3) 'intcsv'],'integrated');
fprintf(2,'done.\n');
exit