~ubuntu-branches/ubuntu/gutsy/audacity/gutsy-backports

« back to all changes in this revision

Viewing changes to src/effects/nyquist/Nyquist.cpp

  • Committer: Bazaar Package Importer
  • Author(s): John Dong
  • Date: 2008-02-18 21:58:19 UTC
  • mfrom: (13.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080218215819-tmbcf1rx238r8gdv
Tags: 1.3.4-1.1ubuntu1~gutsy1
Automated backport upload; no source changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
#include "../../AudacityApp.h"
53
53
#include "../../LabelTrack.h"
54
54
#include "../../Internat.h"
 
55
#include "../../ShuttleGui.h"
55
56
 
56
57
#include "Nyquist.h"
57
58
 
109
110
      return ((WaveTrack *)iter.First())->GetRate();
110
111
   }
111
112
   else {
112
 
      double d;
113
 
      s.ToDouble(&d);
114
 
      return d;
 
113
      return Internat::CompatibleToDouble(s);
115
114
   }
116
115
}
117
116
 
328
327
      if (result == wxID_CANCEL)
329
328
         return false;
330
329
 
331
 
      if (result == wxID_MORE)
 
330
      if (result == eDebugID)
332
331
         mDebug = true;
333
332
      else
334
333
         mDebug = false;
383
382
   if (result == wxID_CANCEL)
384
383
      return false;
385
384
   
386
 
   if (result == wxID_MORE)
 
385
   if (result == eDebugID)
387
386
      mDebug = true;
388
387
   else
389
388
      mDebug = false;
395
394
{
396
395
   bool success = true;
397
396
   
398
 
   TrackListIterator iter(mWaveTracks);
 
397
   this->CopyInputWaveTracks(); // Set up m_pOutputWaveTracks.
 
398
   TrackListIterator iter(m_pOutputWaveTracks);
399
399
   mCurTrack[0] = (WaveTrack *) iter.First();
400
400
   mOutputTime = mT1 - mT0;
401
401
   mCount = 0;
412
412
               wxMessageBox(_("Sorry, cannot apply effect on stereo tracks where the tracks don't match."), 
413
413
                            wxT("Nyquist"),
414
414
                            wxOK | wxCENTRE, mParent);
415
 
               return false;
 
415
               success = false;
 
416
               goto finish;
416
417
            }
417
418
            mCurStart[1] = mCurTrack[1]->TimeToLongSamples(mT0);
418
419
         }
443
444
      dlog.ShowModal();
444
445
   }
445
446
 
 
447
   this->ReplaceProcessedWaveTracks(success); 
446
448
   return success;
447
449
}
448
450
 
715
717
BEGIN_EVENT_TABLE(NyquistDialog, wxDialog)
716
718
   EVT_BUTTON(wxID_OK, NyquistDialog::OnOk)
717
719
   EVT_BUTTON(wxID_CANCEL, NyquistDialog::OnCancel)
718
 
   EVT_BUTTON(wxID_MORE, NyquistDialog::OnDebug)
 
720
   EVT_BUTTON(eDebugID, NyquistDialog::OnDebug)
719
721
   EVT_COMMAND_RANGE(ID_NYQ_SLIDER, ID_NYQ_SLIDER+99,
720
722
                     wxEVT_COMMAND_SLIDER_UPDATED, NyquistDialog::OnSlider)
721
723
   EVT_COMMAND_RANGE(ID_NYQ_TEXT, ID_NYQ_TEXT+99,
734
736
   mInHandler = true; // prevents race condition on MSW
735
737
 
736
738
   wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
737
 
   wxBoxSizer *hSizer;
738
 
   wxButton   *button;
739
739
 
740
740
   if (info.Length() > 0) {
741
741
      wxControl  *item;
809
809
                   wxALIGN_CENTER_VERTICAL | wxALL, 5);
810
810
      }
811
811
         
812
 
      if( ctrl->type != NYQ_CTRL_CHOICE )
 
812
      if( ctrl->type == NYQ_CTRL_CHOICE )
 
813
      {
 
814
         grid->Add( 10, 10 );
 
815
      }
 
816
      else
