xiRetimer

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

commit
a94f5455fdd8333bc71f364924800c493f018f80
parent
125b6b62f9b540e9e9658552f5fb9eb745603248
Author
Tobias Bengfort <tobias.bengfort@gmx.net>
Date
2010-11-17 18:52
update

Diffstat

M src/gui/retimer_wx.cpp 1 +
M src/rbprocess.h 13 ++++++++-----
M src/sample.cpp 22 +++++++++++++++-------
M xiRetimer 0

4 files changed, 24 insertions, 12 deletions


diff --git a/src/gui/retimer_wx.cpp b/src/gui/retimer_wx.cpp

@@ -233,6 +233,7 @@ PrefsDialog::PrefsDialog( wxWindow* parent, wxWindowID id, const wxString& title
  233   233 	l_stretchmode->Wrap( -1 );
  234   234 	fgSizer4->Add( l_stretchmode, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
  235   235 	
   -1   236         // TODO #ifdef MODE_RUBBERBAND
  236   237 	wxString c_stretchmodeChoices[] = { wxT("none"), wxT("RubberBand") };
  237   238 	int c_stretchmodeNChoices = sizeof( c_stretchmodeChoices ) / sizeof( wxString );
  238   239 	c_stretchmode = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, c_stretchmodeNChoices, c_stretchmodeChoices, 0 );

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

@@ -3,6 +3,9 @@
    3     3 
    4     4 #include "marker.h"
    5     5 #include "sample.h"
   -1     6 
   -1     7 #ifdef MODE_RUBBERBAND
   -1     8 
    6     9 #include <rubberband/RubberBandStretcher.h>
    7    10 #include <map>
    8    11 
@@ -29,12 +32,11 @@ int RBprocess(int olength, float* data, Marker* marker, Sample* sample, int n=1)
   29    32   obuf[0]=data;
   30    33 
   31    34   RubberBand::RubberBandStretcher ts(44100, 1, 0, 1);
   32    -1   // map // TODO not precise
   -1    35   // map // TODO simply todo
   33    36   std::map<unsigned int, unsigned int> fmap;
   34    -1   for (int i=0; i<marker->getLength(); ++i) {
   35    -1     float old= marker->getOld(i);
   36    -1     float nnew= marker->new2nnew(marker->old2new(old));
   37    -1     fmap[int(old*olength)-ostart]=int(nnew*length);
   -1    37   for (int i=0; i<length; i+=1024) {
   -1    38     float old= marker->nnew2new(marker->new2old(i/(float)length));
   -1    39     fmap[int(old*olength)-ostart]=int(i);
   38    40   }
   39    41   ts.setKeyFrameMap(fmap);
   40    42 
@@ -71,3 +73,4 @@ int RBprocess(int olength, float* data, Marker* marker, Sample* sample, int n=1)
   71    73 
   72    74 #endif
   73    75 
   -1    76 #endif

diff --git a/src/sample.cpp b/src/sample.cpp

@@ -1,7 +1,11 @@
    1     1 #include "sample.h"
    2    -1 #include "rbprocess.h"
    3     2 #include <pthread.h>
    4     3 
   -1     4 // TODO create configure/make
   -1     5 #define MODE_RUBBERBAND
   -1     6 
   -1     7 #include "rbprocess.h"
   -1     8 
    5     9 Sample::Sample(Marker* m) {
    6    10   marker=m;
    7    11   length=0;
@@ -113,30 +117,35 @@ int Sample::process() {
  113   117 //  process_bg();
  114   118   if (_processing) return 1;
  115   119   setFinished(0);
   -1   120 /*
  116   121   pthread_t thread;
  117   122   pthread_create(&thread, NULL, Sample::EntryPoint, (void*)this);
  118    -1   _processing=true;
   -1   123 */
   -1   124   process_bg();
  119   125   return 0;
  120   126 }
  121   127 
  122   128 void* Sample::EntryPoint(void* pthis)
  123   129 {
  124    -1    Sample* pt = (Sample*)pthis;
  125    -1    pt->process_bg();
   -1   130   Sample* pt = (Sample*)pthis;
   -1   131   int error=pt->process_bg();
   -1   132   pthread_exit((void*)error);
  126   133 }
  127   134 
  128   135 int Sample::process_bg() {
  129   136 /*
  130    -1 This function does the nmain thing: it stretches the original data as defined by the marker object.
   -1   137 This function does the main thing: it stretches the original data as defined by the marker object.
  131   138 Therefore it reads data from odata and writes to data.
  132   139 */
   -1   140   _processing=true;
  133   141   // setup data
  134   142   length=getGuessedLength();
  135   143   delete[] data;
  136   144   data=new float[length];
  137   145   switch (getStretchMode()) {
  138    -1     // rubberband
   -1   146 #ifdef MODE_RUBBERBAND
  139   147     case 1: RBprocess(olength, data, marker, this); break;
   -1   148 #endif
  140   149     default: {
  141   150       for (int i=0; i<length; ++i) {
  142   151         data[i]=getOld(marker->new2old(marker->nnew2new(i/(float)length)));
@@ -146,7 +155,6 @@ Therefore it reads data from odata and writes to data.
  146   155   }
  147   156   setFinished(1);
  148   157   _processing=false;
  149    -1   pthread_exit((void*)0);
  150   158 }
  151   159 
  152   160 bool Sample::getProcessing() {return _processing;}

diff --git a/xiRetimer b/xiRetimer

Binary files differ.