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

« back to all changes in this revision

Viewing changes to src/effects/Compressor.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:
41
41
#include <wx/dcmemory.h>
42
42
 
43
43
#include "Compressor.h"
 
44
#include "../ShuttleGui.h"
44
45
#include "../WaveTrack.h"
45
46
#include "../widgets/Ruler.h"
46
47
#include "../AColor.h"
63
64
   shuttle.TransferDouble( wxT("Threshold"), mThresholdDB, -12.0f );
64
65
   shuttle.TransferDouble( wxT("Ratio"), mRatio, 2.0f );
65
66
   shuttle.TransferDouble( wxT("AttackTime"), mAttackTime, 0.2f );
 
67
   shuttle.TransferDouble( wxT("DecayTime"), mDecayTime, 0.2f );
66
68
   shuttle.TransferBool( wxT("Normalize"), mNormalize, true );
67
69
   return true;
68
70
}
73
75
   dlog.threshold = mThresholdDB;
74
76
   dlog.ratio = mRatio;
75
77
   dlog.attack = mAttackTime;
 
78
   dlog.decay = mDecayTime;
76
79
   dlog.useGain = mNormalize;
77
80
   dlog.TransferDataToWindow();
78
81
 
85
88
   mThresholdDB = dlog.threshold;
86
89
   mRatio = dlog.ratio;
87
90
   mAttackTime = dlog.attack;
 
91
   mDecayTime = dlog.decay;
88
92
   mNormalize = dlog.useGain;
89
93
 
90
94
   return true;
441
445
   ThresholdID = 7100,
442
446
   RatioID,
443
447
   AttackID,
444
 
   PreviewID
 
448
   DecayID
445
449
};
446
450
 
447
451
BEGIN_EVENT_TABLE(CompressorDialog,wxDialog)
448
452
   EVT_BUTTON( wxID_OK, CompressorDialog::OnOk )
449
453
   EVT_BUTTON( wxID_CANCEL, CompressorDialog::OnCancel )
450
 
   EVT_BUTTON( PreviewID, CompressorDialog::OnPreview )
 
454
   EVT_BUTTON( ID_EFFECT_PREVIEW, CompressorDialog::OnPreview )
451
455
   EVT_SIZE( CompressorDialog::OnSize )
452
456
   EVT_SLIDER( ThresholdID, CompressorDialog::OnSlider )
453
457
   EVT_SLIDER( RatioID, CompressorDialog::OnSlider )
454
458
   EVT_SLIDER( AttackID, CompressorDialog::OnSlider )
 
459
   EVT_SLIDER( DecayID, CompressorDialog::OnSlider )
455
460
END_EVENT_TABLE()
456
461
 
457
462
CompressorDialog::CompressorDialog(EffectCompressor *effect,
497
502
                                wxDefaultPosition, wxSize(200, -1), wxSL_HORIZONTAL);
498
503
   gridSizer->Add(mAttackSlider, 1, wxEXPAND|wxALL, 5);
499
504
 
 
505
   mDecayText = new wxStaticText(this, -1, wxString(_("Decay Time: ")) + wxT("XXXX secs"));
 
506
   gridSizer->Add(mDecayText, 0, wxALIGN_LEFT|wxALL, 5);
 
507
 
 
508
   mDecaySlider = new wxSlider(this, DecayID, 2, 1, 10,
 
509
                                wxDefaultPosition, wxSize(200, -1), wxSL_HORIZONTAL);
 
510
   gridSizer->Add(mDecaySlider, 1, wxEXPAND|wxALL, 5);
 
511
 
500
512
   mainSizer->Add(gridSizer, 0, wxALIGN_CENTRE|wxALIGN_CENTER_VERTICAL|wxALL, 5);
501
513
 
502
514
   wxBoxSizer *hSizer = new wxBoxSizer(wxHORIZONTAL);
507
519
 
508
520
   mainSizer->Add(hSizer, 0, wxALIGN_CENTRE|wxALIGN_CENTER_VERTICAL|wxALL, 5);
509
521
 
510
 
   hSizer = new wxBoxSizer(wxHORIZONTAL);
511
 
 
512
 
   wxButton *preview = new wxButton(this, PreviewID, mEffect->GetPreviewName());
513
 
   hSizer->Add(preview, 0, wxALIGN_CENTRE|wxALL, 5);
514
 
   hSizer->Add(40, 10);
515
 
 
516
 
   wxButton *cancel = new wxButton(this, wxID_CANCEL, _("&Cancel"));
517
 
   hSizer->Add(cancel, 0, wxALIGN_CENTRE|wxALL, 5);
518
 
 
519
 
   wxButton *ok = new wxButton(this, wxID_OK, _("&OK"));
520
 
   ok->SetDefault();
521
 
   hSizer->Add(ok, 0, wxALIGN_CENTRE|wxALL, 5);
522
 
 
523
 
   mainSizer->Add(hSizer, 0, wxALIGN_CENTRE|wxALIGN_CENTER_VERTICAL|wxALL, 5);
 
522
   // Preview, OK, & Cancel buttons
 
523
   mainSizer->Add(CreateStdButtonSizer(this, ePreviewButton|eCancelButton|eOkButton), 0, wxEXPAND);
524
524
 
525
525
   SetAutoLayout(true);
526
526
   SetSizer(mainSizer);
539
539
   mThresholdSlider->SetValue((int)rint(threshold));
540
540
   mRatioSlider->SetValue((int)rint(ratio*2));
541
541
   mAttackSlider->SetValue((int)rint(attack*10));
 
542
   mDecaySlider->SetValue((int)rint(attack));
542
543
   mGainCheckBox->SetValue(useGain);
543
544
 
544
545
   TransferDataFromWindow();
551
552
   threshold = (double)mThresholdSlider->GetValue();
552
553
   ratio = (double)(mRatioSlider->GetValue() / 2.0);
553
554
   attack = (double)(mAttackSlider->GetValue() / 10.0);
 
555
   decay = (double)(mDecaySlider->GetValue());
554
556
   useGain = mGainCheckBox->GetValue();
555
557
 
556
558
   mPanel->threshold = threshold;
565
567
 
566
568
   mAttackText->SetLabel(wxString::Format(_("Attack Time: %.1f secs"), attack));
567
569
 
 
570
   mDecayText->SetLabel(wxString::Format(_("Decay Time: %.1f secs"), decay));
 
571
 
568
572
   mPanel->Refresh(false);
569
573
 
570
574
   return true;
589
593
 
590
594
        // Save & restore parameters around Preview, because we didn't do OK.
591
595
   double    oldAttackTime = mEffect->mAttackTime;
 
596
   double    oldDecayTime = mEffect->mDecayTime;
592
597
   double    oldThresholdDB = mEffect->mThresholdDB;
593
598
   double    oldRatio = mEffect->mRatio;
594
599
   bool      oldUseGain = mEffect->mNormalize;
595
600
 
596
601
   mEffect->mAttackTime = attack;
 
602
   mEffect->mDecayTime = decay;
597
603
   mEffect->mThresholdDB = threshold;
598
604
   mEffect->mRatio = ratio;
599
605
   mEffect->mNormalize = useGain;
601
607
   mEffect->Preview();
602
608
 
603
609
   mEffect->mAttackTime = oldAttackTime;
 
610
   mEffect->mDecayTime = oldDecayTime;
604
611
   mEffect->mThresholdDB = oldThresholdDB;
605
612
   mEffect->mRatio = oldRatio;
606
613
   mEffect->mNormalize = oldUseGain;