- commit
- a90f732b9db8364bf852308fe020cbb1b714d4de
- parent
- 73f7731e85abf361e0d5a143b354281fb8a3bc87
- Author
- Tobias Bengfort <tobias.bengfort@gmx.net>
- Date
- 2010-11-02 21:24
beat markers
Diffstat
| M | README | 1 | + |
| M | src/curve.cpp | 12 | ++++++++++++ |
| M | src/curve.h | 9 | +++++++-- |
| M | src/gui/xiRTMainFrame.cpp | 23 | ++++++++++++++++------- |
| M | src/gui/xiRTMainFrame.h | 2 | ++ |
| M | src/sample.cpp | 4 | ++++ |
| M | src/sample.h | 3 | ++- |
| M | xiRetimer | 0 |
8 files changed, 44 insertions, 10 deletions
diff --git a/README b/README
@@ -15,3 +15,4 @@ playback !! 15 15 exits with error 16 16 improve AudioShape 17 17 bugtracking -1 18 libmad
diff --git a/src/curve.cpp b/src/curve.cpp
@@ -10,6 +10,7 @@ Curve::Curve() {
10 10 seeker=0;
11 11 tempo=90;
12 12 selMarker=-1;
-1 13 beatResolution=1;
13 14 }
14 15
15 16 Curve::~Curve() {
@@ -27,9 +28,20 @@ void Curve::setSeeker(float nn) {
27 28 if (nn>=0 && nn<=1) seeker=nn;
28 29 }
29 30
-1 31 float Curve::getBars() {
-1 32 int beats=sample->getGuessedLength()/(float)sample->sfinfo.samplerate/60/4*tempo;
-1 33 if (beats!=0)
-1 34 return beats;
-1 35 else
-1 36 return 1;
-1 37 }
-1 38
30 39 void Curve::setTempo(int bpm) {tempo=bpm;}
31 40 int Curve::getTempo() {return tempo;}
32 41
-1 42 void Curve::setBeatResolution(float n) {beatResolution=n;}
-1 43 float Curve::getBeatResolution() {return beatResolution;}
-1 44
33 45 void Curve::addMarker() {
34 46 float n=marker->nnew2new(seeker);
35 47 marker->add(marker->new2old(n),n);
diff --git a/src/curve.h b/src/curve.h
@@ -12,8 +12,6 @@ public: 12 12 ~Curve(); 13 13 float getSeeker(); 14 14 void setSeeker(float nn);15 -1 void setTempo(int bpm);16 -1 int getTempo();17 15 void print(); 18 16 // direct access to sample 19 17 Sample* sample; @@ -27,11 +25,18 @@ public: 27 25 void selectMarker(int i); 28 26 void setMarker(float nn); 29 27 void clearMarker(); -1 28 // bars -1 29 float getBars(); -1 30 void setBeatResolution(float n); -1 31 float getBeatResolution(); -1 32 void setTempo(int bpm); -1 33 int getTempo(); 30 34 private: 31 35 float seeker; // 0-1 32 36 Marker* marker; 33 37 int tempo; // bpm 34 38 int selMarker; -1 39 float beatResolution; 35 40 }; 36 41 37 42 /*
diff --git a/src/gui/xiRTMainFrame.cpp b/src/gui/xiRTMainFrame.cpp
@@ -15,6 +15,7 @@ xiRTMainFrame::xiRTMainFrame( wxWindow* parent ) : MainFrame( parent ) {
15 15 sample=curve->sample;
16 16 curve->setSeeker(0);
17 17 width=100; // anything greater than 2
-1 18 height=100;
18 19 Marker_move=false;
19 20 Seeker_move=false;
20 21 }
@@ -102,7 +103,7 @@ void xiRTMainFrame::OnPlayClick( wxCommandEvent& event ) {
102 103 }
103 104
104 105 void xiRTMainFrame::OnEndClick( wxCommandEvent& event ) {
105 -1 curve->setSeeker(0);
-1 106 curve->setSeeker(1);
106 107 }
107 108
108 109 // ************ general **************
@@ -147,9 +148,9 @@ void xiRTMainFrame::OnUpdateUI( wxUpdateUIEvent& event ) {paint();}
147 148 void xiRTMainFrame::paint() {
148 149 // TODO dont repaint all the time
149 150 wxClientDC dc2(this);
150 -1 int h=0;
151 -1 dc2.GetSize(&width,&h);
152 -1 wxBufferedDC dc(&dc2,wxSize(width,h));
-1 151 dc2.GetSize(&width,&height);
-1 152 wxBufferedDC dc(&dc2,wxSize(width,height));
-1 153 int h=height-BEAT;
153 154
154 155 wxBrush brush(*wxBLACK); // red pen of width 1
155 156 dc.SetBackground(brush);
@@ -160,13 +161,13 @@ void xiRTMainFrame::paint() {
160 161 dc.Clear();
161 162 // TODO nicer looking shape
162 163 for (int i=0; i<width-1; ++i) {
163 -1 dc.DrawLine(i,int(curve->get(i/(float)(width-1))*h+h)/2,i+1,int(curve->get((i+1)/(float)(width-1))*h+h)/2);
-1 164 dc.DrawLine(i,int(curve->get(i/(float)(width-1))*h+height)/2,i+1,int(curve->get((i+1)/(float)(width-1))*h+height)/2);
164 165 }
165 166 // TODO display tempo bars !!!
166 167 dc.SetPen(penMarker);
167 168 for (int i=0; i<curve->getMarkerLength(); ++i) {
168 169 int n=int(curve->getMarker(i)*(width-1));
169 -1 dc.DrawLine(n,0,n,h);
-1 170 dc.DrawLine(n,0,n,height);
170 171 wxPoint ps[3];
171 172 wxPoint p0(n-MARKERWIDTH/2,0);
172 173 ps[0]=p0;
@@ -176,8 +177,16 @@ void xiRTMainFrame::paint() {
176 177 ps[2]=p2;
177 178 dc.DrawPolygon(3,ps);
178 179 }
-1 180 // seeker
179 181 dc.SetPen(penSeeker);
180 182 int seek=int(curve->getSeeker()*(width-1));
181 -1 dc.DrawLine(seek,0,seek,h);
-1 183 dc.DrawLine(seek,0,seek,height);
-1 184 //beats
-1 185 dc.SetPen(penMarker);
-1 186 int step=int(width/curve->getBars()/curve->getBeatResolution());
-1 187 for (int i=0; i<width && step!=0; i+=step) {
-1 188 dc.DrawLine(i,0,i,BEAT);
-1 189 }
-1 190
182 191 }
183 192
diff --git a/src/gui/xiRTMainFrame.h b/src/gui/xiRTMainFrame.h
@@ -39,10 +39,12 @@ protected: 39 39 40 40 void paint(); 41 41 static const int MARKERWIDTH=15; -1 42 static const int BEAT=15; 42 43 43 44 Sample* sample; 44 45 Curve* curve; 45 46 int width; -1 47 int height; 46 48 bool Marker_move; 47 49 bool Seeker_move; 48 50
diff --git a/src/sample.cpp b/src/sample.cpp
@@ -16,6 +16,10 @@ int Sample::getLength() {
16 16 return length;
17 17 }
18 18
-1 19 int Sample::getGuessedLength() {
-1 20 return int(olength*marker->getRatio());
-1 21 }
-1 22
19 23 float Sample::get(float nn) {
20 24 // TODO interpolation?
21 25 int i=int((getLength()-1)*nn);
diff --git a/src/sample.h b/src/sample.h
@@ -14,15 +14,16 @@ public: 14 14 float get(float nn); // nnew 15 15 float getOld(float o); 16 16 int getLength(); -1 17 int getGuessedLength(); 17 18 int loadFile(const char* filename); 18 19 int writeFile(const char* filename); 19 20 int process(); -1 21 SF_INFO sfinfo; 20 22 private: 21 23 int length; 22 24 Marker* marker; 23 25 int olength; 24 26 float *odata;25 -1 SF_INFO sfinfo;26 27 }; 27 28 28 29 /*