- commit
- 9cd402d0adda8f09d47a720c2660165e244e12cb
- parent
- 2e74f7ec573b1a089b85d28e9301967557feb8d9
- Author
- Tobias Bengfort <tobias.bengfort@gmx.net>
- Date
- 2010-11-07 16:07
rb_update
Diffstat
| M | src/gui/RetimerMainFrame.cpp | 8 | +++++--- |
| M | src/playback.cpp | 4 | ---- |
| M | src/rbprocess.h | 40 | +++++++++++++++++++++++----------------- |
| M | src/sample.cpp | 2 | +- |
| M | xiRetimer | 0 |
5 files changed, 29 insertions, 25 deletions
diff --git a/src/gui/RetimerMainFrame.cpp b/src/gui/RetimerMainFrame.cpp
@@ -91,13 +91,15 @@ void RetimerMainFrame::OnOpenClick( wxCommandEvent& event ) 91 91 92 92 if (dialog->ShowModal()==wxID_OK) { 93 93 wxString filename=dialog->GetPath();94 -1 if (sample->loadFile(filename.mb_str())!=0)-1 94 if (sample->loadFile(filename.mb_str())!=0) { 95 95 reportError( _T("Could not read from that file")); -1 96 return; -1 97 } 96 98 process(); 97 99 _updateWaveform=true; 98 100 }99 -1 else100 -1 reportError( _T("Please choose a valid file!"));-1 101 // else -1 102 // reportError( _T("Please choose a valid file!")); 101 103 } 102 104 103 105 void RetimerMainFrame::OnExportClick( wxCommandEvent& event )
diff --git a/src/playback.cpp b/src/playback.cpp
@@ -71,10 +71,6 @@ int Playback::start() {
71 71
72 72 void callback(void *udata, Uint8 *stream, int len) {
73 73 if (_play) {
74 -1 std::cout << seeker;
75 -1 std::cout << oseeker;
76 -1 std::cout << std::endl;
77 -1
78 74 if (sounds.dpos==sounds.dlen) {
79 75 _play=false;
80 76 seeker=float(oseeker);
diff --git a/src/rbprocess.h b/src/rbprocess.h
@@ -11,53 +11,58 @@ this is called by sample.process() 11 11 this uses the rubberband library 12 12 */ 13 1314 -1 int RBprocess(int olength, float* data, int length, Marker* marker, Sample* caller, int n=1) {15 -1-1 14 int RBprocess(int olength, float* data, Marker* marker, Sample* sample, int n=1) { -1 15 -1 16 /* 16 17 int ostart=int(marker->getOld(0)*olength); 17 18 if (ostart<0) ostart=0; 18 19 int olength2=int(marker->getOld(marker->getLength()-1)*olength)-ostart; 19 20 if (olength2>olength-ostart) olength2=olength-ostart;20 -1 if (olength2<10) return 1;-1 21 */ -1 22 -1 23 int ostart=0; -1 24 int olength2=olength; 21 25 22 26 float **ibuf = new float *[1]; 23 27 ibuf[0]=new float[olength2]; 24 28 for (int i=0; i<olength2; ++i) {25 -1 ibuf[0][i]=caller->getOld((ostart+i)/(float)olength);-1 29 ibuf[0][i]=sample->getOld((ostart+i)/(float)olength); 26 30 } 27 31 28 32 float **obuf = new float *[1]; 29 33 obuf[0]=data; 30 3431 -1 RubberBand::RubberBandStretcher ts(44100, 1, 0, length/(float)olength2);-1 35 -1 36 RubberBand::RubberBandStretcher ts(44100, 1, 0, sample->getLength()/(float)olength2); 32 37 // map // TODO not precise 33 38 std::map<unsigned int, unsigned int> fmap; 34 39 for (int i=0; i<marker->getLength(); ++i) {35 -1 fmap[int(marker->getOld(i)*olength2)]=int(marker->getNew(i)*length);-1 40 fmap[int(marker->getOld(i)*olength)-ostart]=int(marker->getNew(i)*sample->getLength()); -1 41 /* 36 42 // additional 37 43 for (int j=1; j<n; ++j) { 38 44 float old=(marker->getOld(i+1)-marker->getOld(i))*j/(float)n;39 -1 fmap[int(old*olength2)]=int(marker->new2nnew(marker->old2new(old))*length);-1 45 fmap[int(old*olength)-ostart]=int(marker->new2nnew(marker->old2new(old))*sample->getLength()); 40 46 } -1 47 */ 41 48 } 42 49 ts.setKeyFrameMap(fmap); 43 5044 -1 caller->setFinished(0.03);-1 51 sample->setFinished(0.03); 45 52 ts.study(ibuf, olength2, true);46 -1 ts.setMaxProcessSize(olength2);-1 53 ts.setMaxProcessSize(olength2*2); 47 54 int a1=-1; 48 55 int a2=0;49 -1 caller->setFinished(0.06);-1 56 sample->setFinished(0.06); 50 57 while (a1!=a2) {51 -1 int sam=ts.getSamplesRequired();52 -1 if (sam>olength2/10) sam=olength2/10;53 -1 ts.process(ibuf, sam, false);-1 58 ts.process(ibuf, ts.getSamplesRequired(), false); 54 59 a1=a2; 55 60 a2=ts.available();56 -1 caller->setFinished(a2/(float)length*0.8+0.05); // TODO doesnt really work-1 61 sample->setFinished(a2/(float)sample->getLength()*0.8+0.05); // TODO doesnt really work 57 62 }58 -1 caller->setFinished(0.8);-1 63 sample->setFinished(0.8); 59 64 ts.process(ibuf, olength2, true);60 -1 caller->setFinished(0.95);-1 65 sample->setFinished(0.95); 61 66 62 67 int avail=ts.available(); 63 68 ts.retrieve(obuf, avail); @@ -69,10 +74,11 @@ int RBprocess(int olength, float* data, int length, Marker* marker, Sample* call 69 74 data[j] = value; 70 75 } 71 7672 -1 for (int i=avail; i<length; ++i) {-1 77 for (int i=avail; i<sample->getLength(); ++i) { 73 78 data[i]=0; 74 79 } 75 80 -1 81 delete[] ibuf[0]; 76 82 delete[] ibuf; 77 83 delete[] obuf; 78 84
diff --git a/src/sample.cpp b/src/sample.cpp
@@ -136,7 +136,7 @@ Therefore it reads data from odata and writes to data. 136 136 data=new float[length]; 137 137 switch (getStretchMode()) { 138 138 // rubberband139 -1 case 1: RBprocess(olength, data, length, marker, this); break;-1 139 case 1: RBprocess(olength, data, marker, this); break; 140 140 default: { 141 141 for (int i=0; i<length; ++i) { 142 142 data[i]=getOld(marker->new2old(marker->nnew2new(i/(float)length)));