813
817
      {
814
818
         item = new wxStaticText(this, -1, ctrl->label);
815
819
         grid->Add(item, 0, wxALIGN_LEFT | 
818
822
   }
819
823
   mainSizer->Add(grid, 0, wxALIGN_CENTRE | wxALL, 5);
820
824
 
821
 
   hSizer = new wxBoxSizer(wxHORIZONTAL);
822
 
 
823
 
   button = new wxButton(this, wxID_CANCEL, _("&Cancel"));
824
 
   hSizer->Add(button, 0, wxALIGN_CENTRE | wxALL, 5);
825
 
 
826
 
   button = new wxButton(this, wxID_MORE, _("&Debug"));
827
 
   hSizer->Add(button, 0, wxALIGN_CENTRE | wxALL, 5);
828
 
 
829
 
   button = new wxButton(this, wxID_OK, _("&OK"));
830
 
   button->SetDefault();
831
 
   hSizer->Add(button, 0, wxALIGN_CENTRE | wxALL, 5);
832
 
 
833
 
   mainSizer->Add(hSizer, 0, wxALIGN_CENTRE | wxALL, 5);
 
825
   mainSizer->Add(CreateStdButtonSizer(this, eDebugButton|eCancelButton|eOkButton), 0, wxEXPAND);
834
826
 
835
827
   mInHandler = false;
836
828
 
866
858
      wxString valStr;
867
859
      if (ctrl->type == NYQ_CTRL_REAL) {
868
860
         if (ctrl->high - ctrl->low < 1)
869
 
            valStr.Printf(wxT("%.3f"), ctrl->val);
 
861
            valStr = Internat::ToDisplayString(ctrl->val, 3);
870
862
         else if (ctrl->high - ctrl->low < 10)
871
 
            valStr.Printf(wxT("%.2f"), ctrl->val);
 
863
            valStr = Internat::ToDisplayString(ctrl->val, 2);
872
864
         else if (ctrl->high - ctrl->low < 100)
873
 
            valStr.Printf(wxT("%.1f"), ctrl->val);
 
865
            valStr = Internat::ToDisplayString(ctrl->val, 1);
874
866
         else
875
867
            valStr.Printf(wxT("%d"), (int)floor(ctrl->val + 0.5));
876
868
      }
922
914
      wxSlider *slider = (wxSlider *)FindWindow(ID_NYQ_SLIDER + ctrlId);
923
915
      wxASSERT(slider);
924
916
 
925
 
      ctrl->valStr.ToDouble(&ctrl->val);
926
 
      int pos = (int)floor((ctrl->val - ctrl->low) /
927
 
                           (ctrl->high - ctrl->low) * ctrl->ticks + 0.5);
928
 
      if (pos < 0)
929
 
         pos = 0;
930
 
      if (pos > ctrl->ticks)
931
 
         pos = ctrl->ticks;
932
 
      slider->SetValue(pos);
 
917
      if (ctrl->valStr.ToDouble(&ctrl->val))
 
918
      {
 
919
         int pos = (int)floor((ctrl->val - ctrl->low) /
 
920
                              (ctrl->high - ctrl->low) * ctrl->ticks + 0.5);
 
921
         if (pos < 0)
 
922
            pos = 0;
 
923
         if (pos > ctrl->ticks)
 
924
            pos = ctrl->ticks;
 
925
         slider->SetValue(pos);
 
926
      }
933
927
   }   
934
928
 
935
929
   mInHandler = false;   
951
945
{
952
946
   // Transfer data
953
947
 
954
 
   EndModal(wxID_MORE);
 
948
   EndModal(eDebugID);
955
949
}
956
950
 
957
951
/**********************************************************/
959
953
BEGIN_EVENT_TABLE(NyquistInputDialog, wxDialog)
960
954
   EVT_BUTTON(wxID_OK, NyquistInputDialog::OnOk)
961
955
   EVT_BUTTON(wxID_CANCEL, NyquistInputDialog::OnCancel)
962
 
   EVT_BUTTON(wxID_MORE, NyquistInputDialog::OnDebug)
 
956
   EVT_BUTTON(eDebugID, NyquistInputDialog::OnDebug)
963
957
END_EVENT_TABLE()
964
958
 
965
959
NyquistInputDialog::NyquistInputDialog(wxWindow * parent, wxWindowID id,
969
963
   :wxDialog(parent, id, title)
970
964
{
971
965
   wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
972
 
   wxBoxSizer *hSizer;
973
 
   wxButton   *button;
974
966
   wxControl  *item;
975
967
 
976
968
   item = new wxStaticText(this, -1, prompt);
982
974
                                 wxTE_MULTILINE);
983
975
   mainSizer->Add(mCommandText, 0, wxALIGN_LEFT | wxALL, 10);
984
976
 
985
 
   hSizer = new wxBoxSizer(wxHORIZONTAL);
986
 
 
987
 
   button = new wxButton(this, wxID_CANCEL, _("&Cancel"));
988
 
   hSizer->Add(button, 0, wxALIGN_CENTRE | wxALL, 5);
989
 
 
990
 
   button = new wxButton(this, wxID_MORE, _("&Debug"));
991
 
   hSizer->Add(button, 0, wxALIGN_CENTRE | wxALL, 5);
992
 
 
993
 
   button = new wxButton(this, wxID_OK, _("OK"));
994
 
   hSizer->Add(button, 0, wxALIGN_CENTRE | wxALL, 5);
995
 
 
996
 
   mainSizer->Add(hSizer, 0, wxALIGN_CENTRE |
997
 
                  wxLEFT | wxBOTTOM | wxRIGHT, 5);
 
977
   // Debug, OK, & Cancel buttons
 
978
   mainSizer->Add(CreateStdButtonSizer(this, eDebugButton|eCancelButton|eOkButton), 0, wxEXPAND);
998
979
 
999
980
   SetAutoLayout(true);
1000
981
   SetSizer(mainSizer);
1023
1004
{
1024
1005
   // Transfer data
1025
1006
 
1026
 
   EndModal(wxID_MORE);
 
1007
   EndModal(eDebugID);
1027
1008
}
1028
1009
 
1029
1010