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

« back to all changes in this revision

Viewing changes to src/effects/Normalize.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:
25
25
#include <math.h>
26
26
 
27
27
#include "Normalize.h"
 
28
#include "../ShuttleGui.h"
28
29
#include "../Internat.h"
29
30
#include "../WaveTrack.h"
30
31
#include "../Prefs.h"
60
61
   return true;
61
62
}
62
63
 
 
64
wxString EffectNormalize::GetEffectDescription() // useful only after parameter values have been set
 
65
 
66
   // Note: This is useful only after ratio has been set. 
 
67
   wxString strResult =
 
68
      /* i18n-hint: First %s is the effect name, 2nd and 3rd are either true or
 
69
       * false (translated below) if those options were selected */
 
70
      wxString::Format(_("Applied effect: %s remove dc offset = %s, normalize amplitude = %s"), 
 
71
                        this->GetEffectName().c_str(), 
 
72
                        /* i18n-hint: true here means that the option was
 
73
                         * selected. Opposite false if not selected */
 
74
                        mDC ? _("true") : _("false"), 
 
75
                        mGain ? _("true") : _("false"));
 
76
   if (mGain)
 
77
      strResult += wxString::Format(_(", maximum amplitude = %.1f dB"), -mLevel); 
 
78
 
 
79
   return strResult;
 
80
 
81
 
63
82
bool EffectNormalize::TransferParameters( Shuttle & shuttle )
64
83
{
65
84
   shuttle.TransferBool( wxT("ApplyGain"), mGain, true );
120
139
      return true;
121
140
 
122
141
   //Iterate over each track
123
 
   TrackListIterator iter(mWaveTracks);
124
 
   WaveTrack *track = (WaveTrack *) iter.First();
 
142
   this->CopyInputWaveTracks(); // Set up m_pOutputWaveTracks.
 
143
   bool bGoodResult = true;
 
144
 
 
145
   TrackListIterator iter(m_pOutputWaveTracks);
 
146
    WaveTrack *track = (WaveTrack *) iter.First();
125
147
   mCurTrackNum = 0;
126
148
   while (track) {
127
149
      //Get start and end times from track
146
168
 
147
169
         //ProcessOne() (implemented below) processes a single track
148
170
         if (!ProcessOne(track, start, end))
149
 
            return false;
 
171
         {
 
172
            bGoodResult = false;
 
173
            break;
 
174
         }
150
175
      }
151
176
      
152
177
      //Iterate to the next track
154
179
      mCurTrackNum++;
155
180
   }
156
181
 
157
 
   return true;
 
182
   this->ReplaceProcessedWaveTracks(bGoodResult); 
 
183
   return bGoodResult;
158
184
}
159
185
 
160
186
//ProcessOne() takes a track, transforms it to bunch of buffer-blocks,
289
315
// NormalizeDialog
290
316
//----------------------------------------------------------------------------
291
317
 
292
 
#define ID_BUTTON_PREVIEW 10001
293
318
#define ID_NORMALIZE_AMPLITUDE 10002
294
319
#define ID_LEVEL_STATIC_MINUS 10003
295
320
#define ID_LEVEL_STATIC_DB 10004
298
323
BEGIN_EVENT_TABLE(NormalizeDialog,wxDialog)
299
324
   EVT_BUTTON( wxID_OK, NormalizeDialog::OnOk )
300
325
   EVT_BUTTON( wxID_CANCEL, NormalizeDialog::OnCancel )
301
 
        EVT_BUTTON(ID_BUTTON_PREVIEW, NormalizeDialog::OnPreview)
 
326
        EVT_BUTTON(ID_EFFECT_PREVIEW, NormalizeDialog::OnPreview)
302
327
        EVT_CHECKBOX(ID_NORMALIZE_AMPLITUDE, NormalizeDialog::OnUpdateUI)
303
328
END_EVENT_TABLE()
304
329
 
313
338
   wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
314
339
 
315
340
   mainSizer->Add(new wxStaticText(this, -1,
316
 
                                   _("Normalize by Dominic Mazzoni\n"
 
341
                                   _("Normalize by Dominic Mazzoni"
317
342
                                                                                                ),
318
343
                                   wxDefaultPosition, wxDefaultSize,
319
344
                                   wxALIGN_CENTRE),
343
368
                   wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxALL, 5);
344
369
   mainSizer->Add(levelSizer, 0, wxALIGN_LEFT|wxALIGN_TOP|wxALL, 0);
345
370
 
346
 
   wxBoxSizer *hSizer = new wxBoxSizer(wxHORIZONTAL);
347
 
 
348
 
   wxButton * pButton_Preview = 
349
 
                new wxButton(this, ID_BUTTON_PREVIEW, mEffect->GetPreviewName());
350
 
   hSizer->Add(pButton_Preview, 0, wxALIGN_CENTER | wxALL, 5);
351
 
   hSizer->Add(20, 10); // horizontal spacer
352
 
 
353
 
   wxButton *cancel = new wxButton(this, wxID_CANCEL, _("&Cancel"));
354
 
   hSizer->Add(cancel, 0, wxALIGN_CENTRE|wxALL, 5);
355
 
 
356
 
   wxButton *ok = new wxButton(this, wxID_OK, _("&OK"));
357
 
   ok->SetDefault();
358
 
   hSizer->Add(ok, 0, wxALIGN_CENTRE|wxALL, 5);
359
 
 
360
 
   mainSizer->Add(hSizer, 0, wxALIGN_CENTRE|wxALIGN_CENTER_VERTICAL|wxALL, 5);
 
371
   // Preview, OK, & Cancel buttons
 
372
   mainSizer->Add(CreateStdButtonSizer(this, ePreviewButton|eCancelButton|eOkButton), 0, wxEXPAND);
361
373
 
362
374
   SetAutoLayout(true);
363
375
   SetSizer(mainSizer);