diff data/model/AggregateWaveModel.cpp @ 300:5877d68815c7

* Change WaveFileModel API from getValues(start,end) to getData(start,count). It's much less error-prone to pass in frame counts instead of start/end locations. Should have done this ages ago. This closes #1794563. * Add option to apply a transform to only the selection region, instead of the whole audio. * (to make the above work properly) Add start frame offset to wave models
author Chris Cannam
date Mon, 01 Oct 2007 13:48:38 +0000
parents c022976d18e8
children 70a232b1f12a
line wrap: on
line diff
--- a/data/model/AggregateWaveModel.cpp	Fri Sep 28 16:15:06 2007 +0000
+++ b/data/model/AggregateWaveModel.cpp	Mon Oct 01 13:48:38 2007 +0000
@@ -97,8 +97,8 @@
 }
 
 size_t
-AggregateWaveModel::getValues(int channel, size_t start, size_t end,
-                              float *buffer) const
+AggregateWaveModel::getData(int channel, size_t start, size_t count,
+                            float *buffer) const
 {
     int ch0 = channel, ch1 = channel;
     bool mixing = false;
@@ -110,22 +110,22 @@
 
     float *readbuf = buffer;
     if (mixing) {
-        readbuf = new float[end - start];
-        for (size_t i = 0; i < end - start; ++i) {
+        readbuf = new float[count];
+        for (size_t i = 0; i < count; ++i) {
             buffer[i] = 0.f;
         }
     }
 
-    size_t sz = end - start;
-    
+    size_t sz = count;
+
     for (int c = ch0; c <= ch1; ++c) {
         size_t szHere = 
-            m_components[c].model->getValues(m_components[c].channel,
-                                             start, end,
-                                             readbuf);
+            m_components[c].model->getData(m_components[c].channel,
+                                           start, count,
+                                           readbuf);
         if (szHere < sz) sz = szHere;
         if (mixing) {
-            for (size_t i = 0; i < end - start; ++i) {
+            for (size_t i = 0; i < count; ++i) {
                 buffer[i] += readbuf[i];
             }
         }
@@ -136,8 +136,8 @@
 }
          
 size_t
-AggregateWaveModel::getValues(int channel, size_t start, size_t end,
-                              double *buffer) const
+AggregateWaveModel::getData(int channel, size_t start, size_t count,
+                            double *buffer) const
 {
     int ch0 = channel, ch1 = channel;
     bool mixing = false;
@@ -149,22 +149,22 @@
 
     double *readbuf = buffer;
     if (mixing) {
-        readbuf = new double[end - start];
-        for (size_t i = 0; i < end - start; ++i) {
-            buffer[i] = 0.f;
+        readbuf = new double[count];
+        for (size_t i = 0; i < count; ++i) {
+            buffer[i] = 0.0;
         }
     }
 
-    size_t sz = end - start;
+    size_t sz = count;
     
     for (int c = ch0; c <= ch1; ++c) {
         size_t szHere = 
-            m_components[c].model->getValues(m_components[c].channel,
-                                             start, end,
-                                             readbuf);
+            m_components[c].model->getData(m_components[c].channel,
+                                           start, count,
+                                           readbuf);
         if (szHere < sz) sz = szHere;
         if (mixing) {
-            for (size_t i = 0; i < end - start; ++i) {
+            for (size_t i = 0; i < count; ++i) {
                 buffer[i] += readbuf[i];
             }
         }
@@ -175,14 +175,14 @@
 }
         
 void
-AggregateWaveModel::getRanges(size_t channel, size_t start, size_t end,
-                              RangeBlock &ranges, size_t &blockSize) const
+AggregateWaveModel::getSummaries(size_t channel, size_t start, size_t count,
+                                 RangeBlock &ranges, size_t &blockSize) const
 {
     //!!! complete
 }
 
 AggregateWaveModel::Range
-AggregateWaveModel::getRange(size_t channel, size_t start, size_t end) const
+AggregateWaveModel::getSummary(size_t channel, size_t start, size_t count) const
 {
     //!!! complete
     return Range();