xiRetimer

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

commit
2fe28545f89bacd52a4c4db33b3a5c568fdc61eb
parent
2d192a61744920741155490dbae6b0f7c69b1f43
Author
xi <tobias.bengfort@gmx.net>
Date
2010-11-01 16:54
display Marker

Diffstat

M gui/a.out 0
D gui/curve.cpp 50 --------------------------------------------------
D gui/curve.h 46 ----------------------------------------------
M gui/make 2 +-
M gui/xiRTMainFrame.cpp 23 ++++++++++++++---------
M gui/xiRTMainFrame.h 5 ++---

6 files changed, 17 insertions, 109 deletions


diff --git a/gui/a.out b/gui/a.out

Binary files differ.

diff --git a/gui/curve.cpp b/gui/curve.cpp

@@ -1,50 +0,0 @@
    1    -1 #include "curve.h"
    2    -1 
    3    -1 #include <cmath>
    4    -1 
    5    -1 Curve::Curve() {
    6    -1   marker=new Marker();
    7    -1   sample=new Sample(marker);
    8    -1   seeker=0;
    9    -1   tempo=90;
   10    -1 }
   11    -1 
   12    -1 Curve::~Curve() {
   13    -1   delete[] sample;
   14    -1   delete[] marker;
   15    -1 }
   16    -1 
   17    -1 float Curve::get(float nn) {
   18    -1   // TODO interpolation?
   19    -1   return sample->get(nn);
   20    -1 }
   21    -1 
   22    -1 float Curve::getSeeker() {return seeker;}
   23    -1 void Curve::setSeeker(float nn) {
   24    -1   if (nn>=0 && nn<=1) seeker=nn;
   25    -1 }
   26    -1 
   27    -1 void Curve::setTempo(int bpm) {tempo=bpm;}
   28    -1 int Curve::getTempo() {return tempo;}
   29    -1 
   30    -1 void Curve::addMarker() {
   31    -1   float n=marker->nnew2new(seeker);
   32    -1   marker->add(marker->new2old(n),n);
   33    -1 }
   34    -1 
   35    -1 void Curve::removeMarker() {
   36    -1   int i=marker->getAreaNew(marker->nnew2new(seeker));
   37    -1   marker->remove(i);
   38    -1 }
   39    -1 
   40    -1 void Curve::print() {
   41    -1   for (int i=0; i<100; ++i) { // 100 or any number 
   42    -1     for (float j=-1; j<get(i); j+=0.1)
   43    -1       std::cout << "+";
   44    -1     if (std::abs(getSeeker()-i)<0.01)
   45    -1       std::cout << " *";
   46    -1     std::cout << std::endl;
   47    -1   }
   48    -1 }
   49    -1 
   50    -1 

diff --git a/gui/curve.h b/gui/curve.h

@@ -1,46 +0,0 @@
    1    -1 #ifndef __XICURVE_H
    2    -1 #define __XICURVE_H
    3    -1 
    4    -1 #include <iostream>
    5    -1 #include "../src/sample.h"
    6    -1 
    7    -1 // main part of the gui
    8    -1 // layer between screen and backend. Converts everything to screen (0-1) values
    9    -1 class Curve {
   10    -1 public:
   11    -1   Curve(); 
   12    -1   ~Curve();
   13    -1   float getSeeker();
   14    -1   void setSeeker(float nn);
   15    -1   void setTempo(int bpm);
   16    -1   int getTempo();
   17    -1   void print();
   18    -1   // direct access to sample
   19    -1   Sample* sample;
   20    -1   // indirect access to sample
   21    -1   float get(float nn);
   22    -1   // indirect access to marker
   23    -1   void addMarker();
   24    -1   void removeMarker();
   25    -1   // TODO indirect acces for drawing
   26    -1 private:
   27    -1   float seeker; // 0-1
   28    -1   Marker* marker;
   29    -1   int tempo; // bpm
   30    -1 };
   31    -1 
   32    -1 /*
   33    -1 int main() {
   34    -1   Marker* m=new Marker();
   35    -1   Sample* s=new Sample(m);
   36    -1   m->add(0.5,0.3);
   37    -1   int error;
   38    -1   error=s->loadFile("../../test.wav");
   39    -1   
   40    -1   Curve c(s);
   41    -1   c.setScreenWidth(100);
   42    -1   c.print();
   43    -1 }
   44    -1 */
   45    -1 
   46    -1 #endif

diff --git a/gui/make b/gui/make

@@ -1,2 +1,2 @@
    1     1 g++ *.h *.cpp ../src/*.h ../src/*.cpp `wx-config --cxxflags --libs` `pkg-config --cflags --libs rubberband sndfile`
    2    -1 rm *.gch
   -1     2 rm ../*/*.gch

