- commit
- 523fb4d22e3a5d59daaf145f6de0c6b8ab9b9d64
- parent
- e790b326f0358fd13860fde1c1b9bb352492f9e7
- Author
- Tobias Bengfort <tobias.bengfort@gmx.net>
- Date
- 2014-01-26 14:14
formatting
Diffstat
| M | configure.ac | 24 | ++++++++++++------------ |
| M | src/curve.cpp | 140 | ++++++++++++++++++++++++++++++++++++++++--------------------- |
| M | src/curve.h | 66 | +++++++++++++++++++++++++++++++------------------------------ |
| M | src/gui/RetimerAboutDialog.cpp | 10 | +++------- |
| M | src/gui/RetimerAboutDialog.h | 16 | +++++++--------- |
| M | src/gui/RetimerMainFrame.cpp | 450 | +++++++++++++++++++++++++++++++------------------------------ |
| M | src/gui/RetimerMainFrame.h | 99 | ++++++++++++++++++++++++++++++------------------------------- |
| M | src/gui/main.cpp | 21 | ++++++++++----------- |
| M | src/gui/main.h | 11 | +++++------ |
| M | src/gui/retimer_wx.cpp | 410 | ++++++++++++++++++++++++++++++------------------------------- |
| M | src/gui/retimer_wx.cpp.in | 410 | ++++++++++++++++++++++++++++++------------------------------- |
| M | src/gui/retimer_wx.h | 85 | +++++++++++++++++++++++++------------------------------------ |
| M | src/intmode_poly.h | 261 | ++++++++++++++++++++++++++++++++----------------------------- |
| M | src/marker.cpp | 359 | ++++++++++++++++++++++++++++++++++++------------------------- |
| M | src/marker.h | 97 | ++++++++++++++++++++++++++++++------------------------------- |
| M | src/rbprocess.h | 117 | +++++++++++++++++++++++++++++++------------------------------ |
| M | src/sample.cpp | 273 | ++++++++++++++++++++++++++++++++++++------------------------- |
| M | src/sample.h | 79 | ++++++++++++++++++++++++++----------------------------------- |
| M | src/xiarray.cpp | 100 | ++++++++++++++++++++++++++++++++++++------------------------- |
| M | src/xiarray.h | 44 | ++++++++++++++++++-------------------------- |
20 files changed, 1610 insertions, 1462 deletions
diff --git a/configure.ac b/configure.ac
@@ -16,16 +16,17 @@ AC_SUBST(_PKGC) 16 16 # check files 17 17 AC_CHECK_FILES( 18 18 /usr/share/icons/gnome/16x16/actions/fileopen.png19 -1 /usr/share/icons/gnome/16x16/actions/document-save.png20 -1 /usr/share/icons/gnome/16x16/actions/document-properties.png21 -1 /usr/share/icons/gnome/16x16/actions/window-close.png22 -1 /usr/share/icons/gnome/16x16/actions/media-playback-start.png23 -1 /usr/share/icons/gnome/16x16/actions/media-skip-backward.png24 -1 /usr/share/icons/gnome/16x16/actions/edit-clear.png25 -1 /usr/share/icons/gnome/16x16/actions/stock_refresh.png-1 19 /usr/share/icons/gnome/16x16/actions/document-save.png -1 20 /usr/share/icons/gnome/16x16/actions/document-properties.png -1 21 /usr/share/icons/gnome/16x16/actions/window-close.png -1 22 /usr/share/icons/gnome/16x16/actions/media-playback-start.png -1 23 /usr/share/icons/gnome/16x16/actions/media-skip-backward.png -1 24 /usr/share/icons/gnome/16x16/actions/edit-clear.png -1 25 /usr/share/icons/gnome/16x16/actions/stock_refresh.png 26 26 /usr/share/icons/gnome/16x16/actions/help-about.png, 27 27 [],[icons="error"])28 -1 if test "x$icons" = "x" ; then-1 28 -1 29 if test "x$icons" = "x" ; then 29 30 _CFLAGS="$_CFLAGS -DICONS_GNOME" 30 31 echo " Compiling with Gnome icons" 31 32 else @@ -55,7 +56,7 @@ PKG_CHECK_MODULES([RubberBand],[rubberband >= 1.4], 55 56 [ 56 57 _CFLAGS="$_CFLAGS -DMODE_RUBBERBAND" 57 58 _PKGC="$_PKGC rubberband"58 -1 echo " Compiling with RubberBand support"],-1 59 echo " Compiling with RubberBand support"], 59 60 [ 60 61 _CFLAGS="$_CFLAGS -UMODE_RUBBERBAND" 61 62 echo " Compiling without RubberBand support!" @@ -64,8 +65,8 @@ PKG_CHECK_MODULES([RubberBand],[rubberband >= 1.4], 64 65 PKG_CHECK_MODULES([MAD],[mad], 65 66 [ 66 67 _CFLAGS="$_CFLAGS -DENABLE_MP3"67 -1 # _PKGC="$_PKGC rubberband"68 -1 echo " Compiling with mp3 support"],-1 68 #_PKGC="$_PKGC rubberband" -1 69 echo " Compiling with mp3 support"], 69 70 [ 70 71 _CFLAGS="$_CFLAGS -UENABLE_MP3" 71 72 echo " Compiling without mp3 support!" @@ -80,4 +81,3 @@ AC_CONFIG_FILES([makefile 80 81 README 81 82 ]) 82 83 AC_OUTPUT83 -1
diff --git a/src/curve.cpp b/src/curve.cpp
@@ -1,86 +1,132 @@ 1 1 #include "curve.h" 2 2 -1 3 3 4 Curve::Curve(Marker* m, Sample* s, Playback* p) {4 -1 marker=m;5 -1 sample=s;6 -1 playback=p;7 -1 tempo=90;8 -1 selMarker=-1;9 -1 beatResolution=1;10 -1 _showIntLine=false;11 -1 _update=true;-1 5 marker = m; -1 6 sample = s; -1 7 playback = p; -1 8 tempo = 90; -1 9 selMarker = -1; -1 10 beatResolution = 1; -1 11 _showIntLine = false; -1 12 _update = true; 12 13 } 13 14 -1 15 14 16 Curve::~Curve() {15 -1 delete[] sample;16 -1 delete[] marker;-1 17 delete[] sample; -1 18 delete[] marker; 17 19 } 18 20 -1 21 19 22 float Curve::get(float nn) {20 -1 return sample->getOld(marker->new2old(marker->nnew2new(nn)));-1 23 return sample->getOld(marker->new2old(marker->nnew2new(nn))); 21 24 } 22 25 -1 26 23 27 float Curve::getMin(float nn, float l, int n) {24 -1 float min=1;25 -1 for (int i=0; i<n; ++i) {26 -1 float g=get(nn+l*i/(float)n);27 -1 if (g<min) min=g;28 -1 }29 -1 return min;-1 28 float min = 1; -1 29 for (int i = 0; i < n; ++i) { -1 30 float g = get(nn + l * i / (float)n); -1 31 if (g < min) { -1 32 min = g; -1 33 } -1 34 } -1 35 return min; 30 36 } 31 37 -1 38 32 39 float Curve::getMax(float nn, float l, int n) {33 -1 float max=-1;34 -1 for (int i=0; i<n; ++i) {35 -1 float g=get(nn+l*i/(float)n);36 -1 if (g>max) max=g;37 -1 }38 -1 return max;-1 40 float max = -1; -1 41 for (int i = 0; i < n; ++i) { -1 42 float g = get(nn + l * i / (float)n); -1 43 if (g > max) { -1 44 max = g; -1 45 } -1 46 } -1 47 return max; 39 48 } 40 49 -1 50 41 51 float Curve::getSeeker() {42 -1 return playback->getSeeker();-1 52 return playback->getSeeker(); 43 53 } 44 54 -1 55 45 56 float Curve::getBars() {46 -1 int beats=sample->getGuessedLength()/(float)sample->sfinfo.samplerate/60/4*tempo;47 -1 if (beats!=0)48 -1 return beats;49 -1 else50 -1 return 1;-1 57 int beats = sample->getGuessedLength() / sample->sfinfo.samplerate; -1 58 beats *= tempo / 60 / 4; -1 59 if (beats != 0) { -1 60 return beats; -1 61 } else { -1 62 return 1; -1 63 } 51 64 } 52 6553 -1 void Curve::setTempo(int bpm) {tempo=bpm;}54 -1 int Curve::getTempo() {return tempo;}55 6656 -1 void Curve::setBeatResolution(float n) {beatResolution=n;}57 -1 float Curve::getBeatResolution() {return beatResolution;}-1 67 void Curve::setTempo(int bpm) { -1 68 tempo = bpm; -1 69 } -1 70 -1 71 -1 72 int Curve::getTempo() { -1 73 return tempo; -1 74 } -1 75 -1 76 -1 77 void Curve::setBeatResolution(float n) { -1 78 beatResolution = n; -1 79 } -1 80 -1 81 -1 82 float Curve::getBeatResolution() { -1 83 return beatResolution; -1 84 } -1 85 58 86 59 87 void Curve::addMarker() {60 -1 float n=marker->nnew2new(getSeeker());61 -1 marker->add(marker->new2old(n),n);62 -1 selMarker=marker->getAreaNew(n);-1 88 float n = marker->nnew2new(getSeeker()); -1 89 marker->add(marker->new2old(n),n); -1 90 selMarker = marker->getAreaNew(n); 63 91 } 64 92 -1 93 65 94 void Curve::removeMarker() {66 -1 if (selMarker<0) return;67 -1 marker->remove(selMarker);68 -1 selMarker=-1;-1 95 if (selMarker < 0) { -1 96 return; -1 97 } -1 98 marker->remove(selMarker); -1 99 selMarker = -1; 69 100 } 70 101 -1 102 71 103 void Curve::setMarker(float nn) {72 -1 if (selMarker<0) return;73 -1 int i=marker->getAreaNew(marker->nnew2new(nn));74 -1 if (i!=selMarker && i!=selMarker-1) return;75 -1 marker->setNew(selMarker,marker->nnew2new(nn));-1 104 if (selMarker < 0) { -1 105 return; -1 106 } -1 107 int i = marker->getAreaNew(marker->nnew2new(nn)); -1 108 if (i != selMarker && i != selMarker - 1) { -1 109 return; -1 110 } -1 111 marker->setNew(selMarker, marker->nnew2new(nn)); 76 112 } 77 113 -1 114 78 115 void Curve::selectMarker(int i) {79 -1 selMarker=i;-1 116 selMarker = i; 80 117 } 81 11882 -1 int Curve::getMarkerLength() {return marker->getLength();}83 -1 float Curve::getMarker(int i) {return marker->new2nnew(marker->getNew(i));}84 11985 -1 void Curve::clearMarker() {marker->reset();}-1 120 int Curve::getMarkerLength() { -1 121 return marker->getLength(); -1 122 } -1 123 -1 124 -1 125 float Curve::getMarker(int i) { -1 126 return marker->new2nnew(marker->getNew(i)); -1 127 } -1 128 86 129 -1 130 void Curve::clearMarker() { -1 131 marker->reset(); -1 132 }
diff --git a/src/curve.h b/src/curve.h
@@ -8,39 +8,41 @@ 8 8 9 9 // main part of the gui 10 10 // layer between screen and backend. Converts everything to screen (0-1) values -1 11 11 12 class Curve {12 -1 public:13 -1 Curve(Marker* m, Sample* s, Playback* p);14 -1 ~Curve();15 -1 // indirect access to playback16 -1 float getSeeker();17 -1 // indirect access to sample18 -1 float get(float nn);19 -1 float getMin(float nn, float l, int n=10); // nicer looking waveform20 -1 float getMax(float nn, float l, int n=10); // nicer looking waveform21 -1 // indirect access to marker22 -1 void addMarker();23 -1 void removeMarker();24 -1 int getMarkerLength();25 -1 float getMarker(int i);26 -1 void selectMarker(int i);27 -1 void setMarker(float nn);28 -1 void clearMarker();29 -1 // bars30 -1 float getBars();31 -1 void setBeatResolution(float n);32 -1 float getBeatResolution();33 -1 void setTempo(int bpm);34 -1 int getTempo();35 -1 bool _showIntLine;36 -1 bool _update;37 -1 private:38 -1 Marker* marker;39 -1 Sample* sample;40 -1 Playback* playback;41 -1 int tempo; // bpm42 -1 int selMarker;43 -1 float beatResolution;-1 13 public: -1 14 Curve(Marker* m, Sample* s, Playback* p); -1 15 ~Curve(); -1 16 // indirect access to playback -1 17 float getSeeker(); -1 18 // indirect access to sample -1 19 float get(float nn); -1 20 float getMin(float nn, float l, int n=10); // nicer looking waveform -1 21 float getMax(float nn, float l, int n=10); // nicer looking waveform -1 22 // indirect access to marker -1 23 void addMarker(); -1 24 void removeMarker(); -1 25 int getMarkerLength(); -1 26 float getMarker(int i); -1 27 void selectMarker(int i); -1 28 void setMarker(float nn); -1 29 void clearMarker(); -1 30 // bars -1 31 float getBars(); -1 32 void setBeatResolution(float n); -1 33 float getBeatResolution(); -1 34 void setTempo(int bpm); -1 35 int getTempo(); -1 36 bool _showIntLine; -1 37 bool _update; -1 38 -1 39 private: -1 40 Marker* marker; -1 41 Sample* sample; -1 42 Playback* playback; -1 43 int tempo; // bpm -1 44 int selMarker; -1 45 float beatResolution; 44 46 }; 45 47 46 48 #endif
diff --git a/src/gui/RetimerAboutDialog.cpp b/src/gui/RetimerAboutDialog.cpp
@@ -1,13 +1,9 @@ 1 1 #include "RetimerAboutDialog.h" 2 23 -1 RetimerAboutDialog::RetimerAboutDialog( wxWindow* parent )4 -1 :5 -1 AboutDialog( parent )6 -1 {7 -1-1 3 RetimerAboutDialog::RetimerAboutDialog(wxWindow* parent) : AboutDialog(parent) { 8 4 } 9 510 -1 void RetimerAboutDialog::OnOKClick( wxCommandEvent& event )11 -1 {-1 6 -1 7 void RetimerAboutDialog::OnOKClick(wxCommandEvent& event) { 12 8 Close(); 13 9 }
diff --git a/src/gui/RetimerAboutDialog.h b/src/gui/RetimerAboutDialog.h
@@ -9,15 +9,13 @@ Subclass of AboutDialog, which is generated by wxFormBuilder. 9 9 #include "retimer_wx.h" 10 10 11 11 /** Implementing AboutDialog */12 -1 class RetimerAboutDialog : public AboutDialog13 -1 {14 -1 protected:15 -1 // Handlers for AboutDialog events.16 -1 void OnOKClick( wxCommandEvent& event );17 -118 -1 public:19 -1 /** Constructor */20 -1 RetimerAboutDialog( wxWindow* parent );-1 12 class RetimerAboutDialog : public AboutDialog { -1 13 protected: -1 14 // Handlers for AboutDialog events. -1 15 void OnOKClick(wxCommandEvent& event); -1 16 -1 17 public: -1 18 RetimerAboutDialog(wxWindow* parent); 21 19 }; 22 20 23 21 #endif // __RetimerAboutDialog__
diff --git a/src/gui/RetimerMainFrame.cpp b/src/gui/RetimerMainFrame.cpp
@@ -5,251 +5,261 @@ 5 5 #include <iostream> 6 6 7 7 -1 8 RetimerMainFrame::RetimerMainFrame(wxWindow* parent) : MainFrame(parent) { -1 9 marker = new Marker(); -1 10 sample = new Sample(marker); -1 11 playback = new Playback(sample); -1 12 curve = new Curve(marker, sample, playback); -1 13 width = 100; // anything greater than 2 -1 14 height = 100; -1 15 Marker_move = false; -1 16 Seeker_move = false; -1 17 -1 18 brushbg = new wxBrush(*wxBLACK); -1 19 penCurve = new wxPen(*wxBLUE, 1); -1 20 penCurve2 = new wxPen(*wxRED, 1); -1 21 penSeeker = new wxPen(*wxWHITE, 1); -1 22 penMarker = new wxPen(wxColor(255, 255, 0), 1); -1 23 wxBitmap waveform; -1 24 -1 25 timer; -1 26 timer.SetOwner(this); -1 27 Connect(wxEVT_TIMER, wxTimerEventHandler(RetimerMainFrame::OnTimer)); -1 28 timer.Start(100); -1 29 } 8 309 -1 RetimerMainFrame::RetimerMainFrame( wxWindow* parent ) : MainFrame( parent ) {10 -1 marker=new Marker();11 -1 sample=new Sample(marker);12 -1 playback=new Playback(sample);13 -1 curve=new Curve(marker, sample, playback);14 -1 width=100; // anything greater than 215 -1 height=100;16 -1 Marker_move=false;17 -1 Seeker_move=false;18 3119 -1 brushbg=new wxBrush(*wxBLACK);20 -1 penCurve=new wxPen(*wxBLUE,1);21 -1 penCurve2=new wxPen(*wxRED,1);22 -1 penSeeker=new wxPen(*wxWHITE,1);23 -1 penMarker=new wxPen(wxColor(255,255,0),1);24 -1 wxBitmap waveform;-1 32 RetimerMainFrame::~RetimerMainFrame() { -1 33 timer.Stop(); -1 34 // TODO destroy objects -1 35 // delete[] curve; -1 36 // delete[] playback; -1 37 // delete[] sample; -1 38 // delete[] marker; -1 39 } 25 4026 -1 timer;27 -1 timer.SetOwner(this);28 -1 Connect( wxEVT_TIMER, wxTimerEventHandler( RetimerMainFrame::OnTimer ) );29 -1 timer.Start(100);-1 41 -1 42 // ************ mouse ************** -1 43 void RetimerMainFrame::OnLeftDown(wxMouseEvent& event) { -1 44 // check for Marker Select -1 45 if (event.m_y <= MARKERWIDTH * 4 / 5) { -1 46 for (int i = 0; i < curve->getMarkerLength(); ++i) { -1 47 int n = int(curve->getMarker(i) * (width - 1)); -1 48 if (event.m_x <= n + MARKERWIDTH / 2 && event.m_x >= n - MARKERWIDTH / 2) { -1 49 curve->selectMarker(i); -1 50 Marker_move = true; -1 51 return; -1 52 } -1 53 } -1 54 } -1 55 // if not returned set Seeker -1 56 playback->setSeeker(event.m_x / (float)width); -1 57 Seeker_move = true; -1 58 curve->selectMarker(-1); //deselct 30 59 } 31 60 32 6133 -1 RetimerMainFrame::~RetimerMainFrame() {34 -1 timer.Stop();35 -1 // TODO destroy objects36 -1 // delete[] curve;37 -1 // delete[] playback;38 -1 // delete[] sample;39 -1 // delete[] marker;40 -1 }41 -142 -1 // ************ mouse **************43 -1 void RetimerMainFrame::OnLeftDown( wxMouseEvent& event ) {44 -1 // check for Marker Select45 -1 if (event.m_y<=MARKERWIDTH*4/5) {46 -1 for (int i=0; i<curve->getMarkerLength(); ++i) {47 -1 int n=int(curve->getMarker(i)*(width-1));48 -1 if (event.m_x<=n+MARKERWIDTH/2 && event.m_x>=n-MARKERWIDTH/2) {49 -1 curve->selectMarker(i);50 -1 Marker_move=true;51 -1 return;52 -1 }53 -1 }54 -1 }55 -1 // if not returned set Seeker56 -1 playback->setSeeker(event.m_x/(float)width);57 -1 Seeker_move=true;58 -1 curve->selectMarker(-1); //deselct59 -1 }60 -161 -1 void RetimerMainFrame::OnLeftUp( wxMouseEvent& event ) {62 -1 Marker_move=false;63 -1 Seeker_move=false;64 -1 }65 -166 -1 void RetimerMainFrame::OnLeftDClick( wxMouseEvent& event ) {67 -1 // check for Marker Select68 -1 if (event.m_y<=MARKERWIDTH*4/5) {69 -1 for (int i=0; i<curve->getMarkerLength(); ++i) {70 -1 int n=int(curve->getMarker(i)*(width-1));71 -1 if (event.m_x<=n+MARKERWIDTH/2 && event.m_x>=n-MARKERWIDTH/2) {72 -1 curve->selectMarker(i);73 -1 curve->removeMarker();74 -1 curve->_update=true;75 -1 return;76 -1 }77 -1 }78 -1 }79 -1 playback->setSeeker(event.m_x/(float)width);80 -1 curve->addMarker();81 -1 }82 -183 -1 void RetimerMainFrame::OnMotion( wxMouseEvent& event ) {84 -1 if (Marker_move) {85 -1 curve->setMarker(event.m_x/(float)width);86 -1 curve->_update=true;87 -1 }88 -1 if (Seeker_move)89 -1 playback->setSeeker(event.m_x/(float)width);90 -1 }91 -192 -1 // ************ file **************93 -1 void RetimerMainFrame::OnOpenClick( wxCommandEvent& event )94 -1 {95 -1 wxFileDialog* dialog = new wxFileDialog( (wxWindow*)NULL );96 -1 dialog->Show();97 -198 -1 if (dialog->ShowModal()==wxID_OK) {99 -1 wxString filename=dialog->GetPath();100 -1 if (sample->loadFile(filename.mb_str())!=0) {101 -1 reportError( _T("Could not read from that file"));102 -1 return;103 -1 }104 -1 process();105 -1 curve->_update=true;106 -1 }107 -1 // else108 -1 // reportError( _T("Please choose a valid file!"));109 -1 }110 -1111 -1 void RetimerMainFrame::OnExportClick( wxCommandEvent& event )112 -1 {113 -1 wxFileDialog* dialog = new wxFileDialog((wxWindow*)NULL, _T("Export As"), _T(""), _T(""), _T("*.wav"), wxSAVE | wxOVERWRITE_PROMPT);114 -1 dialog->Show();115 -1116 -1 if (dialog->ShowModal()==wxID_OK) {117 -1 wxString filename=dialog->GetPath();118 -1 process();119 -1 if (sample->writeFile(filename.mb_str())!=0) {120 -1 reportError(_T("Could not write to File"));121 -1 }122 -1 }123 -1 else124 -1 reportError(_T("Could not write to File"));125 -1 }126 -1127 -1 // ************ playback **************128 -1 void RetimerMainFrame::OnStartClick( wxCommandEvent& event ) {129 -1 playback->setSeeker(0);130 -1 }131 -1132 -1 void RetimerMainFrame::OnPlayClick( wxCommandEvent& event ) {133 -1 playback->play();134 -1 }135 -1136 -1 // ************ general **************137 -1 void RetimerMainFrame::OnPrefsClick( wxCommandEvent& event )138 -1 {139 -1 RetimerPrefsDialog* dialog = new RetimerPrefsDialog(marker, sample, curve);140 -1 dialog->Show();141 -1 }142 -1143 -1 void RetimerMainFrame::OnExitClick( wxCommandEvent& event )144 -1 {145 -1 Close();146 -1 }147 -1148 -1 void RetimerMainFrame::OnHelpClick( wxCommandEvent& event )149 -1 {-1 62 void RetimerMainFrame::OnLeftUp(wxMouseEvent& event) { -1 63 Marker_move = false; -1 64 Seeker_move = false; -1 65 } -1 66 -1 67 -1 68 void RetimerMainFrame::OnLeftDClick(wxMouseEvent& event) { -1 69 // check for Marker Select -1 70 if (event.m_y <= MARKERWIDTH * 4 / 5) { -1 71 for (int i = 0; i < curve->getMarkerLength(); ++i) { -1 72 int n = int(curve->getMarker(i) * (width - 1)); -1 73 if (event.m_x <= n + MARKERWIDTH / 2 && event.m_x >= n - MARKERWIDTH / 2) { -1 74 curve->selectMarker(i); -1 75 curve->removeMarker(); -1 76 curve->_update = true; -1 77 return; -1 78 } -1 79 } -1 80 } -1 81 playback->setSeeker(event.m_x/(float)width); -1 82 curve->addMarker(); -1 83 } -1 84 -1 85 -1 86 void RetimerMainFrame::OnMotion(wxMouseEvent& event) { -1 87 if (Marker_move) { -1 88 curve->setMarker(event.m_x / (float)width); -1 89 curve->_update = true; -1 90 } -1 91 if (Seeker_move) { -1 92 playback->setSeeker(event.m_x / (float)width); -1 93 } -1 94 } -1 95 -1 96 -1 97 // ************ file ************** -1 98 void RetimerMainFrame::OnOpenClick(wxCommandEvent& event) { -1 99 wxFileDialog* dialog = new wxFileDialog((wxWindow*)NULL); -1 100 dialog->Show(); -1 101 -1 102 if (dialog->ShowModal() == wxID_OK) { -1 103 wxString filename = dialog->GetPath(); -1 104 if (sample->loadFile(filename.mb_str()) != 0) { -1 105 reportError(_T("Could not read from that file")); -1 106 return; -1 107 } -1 108 process(); -1 109 curve->_update = true; -1 110 } -1 111 // else { -1 112 // report Error(_T("Please choose a valid file!")); -1 113 // } -1 114 } -1 115 -1 116 -1 117 void RetimerMainFrame::OnExportClick(wxCommandEvent& event) { -1 118 wxFileDialog* dialog = new wxFileDialog((wxWindow*)NULL, _T("Export As"), _T(""), _T(""), _T("*.wav"), wxSAVE | wxOVERWRITE_PROMPT); -1 119 dialog->Show(); -1 120 -1 121 if (dialog->ShowModal() == wxID_OK) { -1 122 wxString filename = dialog->GetPath(); -1 123 process(); -1 124 if (sample->writeFile(filename.mb_str()) != 0) { -1 125 reportError(_T("Could not write to File")); -1 126 } -1 127 } -1 128 else { -1 129 reportError(_T("Could not write to File")); -1 130 } -1 131 } -1 132 -1 133 -1 134 // ************ playback ************** -1 135 void RetimerMainFrame::OnStartClick(wxCommandEvent& event) { -1 136 playback->setSeeker(0); -1 137 } -1 138 -1 139 -1 140 void RetimerMainFrame::OnPlayClick(wxCommandEvent& event) { -1 141 playback->play(); -1 142 } -1 143 -1 144 -1 145 // ************ general ************** -1 146 void RetimerMainFrame::OnPrefsClick(wxCommandEvent& event) { -1 147 RetimerPrefsDialog* dialog = new RetimerPrefsDialog(marker, sample, curve); -1 148 dialog->Show(); -1 149 } -1 150 -1 151 void RetimerMainFrame::OnExitClick(wxCommandEvent& event) { -1 152 Close(); -1 153 } -1 154 -1 155 void RetimerMainFrame::OnHelpClick(wxCommandEvent& event) { 150 156 // TODO: create Help151 -1 RetimerAboutDialog* dialog = new RetimerAboutDialog( (wxWindow*)NULL );152 -1 dialog->Show();-1 157 RetimerAboutDialog* dialog = new RetimerAboutDialog((wxWindow*)NULL); -1 158 dialog->Show(); 153 159 } 154 160155 -1 // ************ marker **************156 -1 void RetimerMainFrame::OnClearClick( wxCommandEvent& event ) {157 -1 curve->clearMarker();158 -1 curve->_update=true;-1 161 // ************ marker ************** -1 162 void RetimerMainFrame::OnClearClick(wxCommandEvent& event) { -1 163 curve->clearMarker(); -1 164 curve->_update = true; 159 165 } 160 166 161 167162 -1 // ************ misc **************163 -1 void RetimerMainFrame::OnProcessClick( wxCommandEvent& event ) {process();}-1 168 // ************ misc ************** -1 169 void RetimerMainFrame::OnProcessClick(wxCommandEvent& event) { -1 170 process(); -1 171 } 164 172165 -1 void RetimerMainFrame::OnPaint( wxPaintEvent& event ) {166 -1 wxPaintDC pdc(this);167 -1 // paint(&pdc);-1 173 void RetimerMainFrame::OnPaint(wxPaintEvent& event) { -1 174 wxPaintDC pdc(this); -1 175 // paint(&pdc); 168 176 } 169 177 170 178 void RetimerMainFrame::OnTimer(wxTimerEvent& event) {171 -1 wxClientDC dc(this);172 -1 paint(&dc);-1 179 wxClientDC dc(this); -1 180 paint(&dc); 173 181 } 174 182 175 183 void RetimerMainFrame::paint(wxDC* dc) {176 -1 dc->GetSize(&width,&height);177 -1 wxBufferedDC bdc(dc,wxSize(width,height));178 -1 // waveform179 -1 if (curve->_update) {180 -1 waveform.Create(width, height);181 -1 wxMemoryDC mdc;182 -1 mdc.SelectObject(waveform);183 -1 mdc.SetBackground(*brushbg);184 -1 mdc.Clear();185 -1 mdc.SetPen(*penCurve);186 -1 for (int i=0; i<width; ++i) {187 -1 // mdc.DrawLine(i, int(curve->get(i/(float)width)*(height-BEAT)+height)/2, i+1, int(curve->get((i+1)/(float)width)*(height-BEAT)+height)/2);188 -1 float min=1+curve->getMin(i/(float)width, 1/(float)width);189 -1 float max=1+curve->getMax(i/(float)width, 1/(float)width);190 -1 mdc.DrawLine(i,int(min*height/2),i,int(max*height/2));191 -1 }192 -1 if (curve->_showIntLine) {193 -1 mdc.SetPen(*penCurve2);194 -1 float x1;195 -1 float x2=marker->new2nnew(marker->old2new(0));196 -1 for (int i=0; i<height-1; ++i) {197 -1 x1=x2;198 -1 x2=marker->new2nnew(marker->old2new((i+1)/(float)height));199 -1 mdc.DrawLine(int(x1*width),i,int(x2*width),i+1);200 -1 }201 -1 }202 -1 curve->_update=false;203 -1 }204 -1 bdc.DrawBitmap(waveform,0,0,false);205 -1 // marker206 -1 bdc.SetPen(*penMarker);207 -1 for (int i=0; i<curve->getMarkerLength(); ++i) {208 -1 int n=int(curve->getMarker(i)*(width-1));209 -1 bdc.DrawLine(n,0,n,height);210 -1 wxPoint ps[3];211 -1 wxPoint p0(n-MARKERWIDTH/2,0);212 -1 ps[0]=p0;213 -1 wxPoint p1(n+MARKERWIDTH/2,0);214 -1 ps[1]=p1;215 -1 wxPoint p2(n+0,MARKERWIDTH*4/5);216 -1 ps[2]=p2;217 -1 bdc.DrawPolygon(3,ps);218 -1 }219 -1 // seeker220 -1 bdc.SetPen(*penSeeker);221 -1 int seek=int(curve->getSeeker()*(width-1));222 -1 bdc.DrawLine(seek,0,seek,height);223 -1 //beats224 -1 bdc.SetPen(*penMarker);225 -1 int step=int(width/curve->getBars()/curve->getBeatResolution());226 -1 for (int i=0; i<width && step!=0; i+=step) {227 -1 bdc.DrawLine(i,0,i,BEAT);228 -1 }229 -1 }230 -1231 -1 void RetimerMainFrame::OnSize( wxSizeEvent& event ) {232 -1 curve->_update=true;-1 184 dc->GetSize(&width,&height); -1 185 wxBufferedDC bdc(dc,wxSize(width,height)); -1 186 // waveform -1 187 if (curve->_update) { -1 188 waveform.Create(width, height); -1 189 wxMemoryDC mdc; -1 190 mdc.SelectObject(waveform); -1 191 mdc.SetBackground(*brushbg); -1 192 mdc.Clear(); -1 193 mdc.SetPen(*penCurve); -1 194 for (int i = 0; i < width; ++i) { -1 195 // mdc.DrawLine(i, int(curve->get(i/(float)width)*(height-BEAT)+height)/2, i+1, int(curve->get((i+1)/(float)width)*(height-BEAT)+height)/2); -1 196 float min = 1 + curve->getMin(i / (float)width, 1 / (float)width); -1 197 float max = 1 + curve->getMax(i / (float)width, 1 / (float)width); -1 198 mdc.DrawLine(i, int(min * height / 2), i, int(max * height / 2)); -1 199 } -1 200 if (curve->_showIntLine) { -1 201 mdc.SetPen(*penCurve2); -1 202 float x1; -1 203 float x2 = marker->new2nnew(marker->old2new(0)); -1 204 for (int i = 0; i < height - 1; ++i) { -1 205 x1 = x2; -1 206 x2 = marker->new2nnew(marker->old2new((i + 1) / (float)height)); -1 207 mdc.DrawLine(int(x1 * width), i, int(x2 * width), i + 1); -1 208 } -1 209 } -1 210 curve->_update = false; -1 211 } -1 212 bdc.DrawBitmap(waveform,0,0,false); -1 213 // marker -1 214 bdc.SetPen(*penMarker); -1 215 for (int i = 0; i < curve->getMarkerLength(); ++i) { -1 216 int n = int(curve->getMarker(i) * (width - 1)); -1 217 bdc.DrawLine(n, 0, n, height); -1 218 wxPoint ps[3]; -1 219 wxPoint p0(n - MARKERWIDTH / 2, 0); -1 220 ps[0] = p0; -1 221 wxPoint p1(n + MARKERWIDTH / 2, 0); -1 222 ps[1] = p1; -1 223 wxPoint p2(n + 0, MARKERWIDTH * 4 / 5); -1 224 ps[2] = p2; -1 225 bdc.DrawPolygon(3, ps); -1 226 } -1 227 // seeker -1 228 bdc.SetPen(*penSeeker); -1 229 int seek = int(curve->getSeeker() * (width - 1)); -1 230 bdc.DrawLine(seek, 0, seek, height); -1 231 //beats -1 232 bdc.SetPen(*penMarker); -1 233 int step = int(width / curve->getBars() / curve->getBeatResolution()); -1 234 for (int i = 0; i < width && step != 0; i += step) { -1 235 bdc.DrawLine(i, 0, i, BEAT); -1 236 } -1 237 } -1 238 -1 239 -1 240 void RetimerMainFrame::OnSize(wxSizeEvent& event) { -1 241 curve->_update = true; 233 242 } 234 243 235 244 236 245 // *********************************** 237 246 void RetimerMainFrame::process() {238 -1 // sometings wrong here239 -1 if (sample->process()!=0)240 -1 reportError(_T("Could not process data!"));241 -1242 -1 wxProgressDialog::wxProgressDialog* dialog = new wxProgressDialog( _T("processing..."), _T("please wait") );243 -1 dialog ->Show();244 -1 while (sample->getProcessing()) {245 -1 dialog->Update(int(sample->getFinished()*100));246 -1 }247 -1 dialog->Show(false);248 -1 // TODO destroy dialog-1 247 // sometings wrong here -1 248 if (sample->process() != 0) { -1 249 reportError(_T("Could not process data!")); -1 250 } -1 251 -1 252 wxProgressDialog::wxProgressDialog* dialog = new wxProgressDialog(_T("processing..."), _T("please wait")); -1 253 dialog->Show(); -1 254 while (sample->getProcessing()) { -1 255 dialog->Update(int(sample->getFinished() * 100)); -1 256 } -1 257 dialog->Show(false); -1 258 // TODO destroy dialog 249 259 } 250 260 -1 261 251 262 void RetimerMainFrame::reportError(wxString string) {252 -1 wxMessageDialog::wxMessageDialog* dialog = new wxMessageDialog( this, string, _T("Error"), wxOK | wxICON_ERROR );253 -1 dialog ->ShowModal();-1 263 wxMessageDialog::wxMessageDialog* dialog = new wxMessageDialog(this, string, _T("Error"), wxOK | wxICON_ERROR); -1 264 dialog->ShowModal(); 254 265 }255 -1
diff --git a/src/gui/RetimerMainFrame.h b/src/gui/RetimerMainFrame.h
@@ -23,61 +23,60 @@ Subclass of MainFrame, which is generated by wxFormBuilder. 23 23 #include <iostream> 24 24 25 25 /** Implementing MainFrame */26 -1 class RetimerMainFrame : public MainFrame27 -1 {28 -1 protected:29 -1 // mouse30 -1 void OnLeftDown( wxMouseEvent& event );31 -1 void OnLeftUp( wxMouseEvent& event );32 -1 void OnLeftDClick( wxMouseEvent& event );33 -1 void OnMotion( wxMouseEvent& event );34 -1 // file35 -1 void OnOpenClick( wxCommandEvent& event );36 -1 void OnExportClick( wxCommandEvent& event );37 -1 // playback38 -1 void OnStartClick( wxCommandEvent& event );39 -1 void OnPlayClick( wxCommandEvent& event );40 -1 // general41 -1 void OnExitClick( wxCommandEvent& event );42 -1 void OnHelpClick( wxCommandEvent& event );43 -1 // marker44 -1 void OnClearClick( wxCommandEvent& event );45 -1 // misc46 -1 void OnPrefsClick( wxCommandEvent& event );47 -1 void OnProcessClick( wxCommandEvent& event );48 -1 void OnPaint( wxPaintEvent& event );49 -1 void OnSize( wxSizeEvent& event );-1 26 class RetimerMainFrame : public MainFrame { -1 27 protected: -1 28 // mouse -1 29 void OnLeftDown(wxMouseEvent& event); -1 30 void OnLeftUp(wxMouseEvent& event); -1 31 void OnLeftDClick(wxMouseEvent& event); -1 32 void OnMotion(wxMouseEvent& event); -1 33 // file -1 34 void OnOpenClick(wxCommandEvent& event); -1 35 void OnExportClick(wxCommandEvent& event); -1 36 // playback -1 37 void OnStartClick(wxCommandEvent& event); -1 38 void OnPlayClick(wxCommandEvent& event); -1 39 // general -1 40 void OnExitClick(wxCommandEvent& event); -1 41 void OnHelpClick(wxCommandEvent& event); -1 42 // marker -1 43 void OnClearClick(wxCommandEvent& event); -1 44 // misc -1 45 void OnPrefsClick(wxCommandEvent& event); -1 46 void OnProcessClick(wxCommandEvent& event); -1 47 void OnPaint(wxPaintEvent& event); -1 48 void OnSize(wxSizeEvent& event); 50 4951 -1 void paint(wxDC* dc);52 -1 wxTimer timer;53 -1 void OnTimer(wxTimerEvent& event);-1 50 void paint(wxDC* dc); -1 51 wxTimer timer; -1 52 void OnTimer(wxTimerEvent& event); 54 5355 -1 void process();56 -1 void reportError(wxString string);57 -1 static const int MARKERWIDTH=15;58 -1 static const int BEAT=15;59 -160 -1 int width;61 -1 int height;62 -1 bool Marker_move;63 -1 bool Seeker_move;-1 54 void process(); -1 55 void reportError(wxString string); -1 56 static const int MARKERWIDTH=15; -1 57 static const int BEAT=15; 64 5865 -1 Marker* marker;66 -1 Sample* sample;67 -1 Playback* playback;68 -1 Curve* curve;-1 59 int width; -1 60 int height; -1 61 bool Marker_move; -1 62 bool Seeker_move; 69 6370 -1 wxBrush* brushbg;71 -1 wxPen* penCurve;72 -1 wxPen* penCurve2;73 -1 wxPen* penSeeker;74 -1 wxPen* penMarker;75 -1 wxBitmap waveform;-1 64 Marker* marker; -1 65 Sample* sample; -1 66 Playback* playback; -1 67 Curve* curve; 76 6877 -1 public:78 -1 /** Constructor */79 -1 RetimerMainFrame( wxWindow* parent );80 -1 ~RetimerMainFrame( );-1 69 wxBrush* brushbg; -1 70 wxPen* penCurve; -1 71 wxPen* penCurve2; -1 72 wxPen* penSeeker; -1 73 wxPen* penMarker; -1 74 wxBitmap waveform; -1 75 -1 76 public: -1 77 /** Constructor */ -1 78 RetimerMainFrame(wxWindow* parent); -1 79 ~RetimerMainFrame(); 81 80 }; 82 81 83 82 #endif // __RetimerMainFrame__
diff --git a/src/gui/main.cpp b/src/gui/main.cpp
@@ -1,20 +1,19 @@ 1 1 #include "main.h" 2 23 -14 3 IMPLEMENT_APP(wxWidgetsApp) 5 46 -1 wxWidgetsApp::wxWidgetsApp()7 -1 {-1 5 -1 6 wxWidgetsApp::wxWidgetsApp() { 8 7 } 9 810 -1 wxWidgetsApp::~wxWidgetsApp()11 -1 {-1 9 -1 10 wxWidgetsApp::~wxWidgetsApp() { 12 11 } 13 1214 -1 bool wxWidgetsApp::OnInit()15 -1 {16 -1 RetimerMainFrame* dialog = new RetimerMainFrame( (wxWindow*)NULL );17 -1 dialog ->Show();18 -1 SetTopWindow( dialog );19 -1 return true;-1 13 -1 14 bool wxWidgetsApp::OnInit() { -1 15 RetimerMainFrame* dialog = new RetimerMainFrame((wxWindow*)NULL); -1 16 dialog->Show(); -1 17 SetTopWindow(dialog); -1 18 return true; 20 19 }
diff --git a/src/gui/main.h b/src/gui/main.h
@@ -4,12 +4,11 @@ 4 4 #include <wx/wx.h> 5 5 #include "RetimerMainFrame.h" 6 67 -1 class wxWidgetsApp : public wxApp8 -1 {9 -1 public:10 -1 wxWidgetsApp();11 -1 virtual ~wxWidgetsApp();12 -1 virtual bool OnInit();-1 7 class wxWidgetsApp : public wxApp { -1 8 public: -1 9 wxWidgetsApp(); -1 10 virtual ~wxWidgetsApp(); -1 11 virtual bool OnInit(); 13 12 }; 14 13 15 14 DECLARE_APP(wxWidgetsApp)
diff --git a/src/gui/retimer_wx.cpp b/src/gui/retimer_wx.cpp
@@ -10,280 +10,274 @@ 10 10 11 11 /////////////////////////////////////////////////////////////////////////// 12 1213 -1 MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )14 -1 {15 -1 wxInitAllImageHandlers();16 -1 this->SetSizeHints( wxDefaultSize, wxDefaultSize );17 -1-1 13 MainFrame::MainFrame(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(parent, id, title, pos, size, style) { -1 14 wxInitAllImageHandlers(); -1 15 this->SetSizeHints(wxDefaultSize, wxDefaultSize); -1 16 18 17 wxBoxSizer* bSizer3;19 -1 bSizer3 = new wxBoxSizer( wxVERTICAL );20 -121 -1 this->SetSizer( bSizer3 );-1 18 bSizer3 = new wxBoxSizer(wxVERTICAL); -1 19 -1 20 this->SetSizer(bSizer3); 22 21 this->Layout();23 -1 m_statusBar1 = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY );24 -1 m_menubar3 = new wxMenuBar( 0 );-1 22 m_statusBar1 = this->CreateStatusBar(1, wxST_SIZEGRIP, wxID_ANY); -1 23 m_menubar3 = new wxMenuBar(0); 25 24 m_file = new wxMenu(); 26 25 wxMenuItem* m_open;27 -1 m_open = new wxMenuItem( m_file, wxID_ANY, wxString( wxT("open") ) + wxT('\t') + wxT("CTRL+f"), wxEmptyString, wxITEM_NORMAL );-1 26 m_open = new wxMenuItem(m_file, wxID_ANY, wxString(wxT("open")) + wxT('\t') + wxT("CTRL+f"), wxEmptyString, wxITEM_NORMAL); 28 27 #ifdef ICONS_GNOME29 -1 m_open->SetBitmap( wxBitmap( wxT("/usr/share/icons/gnome/16x16/actions/fileopen.png"), wxBITMAP_TYPE_ANY ) );-1 28 m_open->SetBitmap(wxBitmap(wxT("/usr/share/icons/gnome/16x16/actions/fileopen.png"), wxBITMAP_TYPE_ANY)); 30 29 #endif31 -1 m_file->Append( m_open );32 -1-1 30 m_file->Append(m_open); -1 31 33 32 wxMenuItem* m_export;34 -1 m_export = new wxMenuItem( m_file, wxID_ANY, wxString( wxT("export") ) + wxT('\t') + wxT("CTRL+s"), wxEmptyString, wxITEM_NORMAL );-1 33 m_export = new wxMenuItem(m_file, wxID_ANY, wxString(wxT("export")) + wxT('\t') + wxT("CTRL+s"), wxEmptyString, wxITEM_NORMAL); 35 34 #ifdef ICONS_GNOME36 -1 m_export->SetBitmap( wxBitmap( wxT("/usr/share/icons/gnome/16x16/actions/document-save.png"), wxBITMAP_TYPE_ANY ) );-1 35 m_export->SetBitmap(wxBitmap(wxT("/usr/share/icons/gnome/16x16/actions/document-save.png"), wxBITMAP_TYPE_ANY)); 37 36 #endif38 -1 m_file->Append( m_export );39 -1-1 37 m_file->Append(m_export); -1 38 40 39 wxMenuItem* m_separator6; 41 40 m_separator6 = m_file->AppendSeparator();42 -1-1 41 43 42 wxMenuItem* m_prefs;44 -1 m_prefs = new wxMenuItem( m_file, wxID_ANY, wxString( wxT("preferences") ) + wxT('\t') + wxT("F5"), wxEmptyString, wxITEM_NORMAL );-1 43 m_prefs = new wxMenuItem(m_file, wxID_ANY, wxString(wxT("preferences")) + wxT('\t') + wxT("F5"), wxEmptyString, wxITEM_NORMAL); 45 44 #ifdef ICONS_GNOME46 -1 m_prefs->SetBitmap( wxBitmap( wxT("/usr/share/icons/gnome/16x16/actions/document-properties.png"), wxBITMAP_TYPE_ANY ) );-1 45 m_prefs->SetBitmap(wxBitmap(wxT("/usr/share/icons/gnome/16x16/actions/document-properties.png"), wxBITMAP_TYPE_ANY)); 47 46 #endif48 -1 m_file->Append( m_prefs );49 -1-1 47 m_file->Append(m_prefs); -1 48 50 49 wxMenuItem* m_separator7; 51 50 m_separator7 = m_file->AppendSeparator();52 -1-1 51 53 52 wxMenuItem* b_exit;54 -1 b_exit = new wxMenuItem( m_file, wxID_ANY, wxString( wxT("Exit") ) , wxEmptyString, wxITEM_NORMAL );-1 53 b_exit = new wxMenuItem(m_file, wxID_ANY, wxString(wxT("Exit")) , wxEmptyString, wxITEM_NORMAL); 55 54 #ifdef ICONS_GNOME56 -1 b_exit->SetBitmap( wxBitmap( wxT("/usr/share/icons/gnome/16x16/actions/window-close.png"), wxBITMAP_TYPE_ANY ) );-1 55 b_exit->SetBitmap(wxBitmap(wxT("/usr/share/icons/gnome/16x16/actions/window-close.png"), wxBITMAP_TYPE_ANY)); 57 56 #endif58 -1 m_file->Append( b_exit );59 -160 -1 m_menubar3->Append( m_file, wxT("File") );61 -1-1 57 m_file->Append(b_exit); -1 58 -1 59 m_menubar3->Append(m_file, wxT("File")); -1 60 62 61 m_edit = new wxMenu(); 63 62 wxMenuItem* m_play;64 -1 m_play = new wxMenuItem( m_edit, wxID_ANY, wxString( wxT("play/pause") ) + wxT('\t') + wxT("SPACE"), wxEmptyString, wxITEM_NORMAL );-1 63 m_play = new wxMenuItem(m_edit, wxID_ANY, wxString(wxT("play/pause")) + wxT('\t') + wxT("SPACE"), wxEmptyString, wxITEM_NORMAL); 65 64 #ifdef ICONS_GNOME66 -1 m_play->SetBitmap( wxBitmap( wxT("/usr/share/icons/gnome/16x16/actions/media-playback-start.png"), wxBITMAP_TYPE_ANY ) );-1 65 m_play->SetBitmap(wxBitmap(wxT("/usr/share/icons/gnome/16x16/actions/media-playback-start.png"), wxBITMAP_TYPE_ANY)); 67 66 #endif68 -1 m_edit->Append( m_play );69 -1-1 67 m_edit->Append(m_play); -1 68 70 69 wxMenuItem* m_start;71 -1 m_start = new wxMenuItem( m_edit, wxID_ANY, wxString( wxT("start") ) + wxT('\t') + wxT("CTRL+LEFT"), wxEmptyString, wxITEM_NORMAL );-1 70 m_start = new wxMenuItem(m_edit, wxID_ANY, wxString(wxT("start")) + wxT('\t') + wxT("CTRL+LEFT"), wxEmptyString, wxITEM_NORMAL); 72 71 #ifdef ICONS_GNOME73 -1 m_start->SetBitmap( wxBitmap( wxT("/usr/share/icons/gnome/16x16/actions/media-skip-backward.png"), wxBITMAP_TYPE_ANY ) );-1 72 m_start->SetBitmap(wxBitmap(wxT("/usr/share/icons/gnome/16x16/actions/media-skip-backward.png"), wxBITMAP_TYPE_ANY)); 74 73 #endif75 -1 m_edit->Append( m_start );76 -1-1 74 m_edit->Append(m_start); -1 75 77 76 wxMenuItem* m_separator8; 78 77 m_separator8 = m_edit->AppendSeparator();79 -1-1 78 80 79 wxMenuItem* m_clear;81 -1 m_clear = new wxMenuItem( m_edit, wxID_ANY, wxString( wxT("clear markers") ) + wxT('\t') + wxT("CTRL+c"), wxEmptyString, wxITEM_NORMAL );-1 80 m_clear = new wxMenuItem(m_edit, wxID_ANY, wxString(wxT("clear markers")) + wxT('\t') + wxT("CTRL+c"), wxEmptyString, wxITEM_NORMAL); 82 81 #ifdef ICONS_GNOME83 -1 m_clear->SetBitmap( wxBitmap( wxT("/usr/share/icons/gnome/16x16/actions/edit-clear.png"), wxBITMAP_TYPE_ANY ) );-1 82 m_clear->SetBitmap(wxBitmap(wxT("/usr/share/icons/gnome/16x16/actions/edit-clear.png"), wxBITMAP_TYPE_ANY)); 84 83 #endif85 -1 m_edit->Append( m_clear );86 -1-1 84 m_edit->Append(m_clear); -1 85 87 86 wxMenuItem* m_process;88 -1 m_process = new wxMenuItem( m_edit, wxID_ANY, wxString( wxT("update audio data") ) + wxT('\t') + wxT("CTRL+u"), wxEmptyString, wxITEM_NORMAL );-1 87 m_process = new wxMenuItem(m_edit, wxID_ANY, wxString(wxT("update audio data")) + wxT('\t') + wxT("CTRL+u"), wxEmptyString, wxITEM_NORMAL); 89 88 #ifdef ICONS_GNOME90 -1 m_process->SetBitmap( wxBitmap( wxT("/usr/share/icons/gnome/16x16/actions/stock_refresh.png"), wxBITMAP_TYPE_ANY ) );-1 89 m_process->SetBitmap(wxBitmap(wxT("/usr/share/icons/gnome/16x16/actions/stock_refresh.png"), wxBITMAP_TYPE_ANY)); 91 90 #endif92 -1 m_edit->Append( m_process );93 -194 -1 m_menubar3->Append( m_edit, wxT("Edit") );95 -1-1 91 m_edit->Append(m_process); -1 92 -1 93 m_menubar3->Append(m_edit, wxT("Edit")); -1 94 96 95 m_help = new wxMenu(); 97 96 wxMenuItem* m_about;98 -1 m_about = new wxMenuItem( m_help, wxID_ANY, wxString( wxT("about") ) + wxT('\t') + wxT("F1"), wxEmptyString, wxITEM_NORMAL );-1 97 m_about = new wxMenuItem(m_help, wxID_ANY, wxString(wxT("about")) + wxT('\t') + wxT("F1"), wxEmptyString, wxITEM_NORMAL); 99 98 #ifdef ICONS_GNOME100 -1 m_about->SetBitmap( wxBitmap( wxT("/usr/share/icons/gnome/16x16/actions/help-about.png"), wxBITMAP_TYPE_ANY ) );-1 99 m_about->SetBitmap(wxBitmap(wxT("/usr/share/icons/gnome/16x16/actions/help-about.png"), wxBITMAP_TYPE_ANY)); 101 100 #endif102 -1 m_help->Append( m_about );103 -1104 -1 m_menubar3->Append( m_help, wxT("Help") );105 -1106 -1 this->SetMenuBar( m_menubar3 );107 -1108 -1-1 101 m_help->Append(m_about); -1 102 -1 103 m_menubar3->Append(m_help, wxT("Help")); -1 104 -1 105 this->SetMenuBar(m_menubar3); -1 106 -1 107 109 108 // Connect Events110 -1 this->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( MainFrame::OnLeftDClick ) );111 -1 this->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( MainFrame::OnLeftDown ) );112 -1 this->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( MainFrame::OnLeftUp ) );113 -1 this->Connect( wxEVT_MOTION, wxMouseEventHandler( MainFrame::OnMotion ) );114 -1 this->Connect( wxEVT_PAINT, wxPaintEventHandler( MainFrame::OnPaint ) );115 -1 this->Connect( wxEVT_SIZE, wxSizeEventHandler( MainFrame::OnSize ) );116 -1 this->Connect( m_open->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnOpenClick ) );117 -1 this->Connect( m_export->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnExportClick ) );118 -1 this->Connect( m_prefs->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnPrefsClick ) );119 -1 this->Connect( b_exit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnExitClick ) );120 -1 this->Connect( m_play->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnPlayClick ) );121 -1 this->Connect( m_start->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnStartClick ) );122 -1 this->Connect( m_clear->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnClearClick ) );123 -1 this->Connect( m_process->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnProcessClick ) );124 -1 this->Connect( m_about->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnHelpClick ) );-1 109 this->Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(MainFrame::OnLeftDClick)); -1 110 this->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(MainFrame::OnLeftDown)); -1 111 this->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(MainFrame::OnLeftUp)); -1 112 this->Connect(wxEVT_MOTION, wxMouseEventHandler(MainFrame::OnMotion)); -1 113 this->Connect(wxEVT_PAINT, wxPaintEventHandler(MainFrame::OnPaint)); -1 114 this->Connect(wxEVT_SIZE, wxSizeEventHandler(MainFrame::OnSize)); -1 115 this->Connect(m_open->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnOpenClick)); -1 116 this->Connect(m_export->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnExportClick)); -1 117 this->Connect(m_prefs->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnPrefsClick)); -1 118 this->Connect(b_exit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnExitClick)); -1 119 this->Connect(m_play->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnPlayClick)); -1 120 this->Connect(m_start->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnStartClick)); -1 121 this->Connect(m_clear->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnClearClick)); -1 122 this->Connect(m_process->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnProcessClick)); -1 123 this->Connect(m_about->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnHelpClick)); 125 124 } 126 125127 -1 MainFrame::~MainFrame()128 -1 {-1 126 MainFrame::~MainFrame() { 129 127 // Disconnect Events130 -1 this->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( MainFrame::OnLeftDClick ) );131 -1 this->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( MainFrame::OnLeftDown ) );132 -1 this->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( MainFrame::OnLeftUp ) );133 -1 this->Disconnect( wxEVT_MOTION, wxMouseEventHandler( MainFrame::OnMotion ) );134 -1 this->Disconnect( wxEVT_PAINT, wxPaintEventHandler( MainFrame::OnPaint ) );135 -1 this->Disconnect( wxEVT_SIZE, wxSizeEventHandler( MainFrame::OnSize ) );136 -1 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnOpenClick ) );137 -1 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnExportClick ) );138 -1 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnPrefsClick ) );139 -1 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnExitClick ) );140 -1 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnPlayClick ) );141 -1 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnStartClick ) );142 -1 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnClearClick ) );143 -1 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnProcessClick ) );144 -1 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnHelpClick ) );-1 128 this->Disconnect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(MainFrame::OnLeftDClick)); -1 129 this->Disconnect(wxEVT_LEFT_DOWN, wxMouseEventHandler(MainFrame::OnLeftDown)); -1 130 this->Disconnect(wxEVT_LEFT_UP, wxMouseEventHandler(MainFrame::OnLeftUp)); -1 131 this->Disconnect(wxEVT_MOTION, wxMouseEventHandler(MainFrame::OnMotion)); -1 132 this->Disconnect(wxEVT_PAINT, wxPaintEventHandler(MainFrame::OnPaint)); -1 133 this->Disconnect(wxEVT_SIZE, wxSizeEventHandler(MainFrame::OnSize)); -1 134 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnOpenClick)); -1 135 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnExportClick)); -1 136 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnPrefsClick)); -1 137 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnExitClick)); -1 138 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnPlayClick)); -1 139 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnStartClick)); -1 140 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnClearClick)); -1 141 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnProcessClick)); -1 142 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnHelpClick)); 145 143 } 146 144147 -1 AboutDialog::AboutDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )148 -1 {149 -1 this->SetSizeHints( wxDefaultSize, wxDefaultSize );150 -1-1 145 AboutDialog::AboutDialog(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxDialog(parent, id, title, pos, size, style) { -1 146 this->SetSizeHints(wxDefaultSize, wxDefaultSize); -1 147 151 148 wxBoxSizer* bSizer4;152 -1 bSizer4 = new wxBoxSizer( wxVERTICAL );153 -1-1 149 bSizer4 = new wxBoxSizer(wxVERTICAL); -1 150 154 151 wxBoxSizer* bSizer14;155 -1 bSizer14 = new wxBoxSizer( wxVERTICAL );156 -1157 -1 m_staticText7 = new wxStaticText( this, wxID_ANY, wxT("xiRetimer v0.2"), wxDefaultPosition, wxDefaultSize, 0 );158 -1 m_staticText7->Wrap( -1 );159 -1 bSizer14->Add( m_staticText7, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );160 -1161 -1 m_staticText1 = new wxStaticText( this, wxID_ANY, wxT("Created by xi."), wxDefaultPosition, wxDefaultSize, 0 );162 -1 m_staticText1->Wrap( -1 );163 -1 bSizer14->Add( m_staticText1, 0, wxALIGN_CENTER|wxALL, 5 );164 -1165 -1 m_staticText2 = new wxStaticText( this, wxID_ANY, wxT("www.github.com/xi"), wxDefaultPosition, wxDefaultSize, 0 );166 -1 m_staticText2->Wrap( -1 );167 -1 bSizer14->Add( m_staticText2, 0, wxALIGN_CENTER|wxALL, 5 );168 -1169 -1 bSizer4->Add( bSizer14, 1, wxEXPAND, 5 );170 -1-1 152 bSizer14 = new wxBoxSizer(wxVERTICAL); -1 153 -1 154 m_staticText7 = new wxStaticText(this, wxID_ANY, wxT("xiRetimer v0.2"), wxDefaultPosition, wxDefaultSize, 0); -1 155 m_staticText7->Wrap(-1); -1 156 bSizer14->Add(m_staticText7, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5); -1 157 -1 158 m_staticText1 = new wxStaticText(this, wxID_ANY, wxT("Created by xi."), wxDefaultPosition, wxDefaultSize, 0); -1 159 m_staticText1->Wrap(-1); -1 160 bSizer14->Add(m_staticText1, 0, wxALIGN_CENTER|wxALL, 5); -1 161 -1 162 m_staticText2 = new wxStaticText(this, wxID_ANY, wxT("www.github.com/xi"), wxDefaultPosition, wxDefaultSize, 0); -1 163 m_staticText2->Wrap(-1); -1 164 bSizer14->Add(m_staticText2, 0, wxALIGN_CENTER|wxALL, 5); -1 165 -1 166 bSizer4->Add(bSizer14, 1, wxEXPAND, 5); -1 167 171 168 wxBoxSizer* bSizer7;172 -1 bSizer7 = new wxBoxSizer( wxVERTICAL );173 -1174 -1 m_button1 = new wxButton( this, wxID_ANY, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 );175 -1 bSizer7->Add( m_button1, 0, wxALIGN_CENTER|wxALL, 5 );176 -1177 -1 bSizer4->Add( bSizer7, 0, wxEXPAND, 5 );178 -1179 -1 this->SetSizer( bSizer4 );-1 169 bSizer7 = new wxBoxSizer(wxVERTICAL); -1 170 -1 171 m_button1 = new wxButton(this, wxID_ANY, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0); -1 172 bSizer7->Add(m_button1, 0, wxALIGN_CENTER|wxALL, 5); -1 173 -1 174 bSizer4->Add(bSizer7, 0, wxEXPAND, 5); -1 175 -1 176 this->SetSizer(bSizer4); 180 177 this->Layout();181 -1-1 178 182 179 // Connect Events183 -1 m_button1->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( AboutDialog::OnOKClick ), NULL, this );-1 180 m_button1->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(AboutDialog::OnOKClick), NULL, this); 184 181 } 185 182186 -1 AboutDialog::~AboutDialog()187 -1 {-1 183 AboutDialog::~AboutDialog() { 188 184 // Disconnect Events189 -1 m_button1->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( AboutDialog::OnOKClick ), NULL, this );-1 185 m_button1->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(AboutDialog::OnOKClick), NULL, this); 190 186 } 191 187192 -1 PrefsDialog::PrefsDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )193 -1 {194 -1 this->SetSizeHints( wxDefaultSize, wxDefaultSize );195 -1-1 188 PrefsDialog::PrefsDialog(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxDialog(parent, id, title, pos, size, style) { -1 189 this->SetSizeHints(wxDefaultSize, wxDefaultSize); -1 190 196 191 wxBoxSizer* bSizer5;197 -1 bSizer5 = new wxBoxSizer( wxVERTICAL );198 -1-1 192 bSizer5 = new wxBoxSizer(wxVERTICAL); -1 193 199 194 wxFlexGridSizer* fgSizer4;200 -1 fgSizer4 = new wxFlexGridSizer( 2, 2, 0, 0 );201 -1 fgSizer4->AddGrowableCol( 1 );202 -1 fgSizer4->SetFlexibleDirection( wxBOTH );203 -1 fgSizer4->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );204 -1205 -1 l_intmode = new wxStaticText( this, wxID_ANY, wxT("Interpolation Mode"), wxDefaultPosition, wxDefaultSize, 0 );206 -1 l_intmode->Wrap( -1 );207 -1 fgSizer4->Add( l_intmode, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );208 -1-1 195 fgSizer4 = new wxFlexGridSizer(2, 2, 0, 0); -1 196 fgSizer4->AddGrowableCol(1); -1 197 fgSizer4->SetFlexibleDirection(wxBOTH); -1 198 fgSizer4->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED); -1 199 -1 200 l_intmode = new wxStaticText(this, wxID_ANY, wxT("Interpolation Mode"), wxDefaultPosition, wxDefaultSize, 0); -1 201 l_intmode->Wrap(-1); -1 202 fgSizer4->Add(l_intmode, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); -1 203 209 204 wxString c_intmodeChoices[] = { wxT("Linear"), wxT("Polynominal") };210 -1 int c_intmodeNChoices = sizeof( c_intmodeChoices ) / sizeof( wxString );211 -1 c_intmode = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, c_intmodeNChoices, c_intmodeChoices, 0 );212 -1 c_intmode->SetSelection( 0 );213 -1 fgSizer4->Add( c_intmode, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );214 -1215 -1 l_showint = new wxStaticText( this, wxID_ANY, wxT("show interpolation curve"), wxDefaultPosition, wxDefaultSize, 0 );216 -1 l_showint->Wrap( -1 );217 -1 fgSizer4->Add( l_showint, 0, wxALL, 5 );218 -1219 -1 m_showint = new wxCheckBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );220 -1 fgSizer4->Add( m_showint, 0, wxALL, 5 );221 -1222 -1 l_stretchmode = new wxStaticText( this, wxID_ANY, wxT("Stretch Mode"), wxDefaultPosition, wxDefaultSize, 0 );223 -1 l_stretchmode->Wrap( -1 );224 -1 fgSizer4->Add( l_stretchmode, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );225 -1-1 205 int c_intmodeNChoices = sizeof(c_intmodeChoices) / sizeof(wxString); -1 206 c_intmode = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, c_intmodeNChoices, c_intmodeChoices, 0); -1 207 c_intmode->SetSelection(0); -1 208 fgSizer4->Add(c_intmode, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5); -1 209 -1 210 l_showint = new wxStaticText(this, wxID_ANY, wxT("show interpolation curve"), wxDefaultPosition, wxDefaultSize, 0); -1 211 l_showint->Wrap(-1); -1 212 fgSizer4->Add(l_showint, 0, wxALL, 5); -1 213 -1 214 m_showint = new wxCheckBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); -1 215 fgSizer4->Add(m_showint, 0, wxALL, 5); -1 216 -1 217 l_stretchmode = new wxStaticText(this, wxID_ANY, wxT("Stretch Mode"), wxDefaultPosition, wxDefaultSize, 0); -1 218 l_stretchmode->Wrap(-1); -1 219 fgSizer4->Add(l_stretchmode, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); -1 220 226 221 // TODO 227 222 #ifdef MODE_RUBBERBAND 228 223 wxString c_stretchmodeChoices[] = { wxT("none"), wxT("RubberBand")}; 229 224 #else230 -1 wxString c_stretchmodeChoices[] = { wxT("none"), wxT("RubberBand (diabled)")};-1 225 wxString c_stretchmodeChoices[] = { wxT("none"), wxT("RubberBand (disabled)")}; 231 226 #endif232 -1233 -1 int c_stretchmodeNChoices = sizeof( c_stretchmodeChoices ) / sizeof( wxString );234 -1 c_stretchmode = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, c_stretchmodeNChoices, c_stretchmodeChoices, 0 );235 -1 c_stretchmode->SetSelection( 0 );236 -1 fgSizer4->Add( c_stretchmode, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );237 -1238 -1 l_tempo = new wxStaticText( this, wxID_ANY, wxT("Tempo"), wxDefaultPosition, wxDefaultSize, 0 );239 -1 l_tempo->Wrap( -1 );240 -1 fgSizer4->Add( l_tempo, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );241 -1242 -1 t_tempo = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_RIGHT );243 -1 fgSizer4->Add( t_tempo, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );244 -1245 -1 l_beatres = new wxStaticText( this, wxID_ANY, wxT("Beat Resolution"), wxDefaultPosition, wxDefaultSize, 0 );246 -1 l_beatres->Wrap( -1 );247 -1 fgSizer4->Add( l_beatres, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );248 -1249 -1 t_beatres = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_RIGHT );250 -1 fgSizer4->Add( t_beatres, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );251 -1252 -1 bSizer5->Add( fgSizer4, 1, wxEXPAND, 5 );253 -1-1 227 -1 228 int c_stretchmodeNChoices = sizeof(c_stretchmodeChoices) / sizeof(wxString); -1 229 c_stretchmode = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, c_stretchmodeNChoices, c_stretchmodeChoices, 0); -1 230 c_stretchmode->SetSelection(0); -1 231 fgSizer4->Add(c_stretchmode, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5); -1 232 -1 233 l_tempo = new wxStaticText(this, wxID_ANY, wxT("Tempo"), wxDefaultPosition, wxDefaultSize, 0); -1 234 l_tempo->Wrap(-1); -1 235 fgSizer4->Add(l_tempo, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); -1 236 -1 237 t_tempo = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_RIGHT); -1 238 fgSizer4->Add(t_tempo, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5); -1 239 -1 240 l_beatres = new wxStaticText(this, wxID_ANY, wxT("Beat Resolution"), wxDefaultPosition, wxDefaultSize, 0); -1 241 l_beatres->Wrap(-1); -1 242 fgSizer4->Add(l_beatres, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); -1 243 -1 244 t_beatres = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_RIGHT); -1 245 fgSizer4->Add(t_beatres, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5); -1 246 -1 247 bSizer5->Add(fgSizer4, 1, wxEXPAND, 5); -1 248 254 249 wxBoxSizer* bSizer15;255 -1 bSizer15 = new wxBoxSizer( wxHORIZONTAL );256 -1257 -1 b_OK = new wxButton( this, wxID_ANY, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 );258 -1 bSizer15->Add( b_OK, 0, wxALL|wxALIGN_BOTTOM|wxALIGN_RIGHT, 5 );259 -1260 -1 b_Cancel = new wxButton( this, wxID_ANY, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );261 -1 b_Cancel->SetToolTip( wxT("Escape") );262 -1263 -1 bSizer15->Add( b_Cancel, 0, wxALIGN_BOTTOM|wxALIGN_RIGHT|wxALL, 5 );264 -1265 -1 bSizer5->Add( bSizer15, 0, wxALIGN_RIGHT, 5 );266 -1267 -1 this->SetSizer( bSizer5 );-1 250 bSizer15 = new wxBoxSizer(wxHORIZONTAL); -1 251 -1 252 b_OK = new wxButton(this, wxID_ANY, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0); -1 253 bSizer15->Add(b_OK, 0, wxALL|wxALIGN_BOTTOM|wxALIGN_RIGHT, 5); -1 254 -1 255 b_Cancel = new wxButton(this, wxID_ANY, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0); -1 256 b_Cancel->SetToolTip(wxT("Escape")); -1 257 -1 258 bSizer15->Add(b_Cancel, 0, wxALIGN_BOTTOM|wxALIGN_RIGHT|wxALL, 5); -1 259 -1 260 bSizer5->Add(bSizer15, 0, wxALIGN_RIGHT, 5); -1 261 -1 262 this->SetSizer(bSizer5); 268 263 this->Layout();269 -1-1 264 270 265 // Connect Events271 -1 c_intmode->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PrefsDialog::OnIntModeChange ), NULL, this );272 -1 m_showint->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PrefsDialog::OnCheckShowInt ), NULL, this );273 -1 c_stretchmode->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PrefsDialog::OnStretchModeChange ), NULL, this );274 -1 t_tempo->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( PrefsDialog::OnTempoEnter ), NULL, this );275 -1 t_beatres->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( PrefsDialog::OnBeatResEnter ), NULL, this );276 -1 b_OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PrefsDialog::OnOKClick ), NULL, this );277 -1 b_Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PrefsDialog::OnCancelClick ), NULL, this );-1 266 c_intmode->Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(PrefsDialog::OnIntModeChange), NULL, this); -1 267 m_showint->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(PrefsDialog::OnCheckShowInt), NULL, this); -1 268 c_stretchmode->Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(PrefsDialog::OnStretchModeChange), NULL, this); -1 269 t_tempo->Connect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(PrefsDialog::OnTempoEnter), NULL, this); -1 270 t_beatres->Connect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(PrefsDialog::OnBeatResEnter), NULL, this); -1 271 b_OK->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PrefsDialog::OnOKClick), NULL, this); -1 272 b_Cancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PrefsDialog::OnCancelClick), NULL, this); 278 273 } 279 274280 -1 PrefsDialog::~PrefsDialog()281 -1 {-1 275 PrefsDialog::~PrefsDialog() { 282 276 // Disconnect Events283 -1 c_intmode->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PrefsDialog::OnIntModeChange ), NULL, this );284 -1 c_stretchmode->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PrefsDialog::OnStretchModeChange ), NULL, this );285 -1 t_tempo->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( PrefsDialog::OnTempoEnter ), NULL, this );286 -1 t_beatres->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( PrefsDialog::OnBeatResEnter ), NULL, this );287 -1 b_OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PrefsDialog::OnOKClick ), NULL, this );288 -1 b_Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PrefsDialog::OnCancelClick ), NULL, this );-1 277 c_intmode->Disconnect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(PrefsDialog::OnIntModeChange), NULL, this); -1 278 c_stretchmode->Disconnect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(PrefsDialog::OnStretchModeChange), NULL, this); -1 279 t_tempo->Disconnect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(PrefsDialog::OnTempoEnter), NULL, this); -1 280 t_beatres->Disconnect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(PrefsDialog::OnBeatResEnter), NULL, this); -1 281 b_OK->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PrefsDialog::OnOKClick), NULL, this); -1 282 b_Cancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PrefsDialog::OnCancelClick), NULL, this); 289 283 }
diff --git a/src/gui/retimer_wx.cpp.in b/src/gui/retimer_wx.cpp.in
@@ -10,280 +10,274 @@ 10 10 11 11 /////////////////////////////////////////////////////////////////////////// 12 1213 -1 MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )14 -1 {15 -1 wxInitAllImageHandlers();16 -1 this->SetSizeHints( wxDefaultSize, wxDefaultSize );17 -1-1 13 MainFrame::MainFrame(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxFrame(parent, id, title, pos, size, style) { -1 14 wxInitAllImageHandlers(); -1 15 this->SetSizeHints(wxDefaultSize, wxDefaultSize); -1 16 18 17 wxBoxSizer* bSizer3;19 -1 bSizer3 = new wxBoxSizer( wxVERTICAL );20 -121 -1 this->SetSizer( bSizer3 );-1 18 bSizer3 = new wxBoxSizer(wxVERTICAL); -1 19 -1 20 this->SetSizer(bSizer3); 22 21 this->Layout();23 -1 m_statusBar1 = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY );24 -1 m_menubar3 = new wxMenuBar( 0 );-1 22 m_statusBar1 = this->CreateStatusBar(1, wxST_SIZEGRIP, wxID_ANY); -1 23 m_menubar3 = new wxMenuBar(0); 25 24 m_file = new wxMenu(); 26 25 wxMenuItem* m_open;27 -1 m_open = new wxMenuItem( m_file, wxID_ANY, wxString( wxT("open") ) + wxT('\t') + wxT("CTRL+f"), wxEmptyString, wxITEM_NORMAL );-1 26 m_open = new wxMenuItem(m_file, wxID_ANY, wxString(wxT("open")) + wxT('\t') + wxT("CTRL+f"), wxEmptyString, wxITEM_NORMAL); 28 27 #ifdef ICONS_GNOME29 -1 m_open->SetBitmap( wxBitmap( wxT("/usr/share/icons/gnome/16x16/actions/fileopen.png"), wxBITMAP_TYPE_ANY ) );-1 28 m_open->SetBitmap(wxBitmap(wxT("/usr/share/icons/gnome/16x16/actions/fileopen.png"), wxBITMAP_TYPE_ANY)); 30 29 #endif31 -1 m_file->Append( m_open );32 -1-1 30 m_file->Append(m_open); -1 31 33 32 wxMenuItem* m_export;34 -1 m_export = new wxMenuItem( m_file, wxID_ANY, wxString( wxT("export") ) + wxT('\t') + wxT("CTRL+s"), wxEmptyString, wxITEM_NORMAL );-1 33 m_export = new wxMenuItem(m_file, wxID_ANY, wxString(wxT("export")) + wxT('\t') + wxT("CTRL+s"), wxEmptyString, wxITEM_NORMAL); 35 34 #ifdef ICONS_GNOME36 -1 m_export->SetBitmap( wxBitmap( wxT("/usr/share/icons/gnome/16x16/actions/document-save.png"), wxBITMAP_TYPE_ANY ) );-1 35 m_export->SetBitmap(wxBitmap(wxT("/usr/share/icons/gnome/16x16/actions/document-save.png"), wxBITMAP_TYPE_ANY)); 37 36 #endif38 -1 m_file->Append( m_export );39 -1-1 37 m_file->Append(m_export); -1 38 40 39 wxMenuItem* m_separator6; 41 40 m_separator6 = m_file->AppendSeparator();42 -1-1 41 43 42 wxMenuItem* m_prefs;44 -1 m_prefs = new wxMenuItem( m_file, wxID_ANY, wxString( wxT("preferences") ) + wxT('\t') + wxT("F5"), wxEmptyString, wxITEM_NORMAL );-1 43 m_prefs = new wxMenuItem(m_file, wxID_ANY, wxString(wxT("preferences")) + wxT('\t') + wxT("F5"), wxEmptyString, wxITEM_NORMAL); 45 44 #ifdef ICONS_GNOME46 -1 m_prefs->SetBitmap( wxBitmap( wxT("/usr/share/icons/gnome/16x16/actions/document-properties.png"), wxBITMAP_TYPE_ANY ) );-1 45 m_prefs->SetBitmap(wxBitmap(wxT("/usr/share/icons/gnome/16x16/actions/document-properties.png"), wxBITMAP_TYPE_ANY)); 47 46 #endif48 -1 m_file->Append( m_prefs );49 -1-1 47 m_file->Append(m_prefs); -1 48 50 49 wxMenuItem* m_separator7; 51 50 m_separator7 = m_file->AppendSeparator();52 -1-1 51 53 52 wxMenuItem* b_exit;54 -1 b_exit = new wxMenuItem( m_file, wxID_ANY, wxString( wxT("Exit") ) , wxEmptyString, wxITEM_NORMAL );-1 53 b_exit = new wxMenuItem(m_file, wxID_ANY, wxString(wxT("Exit")) , wxEmptyString, wxITEM_NORMAL); 55 54 #ifdef ICONS_GNOME56 -1 b_exit->SetBitmap( wxBitmap( wxT("/usr/share/icons/gnome/16x16/actions/window-close.png"), wxBITMAP_TYPE_ANY ) );-1 55 b_exit->SetBitmap(wxBitmap(wxT("/usr/share/icons/gnome/16x16/actions/window-close.png"), wxBITMAP_TYPE_ANY)); 57 56 #endif58 -1 m_file->Append( b_exit );59 -160 -1 m_menubar3->Append( m_file, wxT("File") );61 -1-1 57 m_file->Append(b_exit); -1 58 -1 59 m_menubar3->Append(m_file, wxT("File")); -1 60 62 61 m_edit = new wxMenu(); 63 62 wxMenuItem* m_play;64 -1 m_play = new wxMenuItem( m_edit, wxID_ANY, wxString( wxT("play/pause") ) + wxT('\t') + wxT("SPACE"), wxEmptyString, wxITEM_NORMAL );-1 63 m_play = new wxMenuItem(m_edit, wxID_ANY, wxString(wxT("play/pause")) + wxT('\t') + wxT("SPACE"), wxEmptyString, wxITEM_NORMAL); 65 64 #ifdef ICONS_GNOME66 -1 m_play->SetBitmap( wxBitmap( wxT("/usr/share/icons/gnome/16x16/actions/media-playback-start.png"), wxBITMAP_TYPE_ANY ) );-1 65 m_play->SetBitmap(wxBitmap(wxT("/usr/share/icons/gnome/16x16/actions/media-playback-start.png"), wxBITMAP_TYPE_ANY)); 67 66 #endif68 -1 m_edit->Append( m_play );69 -1-1 67 m_edit->Append(m_play); -1 68 70 69 wxMenuItem* m_start;71 -1 m_start = new wxMenuItem( m_edit, wxID_ANY, wxString( wxT("start") ) + wxT('\t') + wxT("CTRL+LEFT"), wxEmptyString, wxITEM_NORMAL );-1 70 m_start = new wxMenuItem(m_edit, wxID_ANY, wxString(wxT("start")) + wxT('\t') + wxT("CTRL+LEFT"), wxEmptyString, wxITEM_NORMAL); 72 71 #ifdef ICONS_GNOME73 -1 m_start->SetBitmap( wxBitmap( wxT("/usr/share/icons/gnome/16x16/actions/media-skip-backward.png"), wxBITMAP_TYPE_ANY ) );-1 72 m_start->SetBitmap(wxBitmap(wxT("/usr/share/icons/gnome/16x16/actions/media-skip-backward.png"), wxBITMAP_TYPE_ANY)); 74 73 #endif75 -1 m_edit->Append( m_start );76 -1-1 74 m_edit->Append(m_start); -1 75 77 76 wxMenuItem* m_separator8; 78 77 m_separator8 = m_edit->AppendSeparator();79 -1-1 78 80 79 wxMenuItem* m_clear;81 -1 m_clear = new wxMenuItem( m_edit, wxID_ANY, wxString( wxT("clear markers") ) + wxT('\t') + wxT("CTRL+c"), wxEmptyString, wxITEM_NORMAL );-1 80 m_clear = new wxMenuItem(m_edit, wxID_ANY, wxString(wxT("clear markers")) + wxT('\t') + wxT("CTRL+c"), wxEmptyString, wxITEM_NORMAL); 82 81 #ifdef ICONS_GNOME83 -1 m_clear->SetBitmap( wxBitmap( wxT("/usr/share/icons/gnome/16x16/actions/edit-clear.png"), wxBITMAP_TYPE_ANY ) );-1 82 m_clear->SetBitmap(wxBitmap(wxT("/usr/share/icons/gnome/16x16/actions/edit-clear.png"), wxBITMAP_TYPE_ANY)); 84 83 #endif85 -1 m_edit->Append( m_clear );86 -1-1 84 m_edit->Append(m_clear); -1 85 87 86 wxMenuItem* m_process;88 -1 m_process = new wxMenuItem( m_edit, wxID_ANY, wxString( wxT("update audio data") ) + wxT('\t') + wxT("CTRL+u"), wxEmptyString, wxITEM_NORMAL );-1 87 m_process = new wxMenuItem(m_edit, wxID_ANY, wxString(wxT("update audio data")) + wxT('\t') + wxT("CTRL+u"), wxEmptyString, wxITEM_NORMAL); 89 88 #ifdef ICONS_GNOME90 -1 m_process->SetBitmap( wxBitmap( wxT("/usr/share/icons/gnome/16x16/actions/stock_refresh.png"), wxBITMAP_TYPE_ANY ) );-1 89 m_process->SetBitmap(wxBitmap(wxT("/usr/share/icons/gnome/16x16/actions/stock_refresh.png"), wxBITMAP_TYPE_ANY)); 91 90 #endif92 -1 m_edit->Append( m_process );93 -194 -1 m_menubar3->Append( m_edit, wxT("Edit") );95 -1-1 91 m_edit->Append(m_process); -1 92 -1 93 m_menubar3->Append(m_edit, wxT("Edit")); -1 94 96 95 m_help = new wxMenu(); 97 96 wxMenuItem* m_about;98 -1 m_about = new wxMenuItem( m_help, wxID_ANY, wxString( wxT("about") ) + wxT('\t') + wxT("F1"), wxEmptyString, wxITEM_NORMAL );-1 97 m_about = new wxMenuItem(m_help, wxID_ANY, wxString(wxT("about")) + wxT('\t') + wxT("F1"), wxEmptyString, wxITEM_NORMAL); 99 98 #ifdef ICONS_GNOME100 -1 m_about->SetBitmap( wxBitmap( wxT("/usr/share/icons/gnome/16x16/actions/help-about.png"), wxBITMAP_TYPE_ANY ) );-1 99 m_about->SetBitmap(wxBitmap(wxT("/usr/share/icons/gnome/16x16/actions/help-about.png"), wxBITMAP_TYPE_ANY)); 101 100 #endif102 -1 m_help->Append( m_about );103 -1104 -1 m_menubar3->Append( m_help, wxT("Help") );105 -1106 -1 this->SetMenuBar( m_menubar3 );107 -1108 -1-1 101 m_help->Append(m_about); -1 102 -1 103 m_menubar3->Append(m_help, wxT("Help")); -1 104 -1 105 this->SetMenuBar(m_menubar3); -1 106 -1 107 109 108 // Connect Events110 -1 this->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( MainFrame::OnLeftDClick ) );111 -1 this->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( MainFrame::OnLeftDown ) );112 -1 this->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( MainFrame::OnLeftUp ) );113 -1 this->Connect( wxEVT_MOTION, wxMouseEventHandler( MainFrame::OnMotion ) );114 -1 this->Connect( wxEVT_PAINT, wxPaintEventHandler( MainFrame::OnPaint ) );115 -1 this->Connect( wxEVT_SIZE, wxSizeEventHandler( MainFrame::OnSize ) );116 -1 this->Connect( m_open->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnOpenClick ) );117 -1 this->Connect( m_export->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnExportClick ) );118 -1 this->Connect( m_prefs->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnPrefsClick ) );119 -1 this->Connect( b_exit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnExitClick ) );120 -1 this->Connect( m_play->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnPlayClick ) );121 -1 this->Connect( m_start->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnStartClick ) );122 -1 this->Connect( m_clear->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnClearClick ) );123 -1 this->Connect( m_process->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnProcessClick ) );124 -1 this->Connect( m_about->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnHelpClick ) );-1 109 this->Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(MainFrame::OnLeftDClick)); -1 110 this->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(MainFrame::OnLeftDown)); -1 111 this->Connect(wxEVT_LEFT_UP, wxMouseEventHandler(MainFrame::OnLeftUp)); -1 112 this->Connect(wxEVT_MOTION, wxMouseEventHandler(MainFrame::OnMotion)); -1 113 this->Connect(wxEVT_PAINT, wxPaintEventHandler(MainFrame::OnPaint)); -1 114 this->Connect(wxEVT_SIZE, wxSizeEventHandler(MainFrame::OnSize)); -1 115 this->Connect(m_open->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnOpenClick)); -1 116 this->Connect(m_export->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnExportClick)); -1 117 this->Connect(m_prefs->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnPrefsClick)); -1 118 this->Connect(b_exit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnExitClick)); -1 119 this->Connect(m_play->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnPlayClick)); -1 120 this->Connect(m_start->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnStartClick)); -1 121 this->Connect(m_clear->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnClearClick)); -1 122 this->Connect(m_process->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnProcessClick)); -1 123 this->Connect(m_about->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnHelpClick)); 125 124 } 126 125127 -1 MainFrame::~MainFrame()128 -1 {-1 126 MainFrame::~MainFrame() { 129 127 // Disconnect Events130 -1 this->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( MainFrame::OnLeftDClick ) );131 -1 this->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( MainFrame::OnLeftDown ) );132 -1 this->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( MainFrame::OnLeftUp ) );133 -1 this->Disconnect( wxEVT_MOTION, wxMouseEventHandler( MainFrame::OnMotion ) );134 -1 this->Disconnect( wxEVT_PAINT, wxPaintEventHandler( MainFrame::OnPaint ) );135 -1 this->Disconnect( wxEVT_SIZE, wxSizeEventHandler( MainFrame::OnSize ) );136 -1 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnOpenClick ) );137 -1 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnExportClick ) );138 -1 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnPrefsClick ) );139 -1 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnExitClick ) );140 -1 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnPlayClick ) );141 -1 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnStartClick ) );142 -1 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnClearClick ) );143 -1 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnProcessClick ) );144 -1 this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnHelpClick ) );-1 128 this->Disconnect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(MainFrame::OnLeftDClick)); -1 129 this->Disconnect(wxEVT_LEFT_DOWN, wxMouseEventHandler(MainFrame::OnLeftDown)); -1 130 this->Disconnect(wxEVT_LEFT_UP, wxMouseEventHandler(MainFrame::OnLeftUp)); -1 131 this->Disconnect(wxEVT_MOTION, wxMouseEventHandler(MainFrame::OnMotion)); -1 132 this->Disconnect(wxEVT_PAINT, wxPaintEventHandler(MainFrame::OnPaint)); -1 133 this->Disconnect(wxEVT_SIZE, wxSizeEventHandler(MainFrame::OnSize)); -1 134 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnOpenClick)); -1 135 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnExportClick)); -1 136 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnPrefsClick)); -1 137 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnExitClick)); -1 138 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnPlayClick)); -1 139 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnStartClick)); -1 140 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnClearClick)); -1 141 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnProcessClick)); -1 142 this->Disconnect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(MainFrame::OnHelpClick)); 145 143 } 146 144147 -1 AboutDialog::AboutDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )148 -1 {149 -1 this->SetSizeHints( wxDefaultSize, wxDefaultSize );150 -1-1 145 AboutDialog::AboutDialog(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxDialog(parent, id, title, pos, size, style) { -1 146 this->SetSizeHints(wxDefaultSize, wxDefaultSize); -1 147 151 148 wxBoxSizer* bSizer4;152 -1 bSizer4 = new wxBoxSizer( wxVERTICAL );153 -1-1 149 bSizer4 = new wxBoxSizer(wxVERTICAL); -1 150 154 151 wxBoxSizer* bSizer14;155 -1 bSizer14 = new wxBoxSizer( wxVERTICAL );156 -1157 -1 m_staticText7 = new wxStaticText( this, wxID_ANY, wxT("xiRetimer v@VERSION@"), wxDefaultPosition, wxDefaultSize, 0 );158 -1 m_staticText7->Wrap( -1 );159 -1 bSizer14->Add( m_staticText7, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );160 -1161 -1 m_staticText1 = new wxStaticText( this, wxID_ANY, wxT("Created by xi."), wxDefaultPosition, wxDefaultSize, 0 );162 -1 m_staticText1->Wrap( -1 );163 -1 bSizer14->Add( m_staticText1, 0, wxALIGN_CENTER|wxALL, 5 );164 -1165 -1 m_staticText2 = new wxStaticText( this, wxID_ANY, wxT("www.github.com/xi"), wxDefaultPosition, wxDefaultSize, 0 );166 -1 m_staticText2->Wrap( -1 );167 -1 bSizer14->Add( m_staticText2, 0, wxALIGN_CENTER|wxALL, 5 );168 -1169 -1 bSizer4->Add( bSizer14, 1, wxEXPAND, 5 );170 -1-1 152 bSizer14 = new wxBoxSizer(wxVERTICAL); -1 153 -1 154 m_staticText7 = new wxStaticText(this, wxID_ANY, wxT("xiRetimer v@VERSION@"), wxDefaultPosition, wxDefaultSize, 0); -1 155 m_staticText7->Wrap(-1); -1 156 bSizer14->Add(m_staticText7, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5); -1 157 -1 158 m_staticText1 = new wxStaticText(this, wxID_ANY, wxT("Created by xi."), wxDefaultPosition, wxDefaultSize, 0); -1 159 m_staticText1->Wrap(-1); -1 160 bSizer14->Add(m_staticText1, 0, wxALIGN_CENTER|wxALL, 5); -1 161 -1 162 m_staticText2 = new wxStaticText(this, wxID_ANY, wxT("www.github.com/xi"), wxDefaultPosition, wxDefaultSize, 0); -1 163 m_staticText2->Wrap(-1); -1 164 bSizer14->Add(m_staticText2, 0, wxALIGN_CENTER|wxALL, 5); -1 165 -1 166 bSizer4->Add(bSizer14, 1, wxEXPAND, 5); -1 167 171 168 wxBoxSizer* bSizer7;172 -1 bSizer7 = new wxBoxSizer( wxVERTICAL );173 -1174 -1 m_button1 = new wxButton( this, wxID_ANY, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 );175 -1 bSizer7->Add( m_button1, 0, wxALIGN_CENTER|wxALL, 5 );176 -1177 -1 bSizer4->Add( bSizer7, 0, wxEXPAND, 5 );178 -1179 -1 this->SetSizer( bSizer4 );-1 169 bSizer7 = new wxBoxSizer(wxVERTICAL); -1 170 -1 171 m_button1 = new wxButton(this, wxID_ANY, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0); -1 172 bSizer7->Add(m_button1, 0, wxALIGN_CENTER|wxALL, 5); -1 173 -1 174 bSizer4->Add(bSizer7, 0, wxEXPAND, 5); -1 175 -1 176 this->SetSizer(bSizer4); 180 177 this->Layout();181 -1-1 178 182 179 // Connect Events183 -1 m_button1->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( AboutDialog::OnOKClick ), NULL, this );-1 180 m_button1->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(AboutDialog::OnOKClick), NULL, this); 184 181 } 185 182186 -1 AboutDialog::~AboutDialog()187 -1 {-1 183 AboutDialog::~AboutDialog() { 188 184 // Disconnect Events189 -1 m_button1->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( AboutDialog::OnOKClick ), NULL, this );-1 185 m_button1->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(AboutDialog::OnOKClick), NULL, this); 190 186 } 191 187192 -1 PrefsDialog::PrefsDialog( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )193 -1 {194 -1 this->SetSizeHints( wxDefaultSize, wxDefaultSize );195 -1-1 188 PrefsDialog::PrefsDialog(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) : wxDialog(parent, id, title, pos, size, style) { -1 189 this->SetSizeHints(wxDefaultSize, wxDefaultSize); -1 190 196 191 wxBoxSizer* bSizer5;197 -1 bSizer5 = new wxBoxSizer( wxVERTICAL );198 -1-1 192 bSizer5 = new wxBoxSizer(wxVERTICAL); -1 193 199 194 wxFlexGridSizer* fgSizer4;200 -1 fgSizer4 = new wxFlexGridSizer( 2, 2, 0, 0 );201 -1 fgSizer4->AddGrowableCol( 1 );202 -1 fgSizer4->SetFlexibleDirection( wxBOTH );203 -1 fgSizer4->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );204 -1205 -1 l_intmode = new wxStaticText( this, wxID_ANY, wxT("Interpolation Mode"), wxDefaultPosition, wxDefaultSize, 0 );206 -1 l_intmode->Wrap( -1 );207 -1 fgSizer4->Add( l_intmode, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );208 -1-1 195 fgSizer4 = new wxFlexGridSizer(2, 2, 0, 0); -1 196 fgSizer4->AddGrowableCol(1); -1 197 fgSizer4->SetFlexibleDirection(wxBOTH); -1 198 fgSizer4->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED); -1 199 -1 200 l_intmode = new wxStaticText(this, wxID_ANY, wxT("Interpolation Mode"), wxDefaultPosition, wxDefaultSize, 0); -1 201 l_intmode->Wrap(-1); -1 202 fgSizer4->Add(l_intmode, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); -1 203 209 204 wxString c_intmodeChoices[] = { wxT("Linear"), wxT("Polynominal") };210 -1 int c_intmodeNChoices = sizeof( c_intmodeChoices ) / sizeof( wxString );211 -1 c_intmode = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, c_intmodeNChoices, c_intmodeChoices, 0 );212 -1 c_intmode->SetSelection( 0 );213 -1 fgSizer4->Add( c_intmode, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );214 -1215 -1 l_showint = new wxStaticText( this, wxID_ANY, wxT("show interpolation curve"), wxDefaultPosition, wxDefaultSize, 0 );216 -1 l_showint->Wrap( -1 );217 -1 fgSizer4->Add( l_showint, 0, wxALL, 5 );218 -1219 -1 m_showint = new wxCheckBox( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );220 -1 fgSizer4->Add( m_showint, 0, wxALL, 5 );221 -1222 -1 l_stretchmode = new wxStaticText( this, wxID_ANY, wxT("Stretch Mode"), wxDefaultPosition, wxDefaultSize, 0 );223 -1 l_stretchmode->Wrap( -1 );224 -1 fgSizer4->Add( l_stretchmode, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );225 -1-1 205 int c_intmodeNChoices = sizeof(c_intmodeChoices) / sizeof(wxString); -1 206 c_intmode = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, c_intmodeNChoices, c_intmodeChoices, 0); -1 207 c_intmode->SetSelection(0); -1 208 fgSizer4->Add(c_intmode, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5); -1 209 -1 210 l_showint = new wxStaticText(this, wxID_ANY, wxT("show interpolation curve"), wxDefaultPosition, wxDefaultSize, 0); -1 211 l_showint->Wrap(-1); -1 212 fgSizer4->Add(l_showint, 0, wxALL, 5); -1 213 -1 214 m_showint = new wxCheckBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); -1 215 fgSizer4->Add(m_showint, 0, wxALL, 5); -1 216 -1 217 l_stretchmode = new wxStaticText(this, wxID_ANY, wxT("Stretch Mode"), wxDefaultPosition, wxDefaultSize, 0); -1 218 l_stretchmode->Wrap(-1); -1 219 fgSizer4->Add(l_stretchmode, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); -1 220 226 221 // TODO 227 222 #ifdef MODE_RUBBERBAND 228 223 wxString c_stretchmodeChoices[] = { wxT("none"), wxT("RubberBand")}; 229 224 #else230 -1 wxString c_stretchmodeChoices[] = { wxT("none"), wxT("RubberBand (diabled)")};-1 225 wxString c_stretchmodeChoices[] = { wxT("none"), wxT("RubberBand (disabled)")}; 231 226 #endif232 -1233 -1 int c_stretchmodeNChoices = sizeof( c_stretchmodeChoices ) / sizeof( wxString );234 -1 c_stretchmode = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, c_stretchmodeNChoices, c_stretchmodeChoices, 0 );235 -1 c_stretchmode->SetSelection( 0 );236 -1 fgSizer4->Add( c_stretchmode, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );237 -1238 -1 l_tempo = new wxStaticText( this, wxID_ANY, wxT("Tempo"), wxDefaultPosition, wxDefaultSize, 0 );239 -1 l_tempo->Wrap( -1 );240 -1 fgSizer4->Add( l_tempo, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );241 -1242 -1 t_tempo = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_RIGHT );243 -1 fgSizer4->Add( t_tempo, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );244 -1245 -1 l_beatres = new wxStaticText( this, wxID_ANY, wxT("Beat Resolution"), wxDefaultPosition, wxDefaultSize, 0 );246 -1 l_beatres->Wrap( -1 );247 -1 fgSizer4->Add( l_beatres, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );248 -1249 -1 t_beatres = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_RIGHT );250 -1 fgSizer4->Add( t_beatres, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5 );251 -1252 -1 bSizer5->Add( fgSizer4, 1, wxEXPAND, 5 );253 -1-1 227 -1 228 int c_stretchmodeNChoices = sizeof(c_stretchmodeChoices) / sizeof(wxString); -1 229 c_stretchmode = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, c_stretchmodeNChoices, c_stretchmodeChoices, 0); -1 230 c_stretchmode->SetSelection(0); -1 231 fgSizer4->Add(c_stretchmode, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5); -1 232 -1 233 l_tempo = new wxStaticText(this, wxID_ANY, wxT("Tempo"), wxDefaultPosition, wxDefaultSize, 0); -1 234 l_tempo->Wrap(-1); -1 235 fgSizer4->Add(l_tempo, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); -1 236 -1 237 t_tempo = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_RIGHT); -1 238 fgSizer4->Add(t_tempo, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5); -1 239 -1 240 l_beatres = new wxStaticText(this, wxID_ANY, wxT("Beat Resolution"), wxDefaultPosition, wxDefaultSize, 0); -1 241 l_beatres->Wrap(-1); -1 242 fgSizer4->Add(l_beatres, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5); -1 243 -1 244 t_beatres = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxTE_RIGHT); -1 245 fgSizer4->Add(t_beatres, 1, wxALL|wxEXPAND|wxALIGN_CENTER_VERTICAL, 5); -1 246 -1 247 bSizer5->Add(fgSizer4, 1, wxEXPAND, 5); -1 248 254 249 wxBoxSizer* bSizer15;255 -1 bSizer15 = new wxBoxSizer( wxHORIZONTAL );256 -1257 -1 b_OK = new wxButton( this, wxID_ANY, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0 );258 -1 bSizer15->Add( b_OK, 0, wxALL|wxALIGN_BOTTOM|wxALIGN_RIGHT, 5 );259 -1260 -1 b_Cancel = new wxButton( this, wxID_ANY, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );261 -1 b_Cancel->SetToolTip( wxT("Escape") );262 -1263 -1 bSizer15->Add( b_Cancel, 0, wxALIGN_BOTTOM|wxALIGN_RIGHT|wxALL, 5 );264 -1265 -1 bSizer5->Add( bSizer15, 0, wxALIGN_RIGHT, 5 );266 -1267 -1 this->SetSizer( bSizer5 );-1 250 bSizer15 = new wxBoxSizer(wxHORIZONTAL); -1 251 -1 252 b_OK = new wxButton(this, wxID_ANY, wxT("OK"), wxDefaultPosition, wxDefaultSize, 0); -1 253 bSizer15->Add(b_OK, 0, wxALL|wxALIGN_BOTTOM|wxALIGN_RIGHT, 5); -1 254 -1 255 b_Cancel = new wxButton(this, wxID_ANY, wxT("Cancel"), wxDefaultPosition, wxDefaultSize, 0); -1 256 b_Cancel->SetToolTip(wxT("Escape")); -1 257 -1 258 bSizer15->Add(b_Cancel, 0, wxALIGN_BOTTOM|wxALIGN_RIGHT|wxALL, 5); -1 259 -1 260 bSizer5->Add(bSizer15, 0, wxALIGN_RIGHT, 5); -1 261 -1 262 this->SetSizer(bSizer5); 268 263 this->Layout();269 -1-1 264 270 265 // Connect Events271 -1 c_intmode->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PrefsDialog::OnIntModeChange ), NULL, this );272 -1 m_showint->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PrefsDialog::OnCheckShowInt ), NULL, this );273 -1 c_stretchmode->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PrefsDialog::OnStretchModeChange ), NULL, this );274 -1 t_tempo->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( PrefsDialog::OnTempoEnter ), NULL, this );275 -1 t_beatres->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( PrefsDialog::OnBeatResEnter ), NULL, this );276 -1 b_OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PrefsDialog::OnOKClick ), NULL, this );277 -1 b_Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PrefsDialog::OnCancelClick ), NULL, this );-1 266 c_intmode->Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(PrefsDialog::OnIntModeChange), NULL, this); -1 267 m_showint->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(PrefsDialog::OnCheckShowInt), NULL, this); -1 268 c_stretchmode->Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(PrefsDialog::OnStretchModeChange), NULL, this); -1 269 t_tempo->Connect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(PrefsDialog::OnTempoEnter), NULL, this); -1 270 t_beatres->Connect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(PrefsDialog::OnBeatResEnter), NULL, this); -1 271 b_OK->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PrefsDialog::OnOKClick), NULL, this); -1 272 b_Cancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PrefsDialog::OnCancelClick), NULL, this); 278 273 } 279 274280 -1 PrefsDialog::~PrefsDialog()281 -1 {-1 275 PrefsDialog::~PrefsDialog() { 282 276 // Disconnect Events283 -1 c_intmode->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PrefsDialog::OnIntModeChange ), NULL, this );284 -1 c_stretchmode->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PrefsDialog::OnStretchModeChange ), NULL, this );285 -1 t_tempo->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( PrefsDialog::OnTempoEnter ), NULL, this );286 -1 t_beatres->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( PrefsDialog::OnBeatResEnter ), NULL, this );287 -1 b_OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PrefsDialog::OnOKClick ), NULL, this );288 -1 b_Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PrefsDialog::OnCancelClick ), NULL, this );-1 277 c_intmode->Disconnect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(PrefsDialog::OnIntModeChange), NULL, this); -1 278 c_stretchmode->Disconnect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(PrefsDialog::OnStretchModeChange), NULL, this); -1 279 t_tempo->Disconnect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(PrefsDialog::OnTempoEnter), NULL, this); -1 280 t_beatres->Disconnect(wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler(PrefsDialog::OnBeatResEnter), NULL, this); -1 281 b_OK->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PrefsDialog::OnOKClick), NULL, this); -1 282 b_Cancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PrefsDialog::OnCancelClick), NULL, this); 289 283 }
diff --git a/src/gui/retimer_wx.h b/src/gui/retimer_wx.h
@@ -33,73 +33,61 @@ 33 33 /////////////////////////////////////////////////////////////////////////////// 34 34 /// Class MainFrame 35 35 ///////////////////////////////////////////////////////////////////////////////36 -1 class MainFrame : public wxFrame-1 36 class MainFrame : public wxFrame 37 37 {38 -1 private:39 -140 38 protected: 41 39 wxStatusBar* m_statusBar1; 42 40 wxMenuBar* m_menubar3; 43 41 wxMenu* m_file; 44 42 wxMenu* m_edit; 45 43 wxMenu* m_help;46 -1-1 44 47 45 // Virtual event handlers, overide them in your derived class48 -1 virtual void OnLeftDClick( wxMouseEvent& event ) { event.Skip(); }49 -1 virtual void OnLeftDown( wxMouseEvent& event ) { event.Skip(); }50 -1 virtual void OnLeftUp( wxMouseEvent& event ) { event.Skip(); }51 -1 virtual void OnMotion( wxMouseEvent& event ) { event.Skip(); }52 -1 virtual void OnPaint( wxPaintEvent& event ) { event.Skip(); }53 -1 virtual void OnSize( wxSizeEvent& event ) { event.Skip(); }54 -1 virtual void OnOpenClick( wxCommandEvent& event ) { event.Skip(); }55 -1 virtual void OnExportClick( wxCommandEvent& event ) { event.Skip(); }56 -1 virtual void OnPrefsClick( wxCommandEvent& event ) { event.Skip(); }57 -1 virtual void OnExitClick( wxCommandEvent& event ) { event.Skip(); }58 -1 virtual void OnPlayClick( wxCommandEvent& event ) { event.Skip(); }59 -1 virtual void OnStartClick( wxCommandEvent& event ) { event.Skip(); }60 -1 virtual void OnClearClick( wxCommandEvent& event ) { event.Skip(); }61 -1 virtual void OnProcessClick( wxCommandEvent& event ) { event.Skip(); }62 -1 virtual void OnHelpClick( wxCommandEvent& event ) { event.Skip(); }63 -164 -1-1 46 virtual void OnLeftDClick(wxMouseEvent& event) { event.Skip(); } -1 47 virtual void OnLeftDown(wxMouseEvent& event) { event.Skip(); } -1 48 virtual void OnLeftUp(wxMouseEvent& event) { event.Skip(); } -1 49 virtual void OnMotion(wxMouseEvent& event) { event.Skip(); } -1 50 virtual void OnPaint(wxPaintEvent& event) { event.Skip(); } -1 51 virtual void OnSize(wxSizeEvent& event) { event.Skip(); } -1 52 virtual void OnOpenClick(wxCommandEvent& event) { event.Skip(); } -1 53 virtual void OnExportClick(wxCommandEvent& event) { event.Skip(); } -1 54 virtual void OnPrefsClick(wxCommandEvent& event) { event.Skip(); } -1 55 virtual void OnExitClick(wxCommandEvent& event) { event.Skip(); } -1 56 virtual void OnPlayClick(wxCommandEvent& event) { event.Skip(); } -1 57 virtual void OnStartClick(wxCommandEvent& event) { event.Skip(); } -1 58 virtual void OnClearClick(wxCommandEvent& event) { event.Skip(); } -1 59 virtual void OnProcessClick(wxCommandEvent& event) { event.Skip(); } -1 60 virtual void OnHelpClick(wxCommandEvent& event) { event.Skip(); } -1 61 65 62 public:66 -167 -1 MainFrame( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("xiRetimer"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 611,397 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );-1 63 MainFrame(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("xiRetimer"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(611,397), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL); 68 64 ~MainFrame();69 -170 65 }; 71 66 72 67 /////////////////////////////////////////////////////////////////////////////// 73 68 /// Class AboutDialog 74 69 ///////////////////////////////////////////////////////////////////////////////75 -1 class AboutDialog : public wxDialog-1 70 class AboutDialog : public wxDialog 76 71 {77 -1 private:78 -179 72 protected: 80 73 wxStaticText* m_staticText7; 81 74 wxStaticText* m_staticText1; 82 75 wxStaticText* m_staticText2; 83 76 wxButton* m_button1;84 -1-1 77 85 78 // Virtual event handlers, overide them in your derived class86 -1 virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); }87 -188 -1-1 79 virtual void OnOKClick(wxCommandEvent& event) { event.Skip(); } -1 80 89 81 public:90 -191 -1 AboutDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("About"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 159,135 ), long style = wxDEFAULT_DIALOG_STYLE );-1 82 AboutDialog(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("About"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(159,135), long style = wxDEFAULT_DIALOG_STYLE); 92 83 ~AboutDialog();93 -194 84 }; 95 85 96 86 /////////////////////////////////////////////////////////////////////////////// 97 87 /// Class PrefsDialog 98 88 ///////////////////////////////////////////////////////////////////////////////99 -1 class PrefsDialog : public wxDialog-1 89 class PrefsDialog : public wxDialog 100 90 {101 -1 private:102 -1103 91 protected: 104 92 wxStaticText* l_intmode; 105 93 wxChoice* c_intmode; @@ -113,22 +101,19 @@ class PrefsDialog : public wxDialog 113 101 wxTextCtrl* t_beatres; 114 102 wxButton* b_OK; 115 103 wxButton* b_Cancel;116 -1-1 104 117 105 // Virtual event handlers, overide them in your derived class118 -1 virtual void OnIntModeChange( wxCommandEvent& event ) { event.Skip(); }119 -1 virtual void OnCheckShowInt( wxCommandEvent& event ) { event.Skip(); }120 -1 virtual void OnStretchModeChange( wxCommandEvent& event ) { event.Skip(); }121 -1 virtual void OnTempoEnter( wxCommandEvent& event ) { event.Skip(); }122 -1 virtual void OnBeatResEnter( wxCommandEvent& event ) { event.Skip(); }123 -1 virtual void OnOKClick( wxCommandEvent& event ) { event.Skip(); }124 -1 virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); }125 -1126 -1-1 106 virtual void OnIntModeChange(wxCommandEvent& event) { event.Skip(); } -1 107 virtual void OnCheckShowInt(wxCommandEvent& event) { event.Skip(); } -1 108 virtual void OnStretchModeChange(wxCommandEvent& event) { event.Skip(); } -1 109 virtual void OnTempoEnter(wxCommandEvent& event) { event.Skip(); } -1 110 virtual void OnBeatResEnter(wxCommandEvent& event) { event.Skip(); } -1 111 virtual void OnOKClick(wxCommandEvent& event) { event.Skip(); } -1 112 virtual void OnCancelClick(wxCommandEvent& event) { event.Skip(); } -1 113 127 114 public:128 -1129 -1 PrefsDialog( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Preferences"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 322,238 ), long style = wxDEFAULT_DIALOG_STYLE );-1 115 PrefsDialog(wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Preferences"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(322,238), long style = wxDEFAULT_DIALOG_STYLE); 130 116 ~PrefsDialog();131 -1132 117 }; 133 118 134 119 #endif //__retimer_wx__
diff --git a/src/intmode_poly.h b/src/intmode_poly.h
@@ -4,143 +4,160 @@ 4 4 #include <iostream> 5 5 #include "marker.h" 6 67 -1 /*8 -1 This defines a interpolytion mode used in marker9 -1 */-1 7 /* This defines a interpolytion mode used in marker */ 10 8 11 9 namespace _IntPoly {12 -1 void update(Marker* marker, int pi);13 -1 float calculate(float x);14 -1 float** invertMatrix(float** A);15 -1 float a=0,b=0,c=0,d=0;16 -1 int IPi,IPn;-1 10 void update(Marker* marker, int pi); -1 11 float calculate(float x); -1 12 float** invertMatrix(float** A); -1 13 float a=0, b=0, c=0, d=0; -1 14 int IPi, IPn; 17 15 } 18 16 -1 17 19 18 float int_poly(Marker* marker, float old) {20 -1 int ii=marker->getAreaOld(old);21 -1 if (marker->_update || ii!=_IntPoly::IPi) _IntPoly::update(marker,ii);22 -1 marker->_update=false;23 -1 return _IntPoly::calculate(old);-1 19 int ii = marker->getAreaOld(old); -1 20 if (marker->_update || ii != _IntPoly::IPi) { -1 21 _IntPoly::update(marker,ii); -1 22 } -1 23 marker->_update = false; -1 24 return _IntPoly::calculate(old); 24 25 } 25 26 26 27 //*********************************************************************// 27 28 28 29 float _IntPoly::calculate(float x) {29 -1 return _IntPoly::a*x*x*x+_IntPoly::b*x*x+_IntPoly::c*x+_IntPoly::d;-1 30 float ret = _IntPoly::a * x * x * x; -1 31 ret += _IntPoly::b * x * x; -1 32 ret += _IntPoly::c * x; -1 33 ret += _IntPoly::d; -1 34 return ret; 30 35 } 31 36 -1 37 32 38 void _IntPoly::update(Marker* marker, int pi) {33 -1 IPn=marker->getLength();34 -1 IPi=pi;35 -1 float x1=marker->getOld(IPi);36 -1 float x2=marker->getOld(IPi+1);37 -1 float y1=marker->getNew(IPi);38 -1 float y2=marker->getNew(IPi+1);39 -1 float d1;40 -1 float d2;41 -1 if (IPi<=0)42 -1 d1=(marker->getNew(1)-marker->getNew(0))/(marker->getOld(1)-marker->getOld(0));43 -1 else44 -1 d1=(marker->getNew(IPi-1)-y2)/(marker->getOld(IPi-1)-x2);45 -1 if (IPi>=IPn-2)46 -1 d2=(marker->getNew(IPn-1)-marker->getNew(IPn-2))/(marker->getOld(IPn-1)-marker->getOld(IPn-2));47 -1 else48 -1 d2=(y1-marker->getNew(IPi+2))/(x1-marker->getOld(IPi+2));49 -150 -1 float** M=new float*[3];51 -1 for (int j=0; j<3; ++j) {52 -1 M[j]=new float[3];53 -1 }54 -155 -1 M[0][0]=3*x1*x1;56 -1 M[0][1]=2*x1;57 -1 M[0][2]=1;58 -159 -1 M[1][0]=3*x2*x2;60 -1 M[1][1]=2*x2;61 -1 M[1][2]=1;62 -163 -1 M[2][0]=x2*x2*x2-x1*x1*x1;64 -1 M[2][1]=x2*x2-x1*x1;65 -1 M[2][2]=x2-x1;66 -167 -1 float** I=invertMatrix(M);68 -169 -1 int zeros=0;70 -1 for (int j=0; j<3; ++j) {71 -1 for (int jj=0; jj<3; ++jj) {72 -1 if (I[j][jj]==0) zeros++;73 -1 }74 -1 }75 -1 if (zeros==9) {76 -1 a=0;77 -1 b=0;78 -1 c=(y2-y1)/(x2-x1);79 -1 d=y1;80 -1 return;81 -1 }82 -183 -184 -1 for (int j=0; j<3; ++j) {85 -1 delete[] M[j];86 -1 }87 -1 delete[] M;88 -189 -1 _IntPoly::a=I[0][0]*d1+I[0][1]*d2+I[0][2]*(y2-y1);90 -1 _IntPoly::b=I[1][0]*d1+I[1][1]*d2+I[1][2]*(y2-y1);91 -1 _IntPoly::c=I[2][0]*d1+I[2][1]*d2+I[2][2]*(y2-y1);92 -1 _IntPoly::d=y1-_IntPoly::a*x1*x1*x1-_IntPoly::b*x1*x1-_IntPoly::c*x1;93 -194 -1 for (int j=0; j<3; ++j) {95 -1 delete[] I[j];96 -1 }97 -1 delete[] I;-1 39 IPn = marker->getLength(); -1 40 IPi = pi; -1 41 float x1 = marker->getOld(IPi); -1 42 float x2 = marker->getOld(IPi + 1); -1 43 float y1 = marker->getNew(IPi); -1 44 float y2 = marker->getNew(IPi + 1); -1 45 float d1; -1 46 float d2; -1 47 if (IPi <= 0) { -1 48 d1 = marker->getNew(1) - marker->getNew(0); -1 49 d1 /= marker->getOld(1) - marker->getOld(0); -1 50 } else { -1 51 d1 = (marker->getNew(IPi - 1) - y2) / (marker->getOld(IPi - 1) - x2); -1 52 } -1 53 if (IPi >= IPn - 2) { -1 54 d2 = marker->getNew(IPn - 1) - marker->getNew(IPn - 2); -1 55 d2 /= marker->getOld(IPn - 1) - marker->getOld(IPn - 2); -1 56 } else { -1 57 d2 = (y1 - marker->getNew(IPi + 2)) / (x1 - marker->getOld(IPi + 2)); -1 58 } -1 59 -1 60 float** M = new float*[3]; -1 61 for (int j = 0; j < 3; ++j) { -1 62 M[j] = new float[3]; -1 63 } -1 64 -1 65 M[0][0] = 3 * x1 * x1; -1 66 M[0][1] = 2 * x1; -1 67 M[0][2] = 1; -1 68 -1 69 M[1][0] = 3 * x2 * x2; -1 70 M[1][1] = 2 * x2; -1 71 M[1][2] = 1; -1 72 -1 73 M[2][0] = x2 * x2 * x2 - x1 * x1 * x1; -1 74 M[2][1] = x2 * x2 - x1 * x1; -1 75 M[2][2] = x2 - x1; -1 76 -1 77 float** I = invertMatrix(M); -1 78 -1 79 int zeros = 0; -1 80 for (int j = 0; j < 3; ++j) { -1 81 for (int jj = 0; jj < 3; ++jj) { -1 82 if (I[j][jj] == 0) { -1 83 zeros++; -1 84 } -1 85 } -1 86 } -1 87 if (zeros == 9) { -1 88 a = 0; -1 89 b = 0; -1 90 c = (y2 - y1) / (x2 - x1); -1 91 d = y1; -1 92 return; -1 93 } -1 94 -1 95 -1 96 for (int j = 0; j < 3; ++j) { -1 97 delete[] M[j]; -1 98 } -1 99 delete[] M; -1 100 -1 101 _IntPoly::a = I[0][0] * d1 + I[0][1] * d2 + I[0][2] * (y2 - y1); -1 102 _IntPoly::b = I[1][0] * d1 + I[1][1] * d2 + I[1][2] * (y2 - y1); -1 103 _IntPoly::c = I[2][0] * d1 + I[2][1] * d2 + I[2][2] * (y2 - y1); -1 104 -1 105 _IntPoly::d = y1; -1 106 _IntPoly::d -= _IntPoly::a * x1 * x1 * x1; -1 107 _IntPoly::d -= _IntPoly::b * x1 * x1; -1 108 _IntPoly::d -= _IntPoly::c * x1; -1 109 -1 110 for (int j = 0; j < 3; ++j) { -1 111 delete[] I[j]; -1 112 } -1 113 delete[] I; 98 114 } 99 115 -1 116 100 117 float** _IntPoly::invertMatrix(float** A) {101 -1 float** X=new float*[3];102 -1 for (int i=0; i<3; ++i) {103 -1 X[i]=new float[3];104 -1 }105 -1 int i,j;106 -1 float n=0; // determinant of A107 -1108 -1 n+=A[0][0]*A[1][1]*A[2][2];109 -1 n+=A[0][1]*A[1][2]*A[2][0];110 -1 n+=A[0][2]*A[1][0]*A[2][1];111 -1112 -1 n-=A[0][0]*A[1][2]*A[2][1];113 -1 n-=A[0][1]*A[1][0]*A[2][2];114 -1 n-=A[0][2]*A[1][1]*A[2][0];115 -1116 -1 if(n*n<=0.00000000001) {117 -1 for (int i=0; i<3; ++i) {118 -1 for (int j=0; j<3; ++j) {119 -1 X[i][j]=0;120 -1 }121 -1 }122 -1 return X;123 -1 }124 -1125 -1 X[0][0]=A[1][1]*A[2][2]-(A[2][1]*A[1][2]);126 -1 X[1][0]=(-1)*(A[1][0]*A[2][2]-(A[2][0]*A[1][2]));127 -1 X[2][0]=A[1][0]*A[2][1]-(A[2][0]*A[1][1]);128 -1129 -1 X[0][1]=(-1)*(A[0][1]*A[2][2]-A[2][1]*A[0][2]);130 -1 X[1][1]=A[0][0]*A[2][2]-A[0][2]*A[2][0];131 -1 X[2][1]=(-1)*(A[0][0]*A[2][1]-A[2][0]*A[0][1]);132 -1133 -1 X[0][2]=A[0][1]*A[1][2]-A[1][1]*A[0][2];134 -1 X[1][2]=(-1)*(A[0][0]*A[1][2]-A[1][0]*A[0][2]);135 -1 X[2][2]=A[0][0]*A[1][1]-A[1][0]*A[0][1];136 -1137 -1 for(i=0;i<3;i++) {138 -1 for(j=0;j<3;j++) {139 -1 X[i][j]=X[i][j]/n;140 -1 }141 -1 }142 -1143 -1 return X;144 -1 }-1 118 float** X = new float*[3]; -1 119 for (int i = 0; i < 3; ++i) { -1 120 X[i] = new float[3]; -1 121 } -1 122 int i,j; -1 123 float n = 0; // determinant of A -1 124 -1 125 n += A[0][0] * A[1][1] * A[2][2]; -1 126 n += A[0][1] * A[1][2] * A[2][0]; -1 127 n += A[0][2] * A[1][0] * A[2][1]; -1 128 -1 129 n -= A[0][0] * A[1][2] * A[2][1]; -1 130 n -= A[0][1] * A[1][0] * A[2][2]; -1 131 n -= A[0][2] * A[1][1] * A[2][0]; -1 132 -1 133 if (n * n <= 0.00000000001) { -1 134 for (int i = 0; i < 3; ++i) { -1 135 for (int j = 0; j < 3; ++j) { -1 136 X[i][j] = 0; -1 137 } -1 138 } -1 139 return X; -1 140 } -1 141 -1 142 X[0][0] = A[1][1] * A[2][2] - (A[2][1] * A[1][2]); -1 143 X[1][0] = (-1) * (A[1][0] * A[2][2] - (A[2][0] * A[1][2])); -1 144 X[2][0] = A[1][0] * A[2][1] - (A[2][0] * A[1][1]); -1 145 -1 146 X[0][1] = (-1) * (A[0][1] * A[2][2] - A[2][1] * A[0][2]); -1 147 X[1][1] = A[0][0] * A[2][2] - A[0][2] * A[2][0]; -1 148 X[2][1] = (-1) * (A[0][0] * A[2][1]-A[2][0] * A[0][1]); -1 149 -1 150 X[0][2] = A[0][1] * A[1][2] - A[1][1] * A[0][2]; -1 151 X[1][2] = (-1) * (A[0][0] * A[1][2] - A[1][0] * A[0][2]); -1 152 X[2][2] = A[0][0] * A[1][1] - A[1][0] * A[0][1]; -1 153 -1 154 for(i = 0;i < 3; i++) { -1 155 for(j = 0; j < 3; j++) { -1 156 X[i][j] = X[i][j] / n; -1 157 } -1 158 } -1 159 -1 160 return X; -1 161 } 145 162 146 163 #endif
diff --git a/src/marker.cpp b/src/marker.cpp
@@ -1,206 +1,269 @@ 1 1 #include "marker.h" 2 2 #include "intmode_poly.h" 3 3 -1 4 4 5 Marker::Marker() {5 -1 anew;6 -1 aold;7 -1 add(0,0);8 -1 add(1,1);9 -1 interpolationMode=0;10 -1 _update=true;-1 6 anew; -1 7 aold; -1 8 add(0, 0); -1 9 add(1, 1); -1 10 interpolationMode = 0; -1 11 _update = true; 11 12 } 12 13 -1 14 13 15 Marker::~Marker() { 14 16 } 15 17 -1 18 16 19 void Marker::reset() {17 -1 while(getLength()>0) {18 -1 anew.remove(0);19 -1 aold.remove(0);20 -1 }21 -1 add(0,0);22 -1 add(1,1);-1 20 while (getLength() > 0) { -1 21 anew.remove(0); -1 22 aold.remove(0); -1 23 } -1 24 add(0, 0); -1 25 add(1, 1); 23 26 } 24 27 -1 28 25 29 void Marker::add(float pold, float pnew) {26 -1 if (pold<0 || pold>1) {27 -1 std::cerr << "Error in Marker::add" << std::endl;28 -1 std::cerr << " pold not in range" << std::endl;29 -1 return;30 -1 }31 -1 if (getAreaOld(pold)!=getAreaNew(pnew)) {32 -1 std::cerr << "Error in Marker::add" << std::endl;33 -1 std::cerr << " Areas not Fitting: ";34 -1 std::cerr << getAreaOld(pold) << " " << getAreaNew(pnew) << std::endl;35 -1 return;36 -1 }37 -1 anew.add(pnew);38 -1 aold.add(pold);39 -1 _update=true;40 -1 }41 -1-1 30 if (pold < 0 || pold > 1) { -1 31 std::cerr << "Error in Marker::add" << std::endl; -1 32 std::cerr << "pold not in range" << std::endl; -1 33 return; -1 34 } -1 35 if (getAreaOld(pold) != getAreaNew(pnew)) { -1 36 std::cerr << "Error in Marker::add" << std::endl; -1 37 std::cerr << "Areas not Fitting: "; -1 38 std::cerr << getAreaOld(pold) << " " << getAreaNew(pnew) << std::endl; -1 39 return; -1 40 } -1 41 anew.add(pnew); -1 42 aold.add(pold); -1 43 _update = true; -1 44 } -1 45 -1 46 42 47 void Marker::remove(int pi) {43 -1 if (getLength()<=2) return;44 -1 int i=resort(pi);45 -1 anew.remove(i);46 -1 aold.remove(i);47 -1 _update=true;-1 48 if (getLength() <= 2) { -1 49 return; -1 50 } -1 51 int i = resort(pi); -1 52 anew.remove(i); -1 53 aold.remove(i); -1 54 _update = true; 48 55 } 49 56 -1 57 50 58 float Marker::getNew(int pi) {51 -1 return anew.get(resort(pi));-1 59 return anew.get(resort(pi)); 52 60 } 53 61 -1 62 54 63 float Marker::getOld(int pi) {55 -1 return aold.get(resort(pi));-1 64 return aold.get(resort(pi)); 56 65 } 57 66 -1 67 58 68 void Marker::setNew(int pi, float pnew) {59 -1 anew.set(resort(pi), pnew);60 -1 _update=true;-1 69 anew.set(resort(pi), pnew); -1 70 _update = true; -1 71 } -1 72 -1 73 -1 74 int Marker::getInterpolationMode() { -1 75 return interpolationMode; -1 76 } -1 77 -1 78 -1 79 void Marker::setInterpolationMode(int m) { -1 80 interpolationMode = m; 61 81 } 62 8263 -1 int Marker::getInterpolationMode() {return interpolationMode;}64 -1 void Marker::setInterpolationMode(int m) {interpolationMode=m;}65 83 66 84 float Marker::getLengthf() {67 -1 if (getLength()>0)68 -1 return getNew(getLength()-1)-getNew(0);69 -1 else70 -1 return NULL;-1 85 if (getLength() > 0) { -1 86 return getNew(getLength() - 1) - getNew(0); -1 87 } else { -1 88 return NULL; -1 89 } 71 90 } 72 91 -1 92 73 93 float Marker::getRatio(float o) {74 -1 // deprivated75 -1 // derivate of old2new76 -1 // hardcode the derivate to improve performance77 -1 switch (getInterpolationMode()) {78 -1 // linear79 -1 case 0: {80 -1 int i=getAreaOld(o);81 -1 if (i<0 || i+1>getLength()-1) return 0;82 -1 float dold=(getOld(i+1)-getOld(i));83 -1 if (dold<=0) return 0;84 -1 return (getNew(i+1)-getNew(i))/dold;85 -1 } break;86 -1 default: {87 -1 // approxmiate ratio88 -1 float n=100; // TODO automate this89 -1 float o1=o-1/n;90 -1 if (o1<0) o1=0;91 -1 if (o1>1) return 0;92 -1 float o2=o+1/n;93 -1 if (o2<0) return 0;94 -1 if (o2>1) o2=1;95 -1 if (o2-o1<=0) return 0;96 -1 return ((old2new(o2)-old2new(o1))/(o2-o1));97 -1 }98 -1 }-1 94 // deprecated -1 95 // derivate of old2new -1 96 // hardcode the derivate to improve performance -1 97 switch (getInterpolationMode()) { -1 98 // linear -1 99 case 0: { -1 100 int i = getAreaOld(o); -1 101 if (i < 0 || i + 1 > getLength() - 1) { -1 102 return 0; -1 103 } -1 104 float dold = (getOld(i + 1) - getOld(i)); -1 105 if (dold <= 0) { -1 106 return 0; -1 107 } -1 108 return (getNew(i + 1) - getNew(i)) / dold; -1 109 } break; -1 110 default: { -1 111 // approxmiate ratio -1 112 float n = 100; // TODO automate this -1 113 -1 114 float o1 = o - 1 / n; -1 115 if (o1 < 0) { -1 116 o1 = 0; -1 117 } -1 118 if (o1 > 1) { -1 119 return 0; -1 120 } -1 121 -1 122 float o2 = o + 1 / n; -1 123 if (o2 < 0) { -1 124 return 0; -1 125 } -1 126 if (o2 > 1) { -1 127 o2 = 1; -1 128 } -1 129 if (o2 - o1 <= 0) { -1 130 return 0; -1 131 } -1 132 -1 133 return ((old2new(o2) - old2new(o1)) / (o2 - o1)); -1 134 } -1 135 } 99 136 } 100 137 -1 138 101 139 int Marker::getLength() {102 -1 return anew.getLength();-1 140 return anew.getLength(); 103 141 } 104 142 -1 143 105 144 int Marker::resort(int pi) {106 -1 if (!(pi>=0 && pi<getLength())) return -1;107 -1 // write anew and indices into arrays108 -1 float tnew[getLength()];109 -1 int ti[getLength()];110 -1 for (int i=0; i<getLength(); i++) {111 -1 tnew[i]=anew.get(i);112 -1 ti[i]=i;113 -1 }114 -1 // sort arrays115 -1 for (int j=0; j<getLength()-1; j++) {116 -1 for (int i=0; i<getLength()-1-j; i++) {117 -1 if (tnew[i]>tnew[i+1]) {118 -1 // swap119 -1 float ttf;120 -1 ttf=tnew[i];121 -1 tnew[i]=tnew[i+1];122 -1 tnew[i+1]=ttf;123 -1 int tti;124 -1 tti=ti[i];125 -1 ti[i]=ti[i+1];126 -1 ti[i+1]=tti;127 -1 }128 -1 }129 -1 }130 -1 return ti[pi];-1 145 if (!(pi >= 0 && pi < getLength())) { -1 146 return -1; -1 147 } -1 148 // write anew and indices into arrays -1 149 float tnew[getLength()]; -1 150 int ti[getLength()]; -1 151 for (int i = 0; i < getLength(); i++) { -1 152 tnew[i] = anew.get(i); -1 153 ti[i] = i; -1 154 } -1 155 // sort arrays -1 156 for (int j = 0; j < getLength() - 1; j++) { -1 157 for (int i = 0; i < getLength() - 1 - j; i++) { -1 158 if (tnew[i] > tnew[i + 1]) { -1 159 // swap -1 160 float ttf; -1 161 ttf = tnew[i]; -1 162 tnew[i] = tnew[i + 1]; -1 163 tnew[i + 1] = ttf; -1 164 int tti; -1 165 tti = ti[i]; -1 166 ti[i] = ti[i + 1]; -1 167 ti[i + 1] = tti; -1 168 } -1 169 } -1 170 } -1 171 return ti[pi]; 131 172 } 132 173 -1 174 133 175 float Marker::old2new(float o) {134 -1 // this one does all the interpolation!135 -1 // for performance reasons you should also hard code the interpolation modes to getRatio(float) and new2old136 -1 switch (getInterpolationMode()) {137 -1 // case 0: // linear is default138 -1 case 1: { // polynominal spline139 -1 return int_poly(this, o);140 -1 } break;141 -1 default: {142 -1 int i=getAreaOld(o);143 -1 if (i<0 || i+1>getLength()-1) return 0;144 -1 // linear interpolation145 -1 // n - n_i o - o_i146 -1 // -------------- = --------------147 -1 // n_{i+1} - n_i o_{i+1} - o_i148 -1 return (o-getOld(i))/(getOld(i+1)-getOld(i))*(getNew(i+1)-getNew(i))+getNew(i);149 -1 }150 -1 }-1 176 // this one does all the interpolation! -1 177 // for performance reasons you should also hard code the interpolation modes -1 178 // to getRatio(float) and new2old -1 179 switch (getInterpolationMode()) { -1 180 // case 0: // linear is default -1 181 case 1: { // polynominal spline -1 182 return int_poly(this, o); -1 183 } break; -1 184 default: { -1 185 int i = getAreaOld(o); -1 186 if (i < 0 || i + 1 > getLength() - 1) { -1 187 return 0; -1 188 } -1 189 // linear interpolation -1 190 // n - n_i o - o_i -1 191 // ------------- = ------------- -1 192 // n_{i+1} - n_i o_{i+1} - o_i -1 193 float ret = (o - getOld(i)) / (getOld(i + 1) - getOld(i)); -1 194 ret *= getNew(i + 1) - getNew(i); -1 195 ret += getNew(i); -1 196 return ret; -1 197 } -1 198 } 151 199 } 152 200 -1 201 153 202 float Marker::new2old(float n) {154 -1 // inverse of old2new155 -1 // hardcode the derivate to improve performance156 -1 switch (getInterpolationMode()) {157 -1 // linear158 -1 case 0: {159 -1 int i=getAreaNew(n);160 -1 if (i<0 || i+1>getLength()-1) return 0;161 -1 return (n-getNew(i))/(getNew(i+1)-getNew(i))*(getOld(i+1)-getOld(i))+getOld(i);162 -1 } break;163 -1 default: {164 -1 // TODO165 -1 // approximate o;166 -1 float o=n;167 -1 for (int i=1; i<10; ++i) {168 -1 o+=(n-old2new(o))/i;169 -1 }170 -1 return o;171 -1 }172 -1 }-1 203 // inverse of old2new -1 204 // hardcode the derivate to improve performance -1 205 switch (getInterpolationMode()) { -1 206 // linear -1 207 case 0: { -1 208 int i = getAreaNew(n); -1 209 if (i < 0 || i + 1 > getLength() - 1) { -1 210 return 0; -1 211 } -1 212 float ret = (n - getNew(i)) / (getNew(i + 1) - getNew(i)); -1 213 ret *= getOld(i + 1) - getOld(i); -1 214 ret += getOld(i); -1 215 return ret; -1 216 } break; -1 217 default: { -1 218 // TODO -1 219 // approximate o; -1 220 float o = n; -1 221 for (int i = 1; i < 10; ++i) { -1 222 o += (n - old2new(o)) / i; -1 223 } -1 224 return o; -1 225 } -1 226 } 173 227 } 174 228 -1 229 175 230 float Marker::new2nnew(float n) {176 -1 return (n-getNew(0))/(getNew(getLength()-1)-getNew(0));-1 231 return (n - getNew(0)) / (getNew(getLength() - 1) - getNew(0)); 177 232 } 178 233 -1 234 179 235 float Marker::nnew2new(float nn) {180 -1 return nn*(getNew(getLength()-1)-getNew(0))+getNew(0);-1 236 return nn * (getNew(getLength() -1 ) - getNew(0)) + getNew(0); 181 237 } 182 238 -1 239 183 240 int Marker::getAreaNew(float n) {184 -1 // TODO n=getNew(i)185 -1 for (int i=0; i<getLength(); ++i)186 -1 if (n<getNew(i)) return i-1;187 -1 return getLength()-1;-1 241 // TODO n = getNew(i) -1 242 for (int i = 0; i < getLength(); ++i) { -1 243 if (n < getNew(i)) { -1 244 return i - 1; -1 245 } -1 246 } -1 247 return getLength() - 1; 188 248 } 189 249 -1 250 190 251 int Marker::getAreaOld(float o) {191 -1 // TODO n=getNew(i)192 -1 for (int i=0; i<getLength(); ++i)193 -1 if (o<getOld(i)) return i-1;194 -1 return getLength()-1;-1 252 // TODO n = getNew(i) -1 253 for (int i = 0; i < getLength(); ++i) { -1 254 if (o < getOld(i)) { -1 255 return i - 1; -1 256 } -1 257 } -1 258 return getLength() - 1; 195 259 } 196 260 -1 261 197 262 void Marker::print() {198 -1 std::cout << "Marker" << std::endl;199 -1 for (int i=0; i<getLength(); ++i) {200 -1 std::cout << i << " ";201 -1 std::cout << getOld(i) << " ";202 -1 std::cout << getNew(i) << std::endl;203 -1 }-1 263 std::cout << "Marker" << std::endl; -1 264 for (int i = 0; i < getLength(); ++i) { -1 265 std::cout << i << " "; -1 266 std::cout << getOld(i) << " "; -1 267 std::cout << getNew(i) << std::endl; -1 268 } 204 269 }205 -1206 -1
diff --git a/src/marker.h b/src/marker.h
@@ -5,61 +5,58 @@ 5 5 #include "xiarray.h" 6 6 7 7 /*8 -1 marker works with float values9 -1 it mapps old values (o) from 0 (start) to 1 (end) to any new float values (n)10 -1 nnew values (nn) are normalized new values11 -1 most classes apart from marker use nnew values. Never forget to convert them!12 -1 */-1 8 * marker works with float values -1 9 * it mapps old values (o) from 0 (start) to 1 (end) to any new float values (n) -1 10 * nnew values (nn) are normalized new values -1 11 * most classes apart from marker use nnew values. Never forget to convert them! -1 12 */ -1 13 13 14 /*14 -1 For different modes of interpolation you have to edit 3 functions:15 -1 old2new16 -1 new2old - inverse of old2new17 -1 getRatio - derivate of old2new18 -1 */-1 15 * For different modes of interpolation you have to edit 3 functions: -1 16 * old2new -1 17 * new2old - inverse of old2new -1 18 * getRatio - derivate of old2new -1 19 */ 19 20 20 21 /*21 -1 interpolation modes:22 -1 0 - LINEAR23 -1 // TODO define constants24 -1 */-1 22 * interpolation modes: -1 23 * 0 - LINEAR -1 24 * // TODO define constants -1 25 */ 25 26 26 27 class Marker {27 -1 public:28 -1 Marker();29 -1 ~Marker();30 -1 void reset();31 -1 void add(float pold, float pnew);32 -1 void remove(int pi);33 -1 float getNew(int pi);34 -1 float getOld(int pi);35 -1 void setNew(int pi, float pnew);36 -1 int getLength();37 -1 void print();38 -1 // 0-1 conversion39 -1 float old2new(float o);40 -1 float new2old(float n);41 -1 float new2nnew(float n);42 -1 float nnew2new(float n);43 -1 int getAreaNew(float n);44 -1 int getAreaOld(float o);45 -1 float getLengthf(); // factor by wich the length is changed;46 -1 float getRatio(float o); // factor by wich is stretched on this place;47 -1 int getInterpolationMode();48 -1 void setInterpolationMode(int m);49 -1 bool _update; // used by interpolation modes to determine if data has to be updated50 -1 private:51 -1 xiArray anew;52 -1 xiArray aold;53 -1 int resort(int pi);54 -1 int interpolationMode;55 -1 };-1 28 public: -1 29 Marker(); -1 30 ~Marker(); -1 31 void reset(); -1 32 void add(float pold, float pnew); -1 33 void remove(int pi); -1 34 float getNew(int pi); -1 35 float getOld(int pi); -1 36 void setNew(int pi, float pnew); -1 37 int getLength(); -1 38 void print(); 56 3957 -1 /*58 -1 int main() {59 -1 Marker m;60 -1 m.add(0.5,0.4);61 -1 std::cout << m.getNew(1) << std::endl;62 -1 }63 -1 */-1 40 // 0-1 conversion -1 41 float old2new(float o); -1 42 float new2old(float n); -1 43 float new2nnew(float n); -1 44 float nnew2new(float n); -1 45 -1 46 int getAreaNew(float n); -1 47 int getAreaOld(float o); -1 48 float getLengthf(); // factor by which the length is changed; -1 49 float getRatio(float o); // factor by which is stretched on this place; -1 50 int getInterpolationMode(); -1 51 void setInterpolationMode(int m); -1 52 // used by interpolation modes to determine if data has to be updated -1 53 bool _update; -1 54 -1 55 private: -1 56 xiArray anew; -1 57 xiArray aold; -1 58 int resort(int pi); -1 59 int interpolationMode; -1 60 }; 64 61 65 62 #endif
diff --git a/src/rbprocess.h b/src/rbprocess.h
@@ -9,67 +9,70 @@ 9 9 #include <map> 10 10 11 11 /*12 -1 this is called by sample.process()13 -1 this uses the rubberband library14 -1 */-1 12 * this is called by sample.process() -1 13 * this uses the rubberband library -1 14 */ 15 15 16 16 int RBprocess(int olength, float* data, Marker* marker, Sample* sample, int n=1) { 17 1718 -1 int length=sample->getLength();19 -1 int ostart=int(marker->getOld(0)*olength);20 -1 if (ostart<0) ostart=0;21 -1 int olength2=int(marker->getOld(marker->getLength()-1)*olength)-ostart;22 -1 if (olength2>olength-ostart) olength2=olength-ostart;23 -124 -1 float **ibuf = new float *[1];25 -1 ibuf[0]=new float[olength2];26 -1 for (int i=0; i<olength2; ++i) {27 -1 ibuf[0][i]=sample->getOld((ostart+i)/(float)olength);28 -1 }29 -130 -1 float **obuf = new float *[1];31 -1 obuf[0]=data;32 -133 -1 RubberBand::RubberBandStretcher ts(44100, 1, 0, 1);34 -1 // map35 -1 std::map<unsigned int, unsigned int> fmap;36 -1 for (int i=0; i<length; i+=1024) {37 -1 float old= marker->nnew2new(marker->new2old(i/(float)length));38 -1 fmap[int(old*olength)-ostart]=int(i);39 -1 }40 -1 ts.setKeyFrameMap(fmap);41 -142 -1 sample->setFinished(0.03);43 -1 ts.study(ibuf, olength2, true);44 -1 ts.setMaxProcessSize(olength2);45 -1 int a1=-1;46 -1 int a2=0;47 -1 sample->setFinished(0.06);48 -1 ts.process(ibuf, olength2, true);49 -1 sample->setFinished(0.9);50 -151 -1 int avail=ts.available();52 -1 if (avail>length) avail=length;53 -1 ts.retrieve(obuf, avail);54 -155 -1 for (int j=0; j<avail; ++j) {56 -1 float value = obuf[0][j];57 -1 if (value > 1.f) value = 1.f;58 -1 if (value < -1.f) value = -1.f;59 -1 data[j] = value;60 -1 }61 -162 -1 for (int i=avail; i<length; ++i) {63 -1 data[i]=0;64 -1 }65 -166 -1 delete[] ibuf[0];67 -1 delete[] ibuf;68 -1 delete[] obuf;69 -170 -1 return 0;-1 18 int length = sample->getLength(); -1 19 int ostart = int(marker->getOld(0) * olength); -1 20 if (ostart < 0) { -1 21 ostart = 0; -1 22 } -1 23 int olength2 = int(marker->getOld(marker->getLength() - 1) * olength) - ostart; -1 24 if (olength2 > olength - ostart) { -1 25 olength2 = olength - ostart; -1 26 } -1 27 -1 28 float **ibuf = new float *[1]; -1 29 ibuf[0] = new float[olength2]; -1 30 for (int i = 0; i < olength2; ++i) { -1 31 ibuf[0][i] = sample->getOld((ostart + i) / (float)olength); -1 32 } -1 33 -1 34 float **obuf = new float *[1]; -1 35 obuf[0] = data; -1 36 -1 37 RubberBand::RubberBandStretcher ts(44100, 1, 0, 1); -1 38 // map -1 39 std::map<unsigned int, unsigned int> fmap; -1 40 for (int i = 0; i < length; i += 1024) { -1 41 float old = marker->nnew2new(marker->new2old(i / (float)length)); -1 42 fmap[int(old * olength) - ostart] = int(i); -1 43 } -1 44 ts.setKeyFrameMap(fmap); -1 45 -1 46 sample->setFinished(0.03); -1 47 ts.study(ibuf, olength2, true); -1 48 ts.setMaxProcessSize(olength2); -1 49 int a1 = -1; -1 50 int a2 = 0; -1 51 sample->setFinished(0.06); -1 52 ts.process(ibuf, olength2, true); -1 53 sample->setFinished(0.9); -1 54 -1 55 int avail=ts.available(); -1 56 if (avail>length) avail=length; -1 57 ts.retrieve(obuf, avail); -1 58 -1 59 for (int j = 0; j < avail; ++j) { -1 60 float value = obuf[0][j]; -1 61 if (value > 1.f) value = 1.f; -1 62 if (value < -1.f) value = -1.f; -1 63 data[j] = value; -1 64 } -1 65 -1 66 for (int i = avail; i < length; ++i) { -1 67 data[i]=0; -1 68 } -1 69 -1 70 delete[] ibuf[0]; -1 71 delete[] ibuf; -1 72 delete[] obuf; -1 73 -1 74 return 0; 71 75 } 72 76 73 77 #endif74 -175 78 #endif
diff --git a/src/sample.cpp b/src/sample.cpp
@@ -1,157 +1,206 @@ 1 1 #include "sample.h" 2 2 #include "rbprocess.h" 3 3 -1 4 4 5 Sample::Sample(Marker* m) {5 -1 marker=m;6 -1 length=0;7 -1 data=new float[0];8 -1 olength=0;9 -1 odata=new float[0];10 -1 stretchMode=0;11 -1 _processing=false;12 -1 _finished=0;-1 6 marker = m; -1 7 length = 0; -1 8 data = new float[0]; -1 9 olength = 0; -1 10 odata = new float[0]; -1 11 stretchMode = 0; -1 12 _processing = false; -1 13 _finished = 0; 13 14 } 14 15 -1 16 15 17 Sample::~Sample() {16 -1 delete[] data;-1 18 delete[] data; 17 19 } 18 20 -1 21 19 22 int Sample::getLength() {20 -1 return length;-1 23 return length; 21 24 } 22 25 -1 26 23 27 int Sample::getGuessedLength() {24 -1 return int(olength*marker->getLengthf());-1 28 return int(olength * marker->getLengthf()); 25 29 } 26 30 -1 31 27 32 float Sample::get(float nn) {28 -1 if (_processing) return 0;29 -1 int i=int(length*nn);30 -1 if (i<0 || i>=length) return 0;31 -1 return data[i];-1 33 if (_processing) { -1 34 return 0; -1 35 } -1 36 int i = int(length * nn); -1 37 if (i < 0 || i >= length) { -1 38 return 0; -1 39 } -1 40 return data[i]; 32 41 } 33 42 -1 43 34 44 float Sample::getOld(float o) {35 -1 int i=int((olength-1)*o);36 -1 if (i<0 || i>=olength) return 0;37 -1 return odata[i];-1 45 int i = int((olength - 1) * o); -1 46 if (i < 0 || i >= olength) { -1 47 return 0; -1 48 } -1 49 return odata[i]; -1 50 } -1 51 -1 52 -1 53 int Sample::getStretchMode() { -1 54 return stretchMode; 38 55 } 39 5640 -1 int Sample::getStretchMode() {return stretchMode;}41 57 42 58 void Sample::setStretchMode(int m) {43 -1 if (_processing) return;44 -1 stretchMode=m;-1 59 if (!_processing) { -1 60 stretchMode = m; -1 61 } 45 62 } 46 63 -1 64 47 65 int Sample::loadFile(const char* fileName) {48 -1 // TODO madliub/mp3 support49 -1 if (_processing) return 1;50 -1 SNDFILE *sndfile=NULL;51 -1 sfinfo;52 -1 // open file53 -1 sndfile = sf_open(fileName, SFM_READ, &sfinfo);54 -1 if (!sndfile) {55 -1 std::cerr << "ERROR: Failed to open input file \"" << fileName << "\": "56 -1 << sf_strerror(sndfile) << std::endl;57 -1 return 1;58 -1 }59 -1 // setup data60 -1 olength=sfinfo.frames; // expected length61 -1 delete[] odata;62 -1 odata=new float[olength];63 -164 -1 // read file into data65 -1 float ptr[10240*sfinfo.channels];66 -1 int count2=0;67 -1 while (true) {68 -1 int count = sf_readf_float(sndfile, ptr, 10240);69 -1 if (count <= 0) break;70 -1 // save ptr in data71 -1 for (int i=0; i<count*sfinfo.channels; i+=sfinfo.channels) {72 -1 odata[count2]=0;73 -1 for (int j=0; j<sfinfo.channels; ++j)74 -1 odata[count2]+=ptr[i+j];75 -1 odata[count2]/=sfinfo.channels;76 -1 count2++;77 -1 }78 -1 }79 -1 sf_close(sndfile);80 -1 olength=count2; // exact length81 -1 // fill data82 -1 return process();-1 66 // TODO madlib/mp3 support -1 67 if (_processing) { -1 68 return 1; -1 69 } -1 70 SNDFILE *sndfile = NULL; -1 71 sfinfo; -1 72 -1 73 // open file -1 74 sndfile = sf_open(fileName, SFM_READ, &sfinfo); -1 75 if (!sndfile) { -1 76 std::cerr << "ERROR: Failed to open input file \"" << fileName << "\": " -1 77 << sf_strerror(sndfile) << std::endl; -1 78 return 1; -1 79 } -1 80 -1 81 // setup data -1 82 olength = sfinfo.frames; // expected length -1 83 delete[] odata; -1 84 odata = new float[olength]; -1 85 -1 86 // read file into data -1 87 float ptr[10240 * sfinfo.channels]; -1 88 int count2 = 0; -1 89 while (true) { -1 90 int count = sf_readf_float(sndfile, ptr, 10240); -1 91 if (count <= 0) { -1 92 break; -1 93 } -1 94 -1 95 // save ptr in data -1 96 for (int i = 0; i < count * sfinfo.channels; i += sfinfo.channels) { -1 97 odata[count2] = 0; -1 98 for (int j = 0; j < sfinfo.channels; ++j) { -1 99 odata[count2] += ptr[i + j]; -1 100 } -1 101 odata[count2] /= sfinfo.channels; -1 102 count2++; -1 103 } -1 104 } -1 105 sf_close(sndfile); -1 106 olength = count2; // exact length -1 107 -1 108 // fill data -1 109 return process(); 83 110 } 84 111 -1 112 85 113 int Sample::writeFile(const char* fileNameOut) {86 -1 if (_processing) return 1;87 -1 if (length<=0) {88 -1 std::cerr << "ERROR: Load a file first" << std::endl;89 -1 return 1;90 -1 }91 -1 SNDFILE *sndfileOut;92 -1 SF_INFO sfinfoOut;93 -1 // open file94 -1 sfinfoOut.channels = 1;95 -1 sfinfoOut.format = sfinfo.format;96 -1 sfinfoOut.samplerate = sfinfo.samplerate;97 -1 sfinfoOut.sections = sfinfo.sections;98 -1 sfinfoOut.seekable = sfinfo.seekable;99 -1100 -1 sndfileOut = sf_open(fileNameOut, SFM_WRITE, &sfinfoOut) ;101 -1 if (!sndfileOut) {102 -1 std::cerr << "ERROR: Failed to open output file \"" << fileNameOut << "\" for writing: "103 -1 << sf_strerror(sndfileOut) << std::endl;104 -1 return 1;105 -1 }106 -1 sf_write_float(sndfileOut, data, length);107 -1 sf_close(sndfileOut);-1 114 if (_processing) { -1 115 return 1; -1 116 } -1 117 if (length <= 0) { -1 118 std::cerr << "ERROR: Load a file first" << std::endl; -1 119 return 1; -1 120 } -1 121 SNDFILE *sndfileOut; -1 122 SF_INFO sfinfoOut; -1 123 -1 124 // open file -1 125 sfinfoOut.channels = 1; -1 126 sfinfoOut.format = sfinfo.format; -1 127 sfinfoOut.samplerate = sfinfo.samplerate; -1 128 sfinfoOut.sections = sfinfo.sections; -1 129 sfinfoOut.seekable = sfinfo.seekable; -1 130 -1 131 sndfileOut = sf_open(fileNameOut, SFM_WRITE, &sfinfoOut); -1 132 if (!sndfileOut) { -1 133 std::cerr << "ERROR: Failed to open output file \"" << fileNameOut -1 134 << "\" for writing: " << sf_strerror(sndfileOut) << std::endl; -1 135 return 1; -1 136 } -1 137 sf_write_float(sndfileOut, data, length); -1 138 sf_close(sndfileOut); 108 139 } 109 140 -1 141 110 142 int Sample::process() {111 -1 // process_bg();112 -1 if (_processing) return 1;113 -1 setFinished(0);114 -1 pthread_t thread;115 -1 pthread_create(&thread, NULL, Sample::EntryPoint, (void*)this);116 -1 // process_bg();117 -1 return 0;-1 143 // process_bg(); -1 144 if (_processing) { -1 145 return 1; -1 146 } -1 147 setFinished(0); -1 148 pthread_t thread; -1 149 pthread_create(&thread, NULL, Sample::EntryPoint, (void*)this); -1 150 // process_bg(); -1 151 return 0; 118 152 } 119 153 -1 154 120 155 void* Sample::EntryPoint(void* pthis) 121 156 {122 -1 Sample* pt = (Sample*)pthis;123 -1 int error=pt->process_bg();124 -1 pthread_exit((void*)error);-1 157 Sample* pt = (Sample*)pthis; -1 158 int error = pt->process_bg(); -1 159 pthread_exit((void*)error); 125 160 } 126 161 -1 162 127 163 int Sample::process_bg() {128 -1 /*129 -1 This function does the main thing: it stretches the original data as defined by the marker object.130 -1 Therefore it reads data from odata and writes to data.131 -1 */132 -1 _processing=true;133 -1 // setup data134 -1 length=getGuessedLength();135 -1 delete[] data;136 -1 data=new float[length];137 -1 switch (getStretchMode()) {-1 164 /* -1 165 * This function does the main thing: it stretches the original data as -1 166 * defined by the marker object. Therefore it reads data from odata and -1 167 * writes to data. -1 168 */ -1 169 _processing = true; -1 170 -1 171 // setup data -1 172 length = getGuessedLength(); -1 173 delete[] data; -1 174 data = new float[length]; -1 175 -1 176 switch (getStretchMode()) { 138 177 #ifdef MODE_RUBBERBAND139 -1 case 1: RBprocess(olength, data, marker, this); break;-1 178 case 1: RBprocess(olength, data, marker, this); break; 140 179 #endif141 -1 default: {142 -1 for (int i=0; i<length; ++i) {143 -1 data[i]=getOld(marker->new2old(marker->nnew2new(i/(float)length)));144 -1 setFinished(i/(float)length);145 -1 }146 -1 }147 -1 }148 -1 setFinished(1);149 -1 _processing=false;150 -1 return 0;-1 180 default: { -1 181 for (int i = 0; i < length; ++i) { -1 182 data[i] = getOld(marker->new2old(marker->nnew2new(i / (float)length))); -1 183 setFinished(i / (float)length); -1 184 } -1 185 } -1 186 } -1 187 -1 188 setFinished(1); -1 189 _processing = false; -1 190 return 0; -1 191 } -1 192 -1 193 -1 194 bool Sample::getProcessing() { -1 195 return _processing; 151 196 } 152 197153 -1 bool Sample::getProcessing() {return _processing;}154 198155 -1 void Sample::setFinished(float f) {_finished=f;}156 -1 float Sample::getFinished() {return _finished;}-1 199 void Sample::setFinished(float f) { -1 200 _finished = f; -1 201 } 157 202 -1 203 -1 204 float Sample::getFinished() { -1 205 return _finished; -1 206 }
diff --git a/src/sample.h b/src/sample.h
@@ -7,54 +7,41 @@ 7 7 #include "marker.h" 8 8 9 9 /*10 -1 Stretchmodes11 -1 0 - none (plain sample copy)12 -1 1 - rubberband13 -1 // TODO define constants14 -1 */-1 10 * Stretchmodes -1 11 * 0 - none (plain sample copy) -1 12 * 1 - rubberband -1 13 * // TODO define constants -1 14 */ 15 15 16 16 class Sample {17 -1 public:18 -1 Sample(Marker* m);19 -1 ~Sample();20 -1 float get(float nn); // nnew21 -1 float getOld(float o);22 -1 int getLength();23 -1 int getGuessedLength();24 -1 int loadFile(const char* filename);25 -1 int writeFile(const char* filename);26 -1 int process(); // implements the main functionality27 -1 SF_INFO sfinfo;28 -1 int getStretchMode();29 -1 void setStretchMode(int m);30 -1 bool getProcessing();31 -1 float getFinished();32 -1 void setFinished(float f);33 -1 private:34 -1 float *data;35 -1 int length;36 -1 Marker* marker;37 -1 int olength;38 -1 float *odata;39 -1 int stretchMode;40 -1 static void * EntryPoint(void*);41 -1 int process_bg();42 -1 bool _processing;43 -1 float _finished;44 -1 };-1 17 public: -1 18 Sample(Marker* m); -1 19 ~Sample(); -1 20 float get(float nn); // nnew -1 21 float getOld(float o); -1 22 int getLength(); -1 23 int getGuessedLength(); -1 24 int loadFile(const char* filename); -1 25 int writeFile(const char* filename); -1 26 int process(); // implements the main functionality -1 27 SF_INFO sfinfo; -1 28 int getStretchMode(); -1 29 void setStretchMode(int m); -1 30 bool getProcessing(); -1 31 float getFinished(); -1 32 void setFinished(float f); 45 3346 -1 /*47 -1 int main() {48 -1 Marker* m=new Marker();49 -1 Sample s(m);50 -1 m->add(0.5,0.3);51 -1 int error;52 -1 error=s.loadFile("../../test.wav");53 -1 while (s.getProcessing()) {54 -1 std::cout << int(s.getFinished()*100) << "%" << std::endl;55 -1 }56 -1 error=s.writeFile("testo.wav");57 -1 }58 -1 */-1 34 private: -1 35 float *data; -1 36 int length; -1 37 Marker* marker; -1 38 int olength; -1 39 float *odata; -1 40 int stretchMode; -1 41 static void * EntryPoint(void*); -1 42 int process_bg(); -1 43 bool _processing; -1 44 float _finished; -1 45 }; 59 46 60 47 #endif
diff --git a/src/xiarray.cpp b/src/xiarray.cpp
@@ -1,71 +1,89 @@ 1 1 #include "xiarray.h" 2 2 -1 3 3 4 xiArray::xiArray() {4 -1 _length=0;5 -1 array=new float[getLength()];-1 5 _length = 0; -1 6 array = new float[getLength()]; 6 7 } 7 8 -1 9 8 10 xiArray::~xiArray() {9 -1 delete[] array;-1 11 delete[] array; 10 12 } 11 13 -1 14 12 15 float xiArray::get(int i) {13 -1 if (i>=0 && i<getLength())14 -1 return array[i];15 -1 else16 -1 return NULL;-1 16 if (i >= 0 && i < getLength()) { -1 17 return array[i]; -1 18 } else { -1 19 return NULL; -1 20 } 17 21 } 18 22 -1 23 19 24 void xiArray::set(int i, float v) {20 -1 if (i>=0 && i<=getLength()) array[i]=v;-1 25 if (i >= 0 && i <= getLength()) { -1 26 array[i] = v; -1 27 } 21 28 } 22 2923 -1 void xiArray::insert(int i,float v) {24 -1 if (i>=0 && i<=getLength()) {25 -1 float* tmpArray=new float[getLength()+1];26 -1 for (int ii=0; ii<i; ii++)27 -1 tmpArray[ii]=array[ii];28 -1 tmpArray[i]=v;29 -1 for (int ii=i; ii<getLength(); ii++)30 -1 tmpArray[ii+1]=array[ii];31 -1 delete[] array;32 -1 array=tmpArray;33 -1 _length++;34 -1 }-1 30 -1 31 void xiArray::insert(int i, float v) { -1 32 if (i >= 0 && i <= getLength()) { -1 33 float* tmpArray = new float[getLength() + 1]; -1 34 for (int ii = 0; ii < i; ii++) { -1 35 tmpArray[ii] = array[ii]; -1 36 } -1 37 tmpArray[i] = v; -1 38 for (int ii = i; ii < getLength(); ii++) { -1 39 tmpArray[ii+1] = array[ii]; -1 40 } -1 41 delete[] array; -1 42 array = tmpArray; -1 43 _length++; -1 44 } 35 45 } 36 46 -1 47 37 48 void xiArray::add(float v) {38 -1 insert(getLength(),v);-1 49 insert(getLength(), v); 39 50 } 40 51 -1 52 41 53 void xiArray::remove(int i) {42 -1 if (i>=0 && i<getLength()) {43 -1 float* tmpArray=new float[getLength()-1];44 -1 for (int ii=0; ii<i; ii++)45 -1 tmpArray[ii]=array[ii];46 -1 for (int ii=i+1; ii<getLength(); ii++)47 -1 tmpArray[ii-1]=array[ii];48 -1 delete[] array;49 -1 array=tmpArray;50 -1 _length--;51 -1 }-1 54 if (i >= 0 && i < getLength()) { -1 55 float* tmpArray = new float[getLength() - 1]; -1 56 for (int ii = 0; ii < i; ii++) { -1 57 tmpArray[ii] = array[ii]; -1 58 } -1 59 for (int ii = i+1; ii < getLength(); ii++) { -1 60 tmpArray[ii-1] = array[ii]; -1 61 } -1 62 delete[] array; -1 63 array = tmpArray; -1 64 _length--; -1 65 } 52 66 } 53 67 -1 68 54 69 int xiArray::getLength() {55 -1 return _length;-1 70 return _length; 56 71 } 57 72 -1 73 58 74 void xiArray::print() {59 -1 std::cout << "[";60 -1 for (int i=0; i<getLength()-1; i++)61 -1 std::cout << get(i) << " ";62 -1 if (getLength() > 0)63 -1 std::cout << get(getLength()-1);64 -1 std::cout << "]";-1 75 std::cout << "["; -1 76 for (int i = 0; i < getLength() - 1; i++) { -1 77 std::cout << get(i) << " "; -1 78 } -1 79 if (getLength() > 0) { -1 80 std::cout << get(getLength() - 1); -1 81 } -1 82 std::cout << "]"; 65 83 } 66 84 -1 85 67 86 void xiArray::println() {68 -1 print();69 -1 std::cout << std::endl;-1 87 print(); -1 88 std::cout << std::endl; 70 89 }71 -1
diff --git a/src/xiarray.h b/src/xiarray.h
@@ -4,35 +4,27 @@ 4 4 #include <iostream> 5 5 6 6 /*7 -1 This is like the first c++ class I wrote and was more like making an easy start. If anybody wants to eliminate this from the project and replace it with vectors or something lika that, just do as you want.-1 7 This is like the first c++ class I wrote and was more like making an easy -1 8 start. If anybody wants to eliminate this from the project and replace it with -1 9 vectors or something like that, just do as you want. 8 10 */ 9 11 10 12 class xiArray {11 -1 public:12 -1 xiArray();13 -1 ~xiArray();14 -1 float get(int i);15 -1 void set(int i, float v);16 -1 void add(float v);17 -1 void insert(int i,float v);18 -1 void remove(int i);19 -1 int getLength();20 -1 void print();21 -1 void println();22 -1 private:23 -1 float* array;24 -1 int _length;25 -1 };-1 13 public: -1 14 xiArray(); -1 15 ~xiArray(); -1 16 float get(int i); -1 17 void set(int i, float v); -1 18 void add(float v); -1 19 void insert(int i,float v); -1 20 void remove(int i); -1 21 int getLength(); -1 22 void print(); -1 23 void println(); 26 2427 -1 /*28 -1 int main() {29 -1 Buffer b;30 -1 b.insert(0,17);31 -1 b.insert(0,13);32 -1 b.insert(1,9);33 -1 b.remove(1);34 -1 b.println();35 -1 }36 -1 */-1 25 private: -1 26 float* array; -1 27 int _length; -1 28 }; 37 29 38 30 #endif