# HG changeset patch # User Chris Cannam # Date 1412170501 -3600 # Node ID 010fbf2a3fba64e91f7c9029747273aa3399be42 # Parent 136d8496a4b82ad106d79f99d3f58d20e0a25efd# Parent 526feaad5820c599ccc17b1e875d48489cae618f Merge from branch start-duration diff -r 136d8496a4b8 -r 010fbf2a3fba .hgsubstate --- a/.hgsubstate Wed Oct 01 13:35:35 2014 +0100 +++ b/.hgsubstate Wed Oct 01 14:35:01 2014 +0100 @@ -1,2 +1,2 @@ d16f0fd6db6104d87882bc43788a3bb1b0f8c528 dataquay -e8e6c4e7437bf7d1a9a5bf937b53d20de99fdf89 svcore +58c4d69b4dd8ff05908097ea2d5c520067b12aa4 svcore diff -r 136d8496a4b8 -r 010fbf2a3fba runner/FeatureExtractionManager.cpp --- a/runner/FeatureExtractionManager.cpp Wed Oct 01 13:35:35 2014 +0100 +++ b/runner/FeatureExtractionManager.cpp Wed Oct 01 14:35:01 2014 +0100 @@ -604,6 +604,10 @@ // cerr << "file has " << frameCount << " frames" << endl; + int earliestStartFrame = 0; + int latestEndFrame = frameCount; + bool haveExtents = false; + for (PluginMap::iterator pi = m_plugins.begin(); pi != m_plugins.end(); ++pi) { @@ -617,12 +621,22 @@ const Transform &transform = ti->first; - //!!! we may want to set the start and duration times for extraction - // in the transform record (defaults of zero indicate extraction - // from the whole file) -// transform.setStartTime(RealTime::zeroTime); -// transform.setDuration -// (RealTime::frame2RealTime(reader->getFrameCount(), m_sampleRate)); + int startFrame = RealTime::realTime2Frame + (transform.getStartTime(), m_sampleRate); + int duration = RealTime::realTime2Frame + (transform.getDuration(), m_sampleRate); + if (duration == 0) { + duration = frameCount - startFrame; + } + + if (!haveExtents || startFrame < earliestStartFrame) { + earliestStartFrame = startFrame; + } + if (!haveExtents || startFrame + duration > latestEndFrame) { + latestEndFrame = startFrame + duration; + } + + haveExtents = true; string outputId = transform.getOutput().toStdString(); if (m_pluginOutputs[plugin].find(outputId) == @@ -650,33 +664,8 @@ } } - long startFrame = 0; - long endFrame = frameCount; - -/*!!! No -- there is no single transform to pull this stuff from -- - * the transforms may have various start and end times, need to be far - * cleverer about this if we're going to support them - - RealTime trStartRT = transform.getStartTime(); - RealTime trDurationRT = transform.getDuration(); - - long trStart = RealTime::realTime2Frame(trStartRT, m_sampleRate); - long trDuration = RealTime::realTime2Frame(trDurationRT, m_sampleRate); - - if (trStart == 0 || trStart < startFrame) { - trStart = startFrame; - } - - if (trDuration == 0) { - trDuration = endFrame - trStart; - } - if (trStart + trDuration > endFrame) { - trDuration = endFrame - trStart; - } - - startFrame = trStart; - endFrame = trStart + trDuration; -*/ + int startFrame = earliestStartFrame; + int endFrame = latestEndFrame; for (PluginMap::iterator pi = m_plugins.begin(); pi != m_plugins.end(); ++pi) { @@ -700,10 +689,10 @@ ProgressPrinter extractionProgress("Extracting and writing features..."); int progress = 0; - for (long i = startFrame; i < endFrame; i += m_blockSize) { + for (int i = startFrame; i < endFrame; i += m_blockSize) { //!!! inefficient, although much of the inefficiency may be - // susceptible to optimisation + // susceptible to compiler optimisation SampleBlock frames; reader->getInterleavedFrames(i, m_blockSize, frames); diff -r 136d8496a4b8 -r 010fbf2a3fba tests/expected/transforms-basic-percussiononsets-df-start-and-duration.csv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/expected/transforms-basic-percussiononsets-df-start-and-duration.csv Wed Oct 01 14:35:01 2014 +0100 @@ -0,0 +1,192 @@ +"./audio/3clicks8.wav",2.000000000,0 +,2.011609977,227 +,2.023219954,180 +,2.034829931,163 +,2.046439909,188 +,2.058049886,156 +,2.069659863,177 +,2.081269841,162 +,2.092879818,187 +,2.104489795,175 +,2.116099773,183 +,2.127709750,177 +,2.139319727,159 +,2.150929705,176 +,2.162539682,170 +,2.174149659,146 +,2.185759637,181 +,2.197369614,170 +,2.208979591,165 +,2.220589569,184 +,2.232199546,170 +,2.243809523,160 +,2.255419501,167 +,2.267029478,183 +,2.278639455,170 +,2.290249433,174 +,2.301859410,159 +,2.313469387,165 +,2.325079365,163 +,2.336689342,185 +,2.348299319,180 +,2.359909297,153 +,2.371519274,159 +,2.383129251,159 +,2.394739229,181 +,2.406349206,386 +,2.417959183,432 +,2.429569160,37 +,2.441179138,170 +,2.452789115,166 +,2.464399092,183 +,2.476009070,161 +,2.487619047,157 +,2.499229024,142 +,2.510839002,177 +,2.522448979,184 +,2.534058956,165 +,2.545668934,177 +,2.557278911,178 +,2.568888888,197 +,2.580498866,172 +,2.592108843,159 +,2.603718820,173 +,2.615328798,145 +,2.626938775,183 +,2.638548752,184 +,2.650158730,157 +,2.661768707,170 +,2.673378684,160 +,2.684988662,178 +,2.696598639,168 +,2.708208616,163 +,2.719818594,166 +,2.731428571,182 +,2.743038548,179 +,2.754648526,168 +,2.766258503,172 +,2.777868480,151 +,2.789478458,180 +,2.801088435,158 +,2.812698412,174 +,2.824308390,184 +,2.835918367,161 +,2.847528344,190 +,2.859138321,161 +,2.870748299,174 +,2.882358276,162 +,2.893968253,183 +,2.905578231,151 +,2.917188208,186 +,2.928798185,162 +,2.940408163,176 +,2.952018140,173 +,2.963628117,159 +,2.975238095,193 +,2.986848072,147 +,2.998458049,189 +,3.010068027,165 +,3.021678004,161 +,3.033287981,169 +,3.044897959,183 +,3.056507936,163 +,3.068117913,149 +,3.079727891,181 +,3.091337868,158 +,3.102947845,179 +,3.114557823,178 +,3.126167800,160 +,3.137777777,205 +,3.149387755,145 +,3.160997732,201 +,3.172607709,159 +,3.184217687,144 +,3.195827664,194 +,3.207437641,168 +,3.219047619,150 +,3.230657596,149 +,3.242267573,183 +,3.253877551,173 +,3.265487528,179 +,3.277097505,176 +,3.288707482,157 +,3.300317460,157 +,3.311927437,194 +,3.323537414,167 +,3.335147392,150 +,3.346757369,183 +,3.358367346,169 +,3.369977324,142 +,3.381587301,191 +,3.393197278,178 +,3.404807256,168 +,3.416417233,190 +,3.428027210,156 +,3.439637188,167 +,3.451247165,166 +,3.462857142,158 +,3.474467120,161 +,3.486077097,170 +,3.497687074,162 +,3.509297052,164 +,3.520907029,177 +,3.532517006,156 +,3.544126984,173 +,3.555736961,168 +,3.567346938,162 +,3.578956916,151 +,3.590566893,164 +,3.602176870,186 +,3.613786848,180 +,3.625396825,156 +,3.637006802,183 +,3.648616780,165 +,3.660226757,154 +,3.671836734,178 +,3.683446712,164 +,3.695056689,167 +,3.706666666,178 +,3.718276643,166 +,3.729886621,164 +,3.741496598,180 +,3.753106575,186 +,3.764716553,174 +,3.776326530,166 +,3.787936507,198 +,3.799546485,171 +,3.811156462,144 +,3.822766439,169 +,3.834376417,180 +,3.845986394,168 +,3.857596371,181 +,3.869206349,171 +,3.880816326,188 +,3.892426303,169 +,3.904036281,165 +,3.915646258,152 +,3.927256235,165 +,3.938866213,185 +,3.950476190,158 +,3.962086167,168 +,3.973696145,163 +,3.985306122,144 +,3.996916099,173 +,4.008526077,174 +,4.020136054,167 +,4.031746031,159 +,4.043356009,164 +,4.054965986,162 +,4.066575963,178 +,4.078185941,187 +,4.089795918,145 +,4.101405895,159 +,4.113015873,162 +,4.124625850,181 +,4.136235827,167 +,4.147845804,158 +,4.159455782,173 +,4.171065759,169 +,4.182675736,158 +,4.194285714,194 +,4.205895691,157 +,4.217505668,166 diff -r 136d8496a4b8 -r 010fbf2a3fba tests/expected/transforms-basic-percussiononsets-multiple-outputs-start-and-duration.csv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/expected/transforms-basic-percussiononsets-multiple-outputs-start-and-duration.csv Wed Oct 01 14:35:01 2014 +0100 @@ -0,0 +1,290 @@ +"./audio/3clicks8.wav",1.000000000,0 +,1.011609977,239 +,1.023219954,161 +,1.034829931,182 +,1.046439909,173 +,1.058049886,150 +,1.069659863,180 +,1.081269841,161 +,1.092879818,181 +,1.104489795,168 +,1.116099773,176 +,1.127709750,162 +,1.139319727,180 +,1.150929705,162 +,1.162539682,165 +,1.174149659,178 +,1.185759637,162 +,1.197369614,161 +,1.208979591,173 +,1.220589569,147 +,1.232199546,150 +,1.243809523,180 +,1.255419501,154 +,1.267029478,201 +,1.278639455,170 +,1.290249433,160 +,1.301859410,178 +,1.313469387,153 +,1.325079365,162 +,1.336689342,176 +,1.348299319,169 +,1.359909297,186 +,1.371519274,153 +,1.383129251,166 +,1.394739229,170 +,1.406349206,166 +,1.417959183,181 +,1.429569160,168 +,1.441179138,190 +,1.452789115,174 +,1.464399092,169 +,1.476009070,170 +,1.487619047,171 +,1.499229024,185 +,1.510839002,168 +,1.522448979,179 +,1.534058956,163 +,1.545668934,175 +,1.557278911,167 +,1.568888888,176 +,1.580498866,164 +,1.592108843,144 +,1.603718820,166 +,1.615328798,190 +,1.626938775,177 +,1.638548752,143 +,1.650158730,509 +,1.661768707,0 +,1.673378684,65 +,1.684988662,190 +,1.696598639,160 +,1.708208616,179 +,1.719818594,164 +,1.650158730 +,1.731428571,157 +,1.743038548,157 +,1.754648526,194 +,1.766258503,181 +,1.777868480,173 +,1.789478458,164 +,1.801088435,143 +,1.812698412,187 +,1.824308390,191 +,1.835918367,184 +,1.847528344,169 +,1.859138321,156 +,1.870748299,178 +,1.882358276,162 +,1.893968253,172 +,1.905578231,166 +,1.917188208,150 +,1.928798185,178 +,1.940408163,166 +,1.952018140,177 +,1.963628117,154 +,1.975238095,155 +,1.986848072,158 +,1.998458049,191 +,2.010068027,167 +,2.021678004,192 +,2.033287981,164 +,2.044897959,192 +,2.056507936,160 +,2.068117913,179 +,2.079727891,162 +,2.091337868,168 +,2.102947845,177 +,2.114557823,179 +,2.126167800,169 +,2.137777777,161 +,2.149387755,166 +,2.160997732,175 +,2.172607709,149 +,2.184217687,189 +,2.195827664,172 +,2.207437641,157 +,2.219047619,173 +,2.230657596,171 +,2.242267573,147 +,2.253877551,180 +,2.265487528,158 +,2.277097505,159 +,2.288707482,193 +,2.300317460,153 +,2.311927437,157 +,2.323537414,165 +,2.335147392,198 +,2.346757369,181 +,2.358367346,146 +,2.369977324,158 +,2.381587301,166 +,2.393197278,171 +,2.404807256,288 +,2.416417233,438 +,2.428027210,29 +,2.439637188,161 +,2.451247165,166 +,2.462857142,189 +,2.416417233 +,2.474467120,167 +,2.486077097,166 +,2.497687074,150 +,2.509297052,190 +,2.520907029,185 +,2.532517006,169 +,2.544126984,172 +,2.555736961,170 +,2.567346938,182 +,2.578956916,171 +,2.590566893,157 +,2.602176870,177 +,2.613786848,160 +,2.625396825,175 +,2.637006802,182 +,2.648616780,160 +,2.660226757,160 +,2.671836734,172 +,2.683446712,177 +,2.695056689,157 +,2.706666666,167 +,2.718276643,172 +,2.729886621,181 +,2.741496598,182 +,2.753106575,158 +,2.764716553,169 +,2.776326530,149 +,2.787936507,182 +,2.799546485,158 +,2.811156462,160 +,2.822766439,192 +,2.834376417,160 +,2.845986394,182 +,2.857596371,149 +,2.869206349,174 +,2.880816326,169 +,2.892426303,187 +,2.904036281,157 +,2.915646258,181 +,2.927256235,170 +,2.938866213,186 +,2.950476190,180 +,2.962086167,177 +,2.973696145,181 +,2.985306122,152 +,2.996916099,199 +,3.008526077,174 +,3.020136054,170 +,3.031746031,169 +,3.043356009,195 +,3.054965986,169 +,3.066575963,142 +,3.078185941,184 +,3.089795918,159 +,3.101405895,181 +,3.113015873,179 +,3.124625850,158 +,3.136235827,212 +,3.147845804,152 +,3.159455782,211 +,3.171065759,163 +,3.182675736,141 +,3.194285714,190 +,3.205895691,167 +,3.217505668,168 +,3.229115646,146 +,3.240725623,164 +,3.252335600,167 +,3.263945578,186 +,3.275555555,179 +,3.287165532,158 +,3.298775510,164 +,3.310385487,182 +,3.321995464,180 +,3.333605442,138 +,3.345215419,180 +,3.356825396,173 +,3.368435374,154 +,3.380045351,198 +,3.391655328,178 +,3.403265306,164 +,3.414875283,193 +,3.426485260,159 +,3.438095238,171 +,3.449705215,165 +,3.461315192,174 +,3.472925170,162 +,3.484535147,175 +,3.496145124,160 +,3.507755102,184 +,3.519365079,169 +,3.530975056,168 +,3.542585034,171 +,3.554195011,166 +,3.565804988,169 +,3.577414965,151 +,3.589024943,154 +,3.600634920,194 +,3.612244897,178 +,3.623854875,153 +,3.635464852,186 +,3.647074829,156 +,3.658684807,162 +,3.670294784,183 +,3.681904761,172 +,3.693514739,163 +,3.705124716,172 +,3.716734693,172 +,3.728344671,167 +,3.739954648,168 +,3.751564625,175 +,3.763174603,179 +,3.774784580,163 +,3.786394557,192 +,3.798004535,169 +,3.809614512,147 +,3.821224489,158 +,3.832834467,202 +,3.844444444,162 +,3.856054421,196 +,3.867664399,158 +,3.879274376,194 +,3.890884353,168 +,3.902494331,171 +,3.914104308,151 +,3.925714285,159 +,3.937324263,172 +,3.948934240,164 +,3.960544217,151 +,3.972154195,163 +,3.983764172,159 +,3.995374149,180 +,4.006984126,163 +,4.018594104,182 +,4.030204081,148 +,4.041814058,183 +,4.053424036,159 +,4.065034013,181 +,4.076643990,184 +,4.088253968,143 +,4.099863945,154 +,4.111473922,165 +,4.123083900,175 +,4.134693877,176 +,4.146303854,158 +,4.157913832,189 +,4.169523809,157 +,4.181133786,163 +,4.192743764,196 +,4.204353741,160 +,4.215963718,168 +,4.227573696,184 +,4.239183673,155 +,4.250793650,168 +,4.262403628,169 +,4.274013605,191 +,4.285623582,155 +,4.297233560,169 +,4.308843537,161 +,4.320453514,172 +,4.332063492,181 diff -r 136d8496a4b8 -r 010fbf2a3fba tests/expected/transforms-basic-percussiononsets-start-and-duration.csv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/expected/transforms-basic-percussiononsets-start-and-duration.csv Wed Oct 01 14:35:01 2014 +0100 @@ -0,0 +1,1 @@ +"./audio/3clicks8.wav",2.417959183 diff -r 136d8496a4b8 -r 010fbf2a3fba tests/expected/transforms-summaries-start-and-duration.csv --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/expected/transforms-summaries-start-and-duration.csv Wed Oct 01 14:35:01 2014 +0100 @@ -0,0 +1,1 @@ +"./audio/3clicks8.wav" diff -r 136d8496a4b8 -r 010fbf2a3fba tests/test-transforms-basic.sh --- a/tests/test-transforms-basic.sh Wed Oct 01 13:35:35 2014 +0100 +++ b/tests/test-transforms-basic.sh Wed Oct 01 14:35:01 2014 +0100 @@ -25,13 +25,16 @@ -no-parameters-default-output \ -no-parameters \ "" \ + -start-and-duration \ -set-parameters \ -set-step-and-block-size \ -set-sample-rate \ -df-windowtype-default \ -df-windowtype-hanning \ -df-windowtype-hamming \ + -df-start-and-duration \ -multiple-outputs \ + -multiple-outputs-start-and-duration \ ; do for type in xml n3 ; do diff -r 136d8496a4b8 -r 010fbf2a3fba tests/transforms/transforms-basic-percussiononsets-df-start-and-duration.n3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/transforms/transforms-basic-percussiononsets-df-start-and-duration.n3 Wed Oct 01 14:35:01 2014 +0100 @@ -0,0 +1,24 @@ +@prefix rdf: . +@prefix vamp: . +@prefix examples: . +@prefix : <#>. + +:transform0 a vamp:Transform; + vamp:plugin examples:percussiononsets ; + vamp:output examples:percussiononsets_output_detectionfunction ; + vamp:step_size "512"; + vamp:block_size "1024"; + vamp:parameter_binding :param0 ; + vamp:parameter_binding :param1 ; + vamp:start "PT2.0S"^^xsd:duration ; + vamp:duration "PT2.0S"^^xsd:duration . + +:param0 a vamp:ParameterBinding; + vamp:parameter [ vamp:identifier "sensitivity" ]; + vamp:value "40". + +:param1 a vamp:ParameterBinding; + vamp:parameter examples:percussiononsets_param_threshold; + vamp:value "3". + + diff -r 136d8496a4b8 -r 010fbf2a3fba tests/transforms/transforms-basic-percussiononsets-df-start-and-duration.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/transforms/transforms-basic-percussiononsets-df-start-and-duration.xml Wed Oct 01 14:35:01 2014 +0100 @@ -0,0 +1,13 @@ + + + + diff -r 136d8496a4b8 -r 010fbf2a3fba tests/transforms/transforms-basic-percussiononsets-multiple-outputs-start-and-duration.n3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/transforms/transforms-basic-percussiononsets-multiple-outputs-start-and-duration.n3 Wed Oct 01 14:35:01 2014 +0100 @@ -0,0 +1,19 @@ +@prefix rdf: . +@prefix vamp: . +@prefix examples: . +@prefix : <#>. + +:transform0 a vamp:Transform; + vamp:plugin examples:percussiononsets ; + vamp:output examples:percussiononsets_output_onsets ; + vamp:start "PT1.0S"^^xsd:duration ; + vamp:duration "PT3.0S"^^xsd:duration . + +:transform1 a vamp:Transform; + vamp:plugin examples:percussiononsets ; + vamp:output examples:percussiononsets_output_detectionfunction ; + vamp:start "PT2.0S"^^xsd:duration ; + vamp:duration "PT1.0S"^^xsd:duration . + + + diff -r 136d8496a4b8 -r 010fbf2a3fba tests/transforms/transforms-basic-percussiononsets-start-and-duration.n3 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/transforms/transforms-basic-percussiononsets-start-and-duration.n3 Wed Oct 01 14:35:01 2014 +0100 @@ -0,0 +1,25 @@ +@prefix rdf: . +@prefix vamp: . +@prefix examples: . +@prefix xsd: . +@prefix : <#>. + +:transform0 a vamp:Transform; + vamp:plugin examples:percussiononsets ; + vamp:output examples:percussiononsets_output_onsets ; + vamp:step_size "512"; + vamp:block_size "1024"; + vamp:parameter_binding :param0 ; + vamp:parameter_binding :param1 ; + vamp:start "PT2.0S"^^xsd:duration ; + vamp:duration "PT2.0S"^^xsd:duration . + +:param0 a vamp:ParameterBinding; + vamp:parameter [ vamp:identifier "sensitivity" ]; + vamp:value "40". + +:param1 a vamp:ParameterBinding; + vamp:parameter examples:percussiononsets_param_threshold; + vamp:value "3". + + diff -r 136d8496a4b8 -r 010fbf2a3fba tests/transforms/transforms-basic-percussiononsets-start-and-duration.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/transforms/transforms-basic-percussiononsets-start-and-duration.xml Wed Oct 01 14:35:01 2014 +0100 @@ -0,0 +1,13 @@ + + + +