diff --git a/gui/xiRTMainFrame.cpp b/gui/xiRTMainFrame.cpp

@@ -8,9 +8,14 @@
    8     8 #include <wx/string.h>
    9     9 #include <wx/filedlg.h>
   10    10 
   -1    11 // TODO move seeker with mouse
   -1    12 // TODO icon bar
   -1    13 
   11    14 xiRTMainFrame::xiRTMainFrame( wxWindow* parent ) : MainFrame( parent ) {
   12    15   curve=new Curve();
   13    16   sample=curve->sample;
   -1    17   curve->setSeeker(0.7);
   -1    18   curve->addMarker();
   14    19   curve->setSeeker(0.3);
   15    20 }
   16    21 
@@ -18,7 +23,6 @@ xiRTMainFrame::~xiRTMainFrame() {
   18    23   delete[] curve;
   19    24 }
   20    25 
   21    -1 
   22    26 void xiRTMainFrame::OnOpenClick( wxCommandEvent& event )
   23    27 {
   24    28     wxFileDialog* dialog = new wxFileDialog( (wxWindow*)NULL );
@@ -64,8 +68,10 @@ void xiRTMainFrame::OnAboutClick( wxCommandEvent& event )
   64    68 }
   65    69 
   66    70 void xiRTMainFrame::OnProcessClick( wxCommandEvent& event ) {
   -1    71     // TODO Link process with process bar
   67    72     wxProgressDialog::wxProgressDialog* dialog = new wxProgressDialog( _T("processing..."), _T("please wait") );
   68    73     dialog ->Show();
   -1    74     sample->process();
   69    75 }
   70    76 
   71    77 void xiRTMainFrame::OnMSetClick( wxCommandEvent& event )
@@ -79,7 +85,7 @@ void xiRTMainFrame::OnMRmClick( wxCommandEvent& event )
   79    85 }
   80    86 
   81    87 void xiRTMainFrame::paint() {
   82    -1   // TODO BufferedDC
   -1    88   // TODO dont repaint all the time
   83    89   wxClientDC dc2(this);
   84    90   int w=0;
   85    91   int h=0;
@@ -98,14 +104,13 @@ void xiRTMainFrame::paint() {
   98   104     dc.DrawLine(i,int(curve->get(i/(float)(w-1))*h+h)/2,i+1,int(curve->get((i+1)/(float)(w-1))*h+h)/2);
   99   105   }
  100   106   // TODO display tempo bars ...
  101    -1   // TODO display marker
  102    -1 //  dc.SetPen(penMarker);
  103    -1 //  for (int i=0; i<marker->getLength(); ++i) {
  104    -1 //    int n=int(marker->getNew(i)*w/marker->getNew(marker->getLength()-1));
  105    -1 //    dc.DrawLine(n,0,n,h);
  106    -1 //  }
   -1   107   dc.SetPen(penMarker);
   -1   108   for (int i=0; i<curve->getMarkerLength(); ++i) {
   -1   109     int n=int(curve->getMarker(i)*(w-1));
   -1   110     dc.DrawLine(n,0,n,h);
   -1   111   }
  107   112   dc.SetPen(penSeeker);
  108    -1   int seek=int(curve->getSeeker()*w);
   -1   113   int seek=int(curve->getSeeker()*(w-1));
  109   114   dc.DrawLine(seek,0,seek,h);
  110   115 }
  111   116 

diff --git a/gui/xiRTMainFrame.h b/gui/xiRTMainFrame.h

@@ -8,8 +8,7 @@ Subclass of MainFrame, which is generated by wxFormBuilder.
    8     8 
    9     9 #include "xiRetimer_wxfb.h"
   10    10 #include "../src/sample.h"
   11    -1 #include "../src/marker.h"
   12    -1 #include "curve.h"
   -1    11 #include "../src/curve.h"
   13    12 
   14    13 
   15    14 /** Implementing MainFrame */
@@ -23,7 +22,7 @@ protected:
   23    22 	void OnExitClick( wxCommandEvent& event );
   24    23 	void OnHelpClick( wxCommandEvent& event );
   25    24 	void OnAboutClick( wxCommandEvent& event );
   26    -1         void OnProcessClick( wxCommandEvent& event );
   -1    25   void OnProcessClick( wxCommandEvent& event );
   27    26 	void OnMSetClick( wxCommandEvent& event );
   28    27 	void OnMRmClick( wxCommandEvent& event );
   29    28         void OnUpdateUI( wxUpdateUIEvent& event );