- commit
- 81461f14162d4b6566acbd782a36c2dbad76e191
- parent
- 8c437edfe3e0c9a42c29b9317f53fd6c3e66ee70
- Author
- Tobias Bengfort <tobias.bengfort@gmx.net>
- Date
- 2010-11-21 14:27
intmode_poly fix
Diffstat
| M | src/curve.cpp | 5 | +++++ |
| M | src/curve.h | 1 | + |
| M | src/gui/RetimerMainFrame.cpp | 14 | ++++++++++++-- |
| M | src/gui/RetimerMainFrame.h | 1 | + |
| M | src/intmode_poly.h | 46 | +++++++++++++++++++++++++++++----------------- |
| M | xiRetimer | 0 |
6 files changed, 48 insertions, 19 deletions
diff --git a/src/curve.cpp b/src/curve.cpp
@@ -82,3 +82,8 @@ float Curve::getMarker(int i) {return marker->new2nnew(marker->getNew(i));}
82 82
83 83 void Curve::clearMarker() {marker->reset();}
84 84
-1 85 bool Curve::showIntLine() {
-1 86 // TODO showIntLine
-1 87 return false;
-1 88 }
-1 89
diff --git a/src/curve.h b/src/curve.h
@@ -32,6 +32,7 @@ public: 32 32 float getBeatResolution(); 33 33 void setTempo(int bpm); 34 34 int getTempo(); -1 35 bool showIntLine(); 35 36 private: 36 37 Marker* marker; 37 38 Sample* sample;
diff --git a/src/gui/RetimerMainFrame.cpp b/src/gui/RetimerMainFrame.cpp
@@ -18,6 +18,7 @@ RetimerMainFrame::RetimerMainFrame( wxWindow* parent ) : MainFrame( parent ) {
18 18
19 19 brushbg=new wxBrush(*wxBLACK);
20 20 penCurve=new wxPen(*wxBLUE,1);
-1 21 penCurve2=new wxPen(*wxRED,1);
21 22 penSeeker=new wxPen(*wxWHITE,1);
22 23 penMarker=new wxPen(wxColor(255,255,0),1);
23 24 wxBitmap waveform;
@@ -189,6 +190,16 @@ void RetimerMainFrame::paint(wxDC* dc) {
189 190 float max=1+curve->getMax(i/(float)width, 1/(float)width);
190 191 mdc.DrawLine(i,int(min*height/2),i,int(max*height/2));
191 192 }
-1 193 if (curve->showIntLine()) {
-1 194 mdc.SetPen(*penCurve2);
-1 195 float x1;
-1 196 float x2=marker->new2nnew(marker->old2new(0));
-1 197 for (int i=0; i<height-1; ++i) {
-1 198 x1=x2;
-1 199 x2=marker->new2nnew(marker->old2new((i+1)/(float)height));
-1 200 mdc.DrawLine(int(x1*width),i,int(x2*width),i+1);
-1 201 }
-1 202 }
192 203 _updateWaveform=false;
193 204 }
194 205 bdc.DrawBitmap(waveform,0,0,false);
@@ -227,8 +238,7 @@ void RetimerMainFrame::OnSize( wxSizeEvent& event ) {
227 238 void RetimerMainFrame::process() {
228 239 // sometings wrong here
229 240 if (sample->process()!=0)
230 -1 // reportError(_T("Could not process data!"));
231 -1 {}
-1 241 reportError(_T("Could not process data!"));
232 242
233 243 wxProgressDialog::wxProgressDialog* dialog = new wxProgressDialog( _T("processing..."), _T("please wait") );
234 244 dialog ->Show();
diff --git a/src/gui/RetimerMainFrame.h b/src/gui/RetimerMainFrame.h
@@ -70,6 +70,7 @@ Curve* curve; 70 70 71 71 wxBrush* brushbg; 72 72 wxPen* penCurve; -1 73 wxPen* penCurve2; 73 74 wxPen* penSeeker; 74 75 wxPen* penMarker; 75 76 wxBitmap waveform;
diff --git a/src/intmode_poly.h b/src/intmode_poly.h
@@ -26,26 +26,25 @@ float** invertMatrix(float** A) {
26 26 n-=A[0][1]*A[1][0]*A[2][2];
27 27 n-=A[0][2]*A[1][1]*A[2][0];
28 28
29 -1 if(n*n<=0.1) {
-1 29 if(n*n<=0.00000000001) {
30 30 for (int i=0; i<3; ++i) {
31 31 for (int j=0; j<3; ++j) {
32 32 X[i][j]=0;
33 33 }
34 -1 X[i][i]=1;
35 34 }
36 35 return X;
37 36 }
38 37
39 38 X[0][0]=A[1][1]*A[2][2]-(A[2][1]*A[1][2]);
40 -1 X[0][1]=(-1)*(A[0][1]*A[2][2]-(A[0][2]*A[2][1]));
41 -1 X[0][2]=A[0][1]*A[1][2]-(A[0][2]*A[1][1]);
-1 39 X[1][0]=(-1)*(A[1][0]*A[2][2]-(A[2][0]*A[1][2]));
-1 40 X[2][0]=A[1][0]*A[2][1]-(A[2][0]*A[1][1]);
42 41
43 -1 X[1][0]=(-1)*(A[1][0]*A[2][2]-A[1][2]*A[2][0]);
-1 42 X[0][1]=(-1)*(A[0][1]*A[2][2]-A[2][1]*A[0][2]);
44 43 X[1][1]=A[0][0]*A[2][2]-A[0][2]*A[2][0];
45 -1 X[1][2]=(-1)*(A[0][0]*A[1][2]-A[0][2]*A[1][0]);
-1 44 X[2][1]=(-1)*(A[0][0]*A[2][1]-A[2][0]*A[0][1]);
46 45
47 -1 X[2][0]=A[1][0]*A[2][1]-A[1][1]*A[2][0];
48 -1 X[2][1]=(-1)*(A[0][0]*A[2][1]-A[0][1]*A[2][0]);
-1 46 X[0][2]=A[0][1]*A[1][2]-A[1][1]*A[0][2];
-1 47 X[1][2]=(-1)*(A[0][0]*A[1][2]-A[1][0]*A[0][2]);
49 48 X[2][2]=A[0][0]*A[1][1]-A[1][0]*A[0][1];
50 49
51 50 for(i=0;i<3;i++) {
@@ -81,13 +80,13 @@ float int_poly(Marker* marker, float old) {
81 80 M[j]=new float[3];
82 81 }
83 82
84 -1 M[0][0]=3*x1*x1*x1;
85 -1 M[0][1]=2*x1*x1;
86 -1 M[0][2]=x1;
-1 83 M[0][0]=3*x1*x1;
-1 84 M[0][1]=2*x1;
-1 85 M[0][2]=1;
87 86
88 -1 M[1][0]=3*x2*x2*x2;
89 -1 M[1][1]=2*x2*x2;
90 -1 M[1][2]=x2;
-1 87 M[1][0]=3*x2*x2;
-1 88 M[1][1]=2*x2;
-1 89 M[1][2]=1;
91 90
92 91 M[2][0]=x2*x2*x2-x1*x1*x1;
93 92 M[2][1]=x2*x2-x1*x1;
@@ -95,14 +94,27 @@ float int_poly(Marker* marker, float old) {
95 94
96 95 float** I=invertMatrix(M);
97 96
-1 97 int zeros=0;
-1 98 for (int j=0; j<3; ++j) {
-1 99 for (int jj=0; jj<3; ++jj) {
-1 100 if (I[j][jj]==0) zeros++;
-1 101 }
-1 102 }
-1 103 if (zeros==9) {
-1 104 float c=(y2-y1)/(x2-x1);
-1 105 float d=y1;
-1 106 return c*(old-x1)+d;
-1 107 }
-1 108
-1 109
98 110 for (int j=0; j<3; ++j) {
99 111 delete[] M[j];
100 112 }
101 113 delete[] M;
102 114
103 -1 float a=I[0][0]*d1*x1+I[0][1]*d2*x2+I[0][2]*(y2-y1);
104 -1 float b=I[1][0]*d1*x1+I[1][1]*d2*x2+I[1][2]*(y2-y1);
105 -1 float c=I[2][0]*d1*x1+I[2][1]*d2*x2+I[2][2]*(y2-y1);
-1 115 float a=I[0][0]*d1+I[0][1]*d2+I[0][2]*(y2-y1);
-1 116 float b=I[1][0]*d1+I[1][1]*d2+I[1][2]*(y2-y1);
-1 117 float c=I[2][0]*d1+I[2][1]*d2+I[2][2]*(y2-y1);
106 118 float d=y1-a*x1*x1*x1-b*x1*x1-c*x1;
107 119
108 120 for (int j=0; j<3; ++j) {