xiRetimer

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

commit
44f585ecc4802de858ca48722c3fc155948065a9
parent
4333a8ae6297269bd79f3a097702d845e0d93b3d
Author
Tobias Bengfort <tobias.bengfort@gmx.net>
Date
2010-11-05 22:27
error messages

Diffstat

M src/gui/xiRTMainFrame.cpp 24 +++++++++++++++++++-----
M src/gui/xiRTMainFrame.h 4 ++++
M src/sample.cpp 10 ++++++----
M xiRetimer 0

4 files changed, 29 insertions, 9 deletions


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

@@ -91,10 +91,13 @@ void xiRTMainFrame::OnOpenClick( wxCommandEvent& event )
   91    91 
   92    92   if (dialog->ShowModal()==wxID_OK) {
   93    93     wxString filename=dialog->GetPath();
   94    -1     sample->loadFile(filename.mb_str());
   -1    94     if (sample->loadFile(filename.mb_str())!=0)
   -1    95       reportError( _T("Could not read from that file"));
   95    96     process();
   96    97     _updateWaveform=true;
   97    98   }
   -1    99   else
   -1   100     reportError( _T("Please choose a valid file!"));
   98   101 }
   99   102 
  100   103 void xiRTMainFrame::OnExportClick( wxCommandEvent& event )
@@ -104,9 +107,13 @@ void xiRTMainFrame::OnExportClick( wxCommandEvent& event )
  104   107 
  105   108     if (dialog->ShowModal()==wxID_OK) {
  106   109       wxString filename=dialog->GetPath();
  107    -1       sample->process();
  108    -1       sample->writeFile(filename.mb_str());
   -1   110       process();
   -1   111       if (sample->writeFile(filename.mb_str())!=0) {
   -1   112         reportError(_T("Could not write to File"));
   -1   113       }
  109   114     }
   -1   115     else
   -1   116       reportError(_T("Could not write to File"));
  110   117 }
  111   118 
  112   119 // ************  playback  **************
@@ -131,7 +138,7 @@ void xiRTMainFrame::OnPrefsClick( wxCommandEvent& event )
  131   138 
  132   139 void xiRTMainFrame::OnExitClick( wxCommandEvent& event )
  133   140 {
  134    -1   Destroy();
   -1   141   Close();
  135   142 }
  136   143 
  137   144 void xiRTMainFrame::OnHelpClick( wxCommandEvent& event )
@@ -163,7 +170,10 @@ void xiRTMainFrame::OnSize( wxSizeEvent& event ) {
  163   170 
  164   171 // ***********************************
  165   172 void xiRTMainFrame::process() {
  166    -1     sample->process();
   -1   173     // sometings wrong here
   -1   174     if (sample->process()!=0)
   -1   175 //      reportError(_T("Could not process data!"));
   -1   176       {}
  167   177 
  168   178     wxProgressDialog::wxProgressDialog* dialog = new wxProgressDialog( _T("processing..."), _T("please wait") );
  169   179     dialog ->Show();
@@ -222,4 +232,8 @@ void xiRTMainFrame::paint() {
  222   232   }
  223   233 }
  224   234 
   -1   235 void xiRTMainFrame::reportError(wxString string) {
   -1   236   wxMessageDialog::wxMessageDialog* dialog = new wxMessageDialog( this, string, _T("Error"), wxOK | wxICON_ERROR );
   -1   237   dialog ->ShowModal();
   -1   238 }
  225   239 

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

@@ -13,11 +13,14 @@ Subclass of MainFrame, which is generated by wxFormBuilder.
   13    13 #include "../curve.h"
   14    14 
   15    15 #include <wx/progdlg.h>
   -1    16 #include <wx/msgdlg.h>
   16    17 #include <wx/dcclient.h>
   17    18 #include <wx/dcbuffer.h>
   18    19 #include <wx/string.h>
   19    20 #include <wx/filedlg.h>
   20    21 
   -1    22 #include <iostream>
   -1    23 
   21    24 /** Implementing MainFrame */
   22    25 class xiRTMainFrame : public MainFrame
   23    26 {
@@ -48,6 +51,7 @@ protected:
   48    51   void paint();
   49    52   void process();
   50    53   bool _updateWaveform;
   -1    54   void reportError(wxString string);
   51    55   static const int MARKERWIDTH=15;
   52    56   static const int BEAT=15;
   53    57   

diff --git a/src/sample.cpp b/src/sample.cpp

@@ -48,7 +48,7 @@ void Sample::setStretchMode(int m) {
   48    48 int Sample::loadFile(const char* fileName) {
   49    49 // TODO multi filetype support
   50    50   if (_processing) return 1;
   51    -1   SNDFILE *sndfile;
   -1    51   SNDFILE *sndfile=NULL;
   52    52   sfinfo;
   53    53   // open file
   54    54   sndfile = sf_open(fileName, SFM_READ, &sfinfo);
@@ -69,16 +69,18 @@ int Sample::loadFile(const char* fileName) {
   69    69     int count = sf_readf_float(sndfile, ptr, 10240);
   70    70     if (count <= 0) break;
   71    71     // save ptr in data
   72    -1     // TODO downmix (maybe several options, maybe multichannel support)
   73    72     for (int i=0; i<count*sfinfo.channels; i+=sfinfo.channels) {
   74    -1       odata[count2]=ptr[i];
   -1    73       odata[count2]=0;
   -1    74       for (int j=0; j<sfinfo.channels; ++j)
   -1    75         odata[count2]+=ptr[i+j];
   -1    76       odata[count2]/=sfinfo.channels;
   75    77       count2++;
   76    78     }
   77    79   }
   78    80   sf_close(sndfile);
   79    81   olength=count2; // exact length
   80    82   // fill data 
   81    -1   process();
   -1    83   return process();
   82    84 }
   83    85 
   84    86 int Sample::writeFile(const char* fileNameOut) {  

diff --git a/xiRetimer b/xiRetimer

Binary files differ.