# HG changeset patch # User Chris Cannam # Date 1413281623 -3600 # Node ID 56dcb5f67ed108d9cf98cea8562fc1824a5e658b # Parent 3921e0c1f4ddce3efb8a51a3554519c66bc436ea# Parent 04945e74d31497a4404ed985b8bdb859140d0076 Merge from default branch diff -r 3921e0c1f4dd -r 56dcb5f67ed1 .hgsubstate --- a/.hgsubstate Mon Oct 13 16:58:30 2014 +0100 +++ b/.hgsubstate Tue Oct 14 11:13:43 2014 +0100 @@ -1,3 +1,3 @@ d16f0fd6db6104d87882bc43788a3bb1b0f8c528 dataquay 879bdc878826bebec67130326f99397c430419b1 sv-dependency-builds -e25dc8d575656f0409233b29a3f621eb225bbd52 svcore +694301cc71ccb10c8cc5a729c9ffb861891589c2 svcore diff -r 3921e0c1f4dd -r 56dcb5f67ed1 runner/MIDIFeatureWriter.cpp --- a/runner/MIDIFeatureWriter.cpp Mon Oct 13 16:58:30 2014 +0100 +++ b/runner/MIDIFeatureWriter.cpp Tue Oct 14 11:13:43 2014 +0100 @@ -155,7 +155,14 @@ << writer.getError() << endl; throw FileOperationFailed(filename, "create MIDI writer"); } + writer.write(); + + if (!writer.isOK()) { + cerr << "ERROR: Failed to write to MIDI file: " + << writer.getError() << endl; + throw FileOperationFailed(filename, "MIDI write"); + } } } diff -r 3921e0c1f4dd -r 56dcb5f67ed1 tests/test-midi-destinations/test-midi-destinations.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-midi-destinations/test-midi-destinations.sh Tue Oct 14 11:13:43 2014 +0100 @@ -0,0 +1,183 @@ +#!/bin/bash + +. ../include.sh + +infile1=$audiopath/3clicks8.wav +infile2=$audiopath/6clicks8.wav + +infile1dot=$audiopath/3.clicks.8.wav + +outfile1=3clicks8.mid +outfile2=6clicks8.mid + +outfile3=3clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.mid +outfile4=3clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.mid +outfile5=6clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.mid +outfile6=6clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.mid + +outfile1dot=3.clicks.8.mid + +tmpmid=$mypath/tmp_1_$$.mid + +trap "rm -f $tmpmid $outfile1 $outfile2 $outfile3 $outfile4 $outfile5 $outfile6 $infile1dot $outfile1dot $audiopath/$outfile1 $audiopath/$outfile2 $audiopath/$outfile3 $audiopath/$outfile4 $audiopath/$outfile5 $audiopath/$outfile6 $audiopath/$outfile1dot" 0 + +transformdir=$mypath/transforms + +check_midi() { + test -f $1 || \ + fail "Fails to write output to expected location $1 for $2" + case $(strings $1 | head -2 | fmt -80) in + MThd\ MTrk) ;; + *) fail "MIDI output does not look like MIDI in $2";; + esac + rm -f $1 +} + + +ctx="onsets transform, one audio file, default MIDI writer destination" + +rm -f $audiopath/$outfile1 + +$r -t $transformdir/onsets.n3 -w midi $infile1 2>/dev/null || \ + fail "Fails to run with $ctx" + +check_midi $audiopath/$outfile1 "$ctx" + + +ctx="onsets transform, one audio file with dots in filename, default MIDI writer destination" + +rm -f $audiopath/$outfile1 + +cp $infile1 $infile1dot + +$r -t $transformdir/onsets.n3 -w midi $infile1dot 2>/dev/null || \ + fail "Fails to run with $ctx" + +check_midi $audiopath/$outfile1dot "$ctx" + +rm -f $infile1dot $audiopath/$outfile1dot + + +ctx="onsets and df transforms, one audio file, default MIDI writer destination" + +rm -f $audiopath/$outfile1 + +$r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w midi $infile1 2>/dev/null || \ + fail "Fails to run with $ctx" + +check_midi $audiopath/$outfile1 "$ctx" + + +ctx="onsets transform, two audio files, default MIDI writer destination" + +rm -f $audiopath/$outfile1 +rm -f $audiopath/$outfile2 + +$r -t $transformdir/onsets.n3 -w midi $infile1 $infile2 2>/dev/null || \ + fail "Fails to run with $ctx" + +check_midi $audiopath/$outfile1 "$ctx" +check_midi $audiopath/$outfile2 "$ctx" + + +ctx="onsets transform, two audio files, one-file MIDI writer" + +$r -t $transformdir/onsets.n3 -w midi --midi-one-file $tmpmid $infile1 $infile2 2>/dev/null || \ + fail "Fails to run with $ctx" + +check_midi $tmpmid "$ctx" + + +ctx="onsets transform, two audio files, stdout MIDI writer" + +# stdout writer is not supported for midi + +$r -t $transformdir/onsets.n3 -w midi --midi-stdout $infile1 $infile2 2>/dev/null >$tmpmid && \ + fail "Fails by completing successfully with $ctx" + + +ctx="onsets transform, one audio file, many-files MIDI writer" + +rm -f $audiopath/$outfile3 + +$r -t $transformdir/onsets.n3 -w midi --midi-many-files $infile1 2>/dev/null || \ + fail "Fails to run with $ctx" + +check_midi $audiopath/$outfile3 "$ctx" + + +ctx="onsets transform, two audio files, many-files MIDI writer" + +rm -f $audiopath/$outfile3 +rm -f $audiopath/$outfile5 + +$r -t $transformdir/onsets.n3 -w midi --midi-many-files $infile1 $infile2 2>/dev/null || \ + fail "Fails to run with $ctx" + +check_midi $audiopath/$outfile3 "$ctx" +check_midi $audiopath/$outfile5 "$ctx" + + +ctx="onsets and df transforms, two audio files, many-files MIDI writer" + +rm -f $audiopath/$outfile3 +rm -f $audiopath/$outfile4 +rm -f $audiopath/$outfile5 +rm -f $audiopath/$outfile6 + +$r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w midi --midi-many-files $infile1 $infile2 2>/dev/null || \ + fail "Fails to run with $ctx" + +check_midi $audiopath/$outfile3 "$ctx" +check_midi $audiopath/$outfile4 "$ctx" +check_midi $audiopath/$outfile5 "$ctx" +check_midi $audiopath/$outfile6 "$ctx" + + +ctx="output base directory" + +rm -f ./$outfile1 + +$r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w midi --midi-basedir . $infile1 2>/dev/null || \ + fail "Fails to run with $ctx" + +check_midi ./$outfile1 "$ctx" + + +ctx="output base directory and many-files" + +rm -f ./$outfile3 +rm -f ./$outfile5 + +$r -t $transformdir/onsets.n3 -w midi --midi-basedir . --midi-many-files $infile1 $infile2 2>/dev/null || \ + fail "Fails to run with $ctx" + +check_midi ./$outfile3 "$ctx" +check_midi ./$outfile5 "$ctx" + + +ctx="nonexistent output base directory" + +$r -t $transformdir/onsets.n3 -w midi --midi-basedir ./DOES_NOT_EXIST $infile1 2>/dev/null && \ + fail "Fails with $ctx by completing successfully (should refuse and bail out)" + + +ctx="existing output file and no --midi-force" + +touch $audiopath/$outfile1 + +$r -t $transformdir/onsets.n3 -w midi $infile1 2>/dev/null && \ + fail "Fails by completing successfully when output file already exists (should refuse and bail out)" + + +ctx="existing output file and --midi-force" + +touch $audiopath/$outfile1 + +$r -t $transformdir/onsets.n3 -w midi --midi-force $infile1 2>/dev/null || \ + fail "Fails to run with $ctx" + +check_midi $audiopath/$outfile1 "$ctx" + + +exit 0 diff -r 3921e0c1f4dd -r 56dcb5f67ed1 tests/test-midi-destinations/transforms/detectionfunction.n3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-midi-destinations/transforms/detectionfunction.n3 Tue Oct 14 11:13:43 2014 +0100 @@ -0,0 +1,11 @@ +@prefix rdf: . +@prefix vamp: . +@prefix examples: . +@prefix : <#>. + +:transform0 a vamp:Transform; + vamp:plugin examples:percussiononsets ; + vamp:output examples:percussiononsets_output_detectionfunction . + + + diff -r 3921e0c1f4dd -r 56dcb5f67ed1 tests/test-midi-destinations/transforms/onsets.n3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test-midi-destinations/transforms/onsets.n3 Tue Oct 14 11:13:43 2014 +0100 @@ -0,0 +1,10 @@ +@prefix rdf: . +@prefix vamp: . +@prefix examples: . +@prefix : <#>. + +:transform0 a vamp:Transform; + vamp:plugin examples:percussiononsets. + + + diff -r 3921e0c1f4dd -r 56dcb5f67ed1 tests/test-rdf-destinations/test-rdf-destinations.sh --- a/tests/test-rdf-destinations/test-rdf-destinations.sh Mon Oct 13 16:58:30 2014 +0100 +++ b/tests/test-rdf-destinations/test-rdf-destinations.sh Tue Oct 14 11:13:43 2014 +0100 @@ -5,20 +5,21 @@ infile1=$audiopath/3clicks8.wav infile2=$audiopath/6clicks8.wav -outfile1=$audiopath/3clicks8.n3 -outfile2=$audiopath/6clicks8.n3 +infile1dot=$audiopath/3.clicks.8.wav -infile1dot=$audiopath/3.clicks.8.wav -outfile1dot=$audiopath/3.clicks.8.n3 +outfile1=3clicks8.n3 +outfile2=6clicks8.n3 -outfile3=$audiopath/3clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.n3 -outfile4=$audiopath/3clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.n3 -outfile5=$audiopath/6clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.n3 -outfile6=$audiopath/6clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.n3 +outfile3=3clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.n3 +outfile4=3clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.n3 +outfile5=6clicks8_vamp_vamp-example-plugins_percussiononsets_onsets.n3 +outfile6=6clicks8_vamp_vamp-example-plugins_percussiononsets_detectionfunction.n3 + +outfile1dot=3.clicks.8.n3 tmpttl=$mypath/tmp_1_$$.ttl -trap "rm -f $tmpttl $outfile1 $outfile2 $outfile3 $outfile4 $outfile5 $outfile6 $infile1dot $outfile1dot" 0 +trap "rm -f $tmpttl $outfile1 $outfile2 $outfile3 $outfile4 $outfile5 $outfile6 $infile1dot $outfile1dot $audiopath/$outfile1 $audiopath/$outfile2 $audiopath/$outfile3 $audiopath/$outfile4 $audiopath/$outfile5 $audiopath/$outfile6 $audiopath/$outfile1dot" 0 transformdir=$mypath/transforms @@ -35,48 +36,48 @@ ctx="onsets transform, one audio file, default RDF writer destination" -rm -f $outfile1 +rm -f $audiopath/$outfile1 $r -t $transformdir/onsets.n3 -w rdf $infile1 2>/dev/null || \ fail "Fails to run with $ctx" -check_rdf $outfile1 "$ctx" +check_rdf $audiopath/$outfile1 "$ctx" ctx="onsets transform, one audio file with dots in filename, default RDF writer destination" -rm -f $outfile1 +rm -f $audiopath/$outfile1 cp $infile1 $infile1dot $r -t $transformdir/onsets.n3 -w rdf $infile1dot 2>/dev/null || \ fail "Fails to run with $ctx" -check_rdf $outfile1dot "$ctx" +check_rdf $audiopath/$outfile1dot "$ctx" -rm -f $infile1dot $outfile1dot +rm -f $infile1dot $audiopath/$outfile1dot ctx="onsets and df transforms, one audio file, default RDF writer destination" -rm -f $outfile1 +rm -f $audiopath/$outfile1 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w rdf $infile1 2>/dev/null || \ fail "Fails to run with $ctx" -check_rdf $outfile1 "$ctx" +check_rdf $audiopath/$outfile1 "$ctx" ctx="onsets transform, two audio files, default RDF writer destination" -rm -f $outfile1 -rm -f $outfile2 +rm -f $audiopath/$outfile1 +rm -f $audiopath/$outfile2 $r -t $transformdir/onsets.n3 -w rdf $infile1 $infile2 2>/dev/null || \ fail "Fails to run with $ctx" -check_rdf $outfile1 "$ctx" -check_rdf $outfile2 "$ctx" +check_rdf $audiopath/$outfile1 "$ctx" +check_rdf $audiopath/$outfile2 "$ctx" ctx="onsets transform, two audio files, one-file RDF writer" @@ -97,45 +98,73 @@ ctx="onsets transform, one audio file, many-files RDF writer" -rm -f $outfile3 +rm -f $audiopath/$outfile3 $r -t $transformdir/onsets.n3 -w rdf --rdf-many-files $infile1 2>/dev/null || \ fail "Fails to run with $ctx" -check_rdf $outfile3 "$ctx" +check_rdf $audiopath/$outfile3 "$ctx" ctx="onsets transform, two audio files, many-files RDF writer" -rm -f $outfile3 -rm -f $outfile5 +rm -f $audiopath/$outfile3 +rm -f $audiopath/$outfile5 $r -t $transformdir/onsets.n3 -w rdf --rdf-many-files $infile1 $infile2 2>/dev/null || \ fail "Fails to run with $ctx" -check_rdf $outfile3 "$ctx" -check_rdf $outfile5 "$ctx" +check_rdf $audiopath/$outfile3 "$ctx" +check_rdf $audiopath/$outfile5 "$ctx" ctx="onsets and df transforms, two audio files, many-files RDF writer" -rm -f $outfile3 -rm -f $outfile4 -rm -f $outfile5 -rm -f $outfile6 +rm -f $audiopath/$outfile3 +rm -f $audiopath/$outfile4 +rm -f $audiopath/$outfile5 +rm -f $audiopath/$outfile6 $r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w rdf --rdf-many-files $infile1 $infile2 2>/dev/null || \ fail "Fails to run with $ctx" -check_rdf $outfile3 "$ctx" -check_rdf $outfile4 "$ctx" -check_rdf $outfile5 "$ctx" -check_rdf $outfile6 "$ctx" +check_rdf $audiopath/$outfile3 "$ctx" +check_rdf $audiopath/$outfile4 "$ctx" +check_rdf $audiopath/$outfile5 "$ctx" +check_rdf $audiopath/$outfile6 "$ctx" + + +ctx="output base directory" + +rm -f ./$outfile1 + +$r -t $transformdir/onsets.n3 -t $transformdir/detectionfunction.n3 -w rdf --rdf-basedir . $infile1 2>/dev/null || \ + fail "Fails to run with $ctx" + +check_rdf ./$outfile1 "$ctx" + + +ctx="output base directory and many-files" + +rm -f ./$outfile3 +rm -f ./$outfile5 + +$r -t $transformdir/onsets.n3 -w rdf --rdf-basedir . --rdf-many-files $infile1 $infile2 2>/dev/null || \ + fail "Fails to run with $ctx" + +check_rdf ./$outfile3 "$ctx" +check_rdf ./$outfile5 "$ctx" + + +ctx="nonexistent output base directory" + +$r -t $transformdir/onsets.n3 -w rdf --rdf-basedir ./DOES_NOT_EXIST $infile1 2>/dev/null && \ + fail "Fails with $ctx by completing successfully (should refuse and bail out)" ctx="existing output file and no --rdf-force" -touch $outfile1 +touch $audiopath/$outfile1 $r -t $transformdir/onsets.n3 -w rdf $infile1 2>/dev/null && \ fail "Fails by completing successfully when output file already exists (should refuse and bail out)" @@ -143,12 +172,12 @@ ctx="existing output file and --rdf-force" -touch $outfile1 +touch $audiopath/$outfile1 $r -t $transformdir/onsets.n3 -w rdf --rdf-force $infile1 2>/dev/null || \ fail "Fails to run with $ctx" -check_rdf $outfile1 "$ctx" +check_rdf $audiopath/$outfile1 "$ctx" exit 0 diff -r 3921e0c1f4dd -r 56dcb5f67ed1 tests/test.sh --- a/tests/test.sh Mon Oct 13 16:58:30 2014 +0100 +++ b/tests/test.sh Tue Oct 14 11:13:43 2014 +0100 @@ -12,6 +12,7 @@ rdf-writer \ rdf-destinations \ csv-destinations \ + midi-destinations \ summaries \ multiple-audio \ ; do