xiRetimer

fit recorded audio to a tempo
git clone https://git.ce9e.org/xiRetimer.git

commit
94e7a516f10b45032fbe9571530795ec35ecbb01
parent
9cd402d0adda8f09d47a720c2660165e244e12cb
Author
Tobias Bengfort <tobias.bengfort@gmx.net>
Date
2010-11-07 17:13
rb_update2

Diffstat

M src/rbprocess.h 34 +++++++++-------------------------
M xiRetimer 0

2 files changed, 9 insertions, 25 deletions


diff --git a/src/rbprocess.h b/src/rbprocess.h

@@ -13,15 +13,11 @@ this uses the rubberband library
   13    13 
   14    14 int RBprocess(int olength, float* data, Marker* marker, Sample* sample, int n=1) {
   15    15 
   16    -1 /*  
   -1    16   int length=sample->getLength();
   17    17   int ostart=int(marker->getOld(0)*olength);
   18    18   if (ostart<0) ostart=0;
   19    19   int olength2=int(marker->getOld(marker->getLength()-1)*olength)-ostart;
   20    20   if (olength2>olength-ostart) olength2=olength-ostart;
   21    -1 */
   22    -1   
   23    -1   int ostart=0;
   24    -1   int olength2=olength;
   25    21 
   26    22   float **ibuf = new float *[1];
   27    23   ibuf[0]=new float[olength2];
@@ -32,39 +28,27 @@ int RBprocess(int olength, float* data, Marker* marker, Sample* sample, int n=1)
   32    28   float **obuf = new float *[1];
   33    29   obuf[0]=data;
   34    30 
   35    -1 
   36    -1   RubberBand::RubberBandStretcher ts(44100, 1, 0, sample->getLength()/(float)olength2);
   -1    31   RubberBand::RubberBandStretcher ts(44100, 1, 0, 1);
   37    32   // map // TODO not precise
   38    33   std::map<unsigned int, unsigned int> fmap;
   39    34   for (int i=0; i<marker->getLength(); ++i) {
   40    -1     fmap[int(marker->getOld(i)*olength)-ostart]=int(marker->getNew(i)*sample->getLength());
   41    -1 /*
   42    -1     // additional 
   43    -1     for (int j=1; j<n; ++j) {
   44    -1       float old=(marker->getOld(i+1)-marker->getOld(i))*j/(float)n;
   45    -1       fmap[int(old*olength)-ostart]=int(marker->new2nnew(marker->old2new(old))*sample->getLength());
   46    -1     }
   47    -1 */
   -1    35     float old= marker->getOld(i);
   -1    36     float nnew= marker->new2nnew(marker->old2new(old));
   -1    37     fmap[int(old*olength)-ostart]=int(nnew*length);
   48    38   }
   49    39   ts.setKeyFrameMap(fmap);
   50    40 
   51    41   sample->setFinished(0.03);
   52    42   ts.study(ibuf, olength2, true);
   53    -1   ts.setMaxProcessSize(olength2*2);
   -1    43   ts.setMaxProcessSize(olength2);
   54    44   int a1=-1;
   55    45   int a2=0;
   56    46   sample->setFinished(0.06);
   57    -1   while (a1!=a2) {
   58    -1     ts.process(ibuf, ts.getSamplesRequired(), false);
   59    -1     a1=a2;
   60    -1     a2=ts.available();
   61    -1     sample->setFinished(a2/(float)sample->getLength()*0.8+0.05); // TODO doesnt really work
   62    -1   }
   63    -1   sample->setFinished(0.8);
   64    47   ts.process(ibuf, olength2, true);
   65    -1   sample->setFinished(0.95);
   -1    48   sample->setFinished(0.9);
   66    49 
   67    50   int avail=ts.available();
   -1    51   if (avail>length) avail=length;
   68    52   ts.retrieve(obuf, avail);
   69    53 
   70    54   for (int j=0; j<avail; ++j) {
@@ -74,7 +58,7 @@ int RBprocess(int olength, float* data, Marker* marker, Sample* sample, int n=1)
   74    58     data[j] = value;
   75    59   }
   76    60 
   77    -1   for (int i=avail; i<sample->getLength(); ++i) {
   -1    61   for (int i=avail; i<length; ++i) {
   78    62     data[i]=0;
   79    63   }
   80    64 

diff --git a/xiRetimer b/xiRetimer

Binary files differ.