1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-04-30 15:49:41 +02:00

Resolves reported bugs and (most) recommendations

All:

Export/Import now disabled if the Effect (family) doesn't support it
Options disabled if the Effect (family) doesn't support it
Standarized on "Latency compensation" instead of "Buffer delay compensation"
Correct loading/saving of factory default settings
Fixed "Mannage" to be "Manage"
Removed conditional code since we're keeping the transport buttons
Play bases state on actual playback status
Play no longer monkeys with selection
Play will now start from where it left off IF:
   The user stops the playback via the Effect Stop button
   If the user wants to restart from the beginning of the selection
   then the user can click Rewind while stopped.
Rewind will not go past start of selection (sorry Steve ;-))
   If Rewind is clicked while not playing, playback will next
   start at beginning of selection.
Fast Forward will stop at end of selection
   However, if FFwd is clicked while not playing, it will
   put playback at the end of selection and the next time
   the user clicks the Effect play button, playback will
   continue from the end of selection to the end of track.
Deleting a preset now prompts user to confirm
Button faces should now look a little better
Bypass (should we rename that???) button now grays when disabled

Audio Units:

Corrected all user visible "AudioUnit" strings to be "Audio Unit"
Removed unneeded "Buffer Size" in settings dialog
Only uses latency if user said it was okay

Ladspa:

Added settings dialog to allow control of latency usage
Removed unused "user selectable" buffer size
Only use latency if user wants it
Refresh controls when presets are loaded

VST:

Removed unused "Rescan at startup" setting
Propogate parameter loads to slave effects
This commit is contained in:
lllucius@gmail.com 2014-12-04 06:10:27 +00:00
parent dd766fd153
commit cddff18025
10 changed files with 430 additions and 319 deletions

View File

@ -405,6 +405,28 @@ static const char * effect_ffwd_xpm[] = {
" MN MN ", " MN MN ",
" "}; " "};
/* XPM */
static const char * effect_off_disabled_xpm[] = {
"16 16 2 1",
" c None",
". c #7f7f7f",
" ",
" .. ",
" . .. . ",
" .. .. .. ",
" ... .. ... ",
" .... .. .... ",
" ... .. ... ",
" ... .. ... ",
" ... .. ... ",
" ... ... ",
" ... ... ",
" ... ... ",
" .... .... ",
" ............ ",
" .......... ",
" ........ "};
/* XPM */ /* XPM */
static const char * effect_play_disabled_xpm[] = { static const char * effect_play_disabled_xpm[] = {
"16 16 48 1", "16 16 48 1",

View File

@ -165,13 +165,15 @@ public:
virtual void LoadUserPreset(const wxString & name) = 0; virtual void LoadUserPreset(const wxString & name) = 0;
virtual void SaveUserPreset(const wxString & name) = 0; virtual void SaveUserPreset(const wxString & name) = 0;
virtual wxArrayString GetFactoryPresets() = 0;
virtual void LoadFactoryPreset(int id) = 0; virtual void LoadFactoryPreset(int id) = 0;
virtual void LoadFactoryDefaults() = 0; virtual void LoadFactoryDefaults() = 0;
virtual wxArrayString GetFactoryPresets() = 0; virtual bool CanExport() = 0;
virtual void ExportPresets() = 0; virtual void ExportPresets() = 0;
virtual void ImportPresets() = 0; virtual void ImportPresets() = 0;
virtual bool HasOptions() = 0;
virtual void ShowOptions() = 0; virtual void ShowOptions() = 0;
}; };

View File

@ -39,6 +39,7 @@ greater use in future.
#include "../Prefs.h" #include "../Prefs.h"
#include "../Project.h" #include "../Project.h"
#include "../WaveTrack.h" #include "../WaveTrack.h"
#include "../toolbars/ControlToolBar.h"
#include "../widgets/AButton.h" #include "../widgets/AButton.h"
#include "../widgets/ProgressDialog.h" #include "../widgets/ProgressDialog.h"
#include "../ondemand/ODManager.h" #include "../ondemand/ODManager.h"
@ -1995,6 +1996,8 @@ public:
// //
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#include "../../images/Effect.h"
enum enum
{ {
kDummyID = 30000, kDummyID = 30000,
@ -2003,8 +2006,8 @@ enum
kExportID = 30003, kExportID = 30003,
kDefaultsID = 30004, kDefaultsID = 30004,
kOptionsID = 30005, kOptionsID = 30005,
kDeleteAllID = 30006, kUserPresetsDummyID = 30006,
#if defined(TRY_BUTTONS) kDeletePresetDummyID = 30007,
kMenuID = 30100, kMenuID = 30100,
kBypassID = 30101, kBypassID = 30101,
kPlayID = 30102, kPlayID = 30102,
@ -2012,7 +2015,6 @@ enum
kFFwdID = 30104, kFFwdID = 30104,
kPlaybackID = 30105, kPlaybackID = 30105,
kCaptureID = 30106, kCaptureID = 30106,
#endif
kUserPresetsID = 31000, kUserPresetsID = 31000,
kDeletePresetID = 32000, kDeletePresetID = 32000,
kFactoryPresetsID = 33000, kFactoryPresetsID = 33000,
@ -2022,21 +2024,16 @@ BEGIN_EVENT_TABLE(EffectUIHost, wxDialog)
EVT_CLOSE(EffectUIHost::OnClose) EVT_CLOSE(EffectUIHost::OnClose)
EVT_BUTTON(wxID_APPLY, EffectUIHost::OnApply) EVT_BUTTON(wxID_APPLY, EffectUIHost::OnApply)
EVT_BUTTON(wxID_CANCEL, EffectUIHost::OnCancel) EVT_BUTTON(wxID_CANCEL, EffectUIHost::OnCancel)
EVT_BUTTON(ePreviewID, EffectUIHost::OnPreview)
EVT_BUTTON(eSettingsID, EffectUIHost::OnSettings)
#if defined(TRY_BUTTONS)
EVT_BUTTON(kMenuID, EffectUIHost::OnMenu) EVT_BUTTON(kMenuID, EffectUIHost::OnMenu)
EVT_BUTTON(kBypassID, EffectUIHost::OnBypass) EVT_BUTTON(kBypassID, EffectUIHost::OnBypass)
EVT_BUTTON(kPlayID, EffectUIHost::OnPlay) EVT_BUTTON(kPlayID, EffectUIHost::OnPlay)
EVT_BUTTON(kRewindID, EffectUIHost::OnRewind) EVT_BUTTON(kRewindID, EffectUIHost::OnRewind)
EVT_BUTTON(kFFwdID, EffectUIHost::OnFFwd) EVT_BUTTON(kFFwdID, EffectUIHost::OnFFwd)
#endif
EVT_MENU(kSaveAsID, EffectUIHost::OnSaveAs) EVT_MENU(kSaveAsID, EffectUIHost::OnSaveAs)
EVT_MENU(kImportID, EffectUIHost::OnImport) EVT_MENU(kImportID, EffectUIHost::OnImport)
EVT_MENU(kExportID, EffectUIHost::OnExport) EVT_MENU(kExportID, EffectUIHost::OnExport)
EVT_MENU(kOptionsID, EffectUIHost::OnOptions) EVT_MENU(kOptionsID, EffectUIHost::OnOptions)
EVT_MENU(kDefaultsID, EffectUIHost::OnDefaults) EVT_MENU(kDefaultsID, EffectUIHost::OnDefaults)
EVT_MENU(kDeleteAllID, EffectUIHost::OnDeleteAllPresets)
EVT_MENU_RANGE(kUserPresetsID, kUserPresetsID + 999, EffectUIHost::OnUserPreset) EVT_MENU_RANGE(kUserPresetsID, kUserPresetsID + 999, EffectUIHost::OnUserPreset)
EVT_MENU_RANGE(kDeletePresetID, kDeletePresetID + 999, EffectUIHost::OnDeletePreset) EVT_MENU_RANGE(kDeletePresetID, kDeletePresetID + 999, EffectUIHost::OnDeletePreset)
EVT_MENU_RANGE(kFactoryPresetsID, kFactoryPresetsID + 999, EffectUIHost::OnFactoryPreset) EVT_MENU_RANGE(kFactoryPresetsID, kFactoryPresetsID + 999, EffectUIHost::OnFactoryPreset)
@ -2073,42 +2070,6 @@ EffectUIHost::~EffectUIHost()
} }
} }
#define TRY_BUTTONS 1
#if defined(TRY_BUTTONS)
#include "../../images/Effect.h"
wxBitmap EffectUIHost::CreateBitmap(const char *xpm[], bool up, bool pusher)
{
wxMemoryDC dc;
wxBitmap pic(xpm);
wxBitmap mod(pic.GetWidth() + 6, pic.GetHeight() + 6);
dc.SelectObject(mod);
#if defined( __WXGTK__ )
wxColour newColour = wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND );
#else
wxColour newColour = wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE );
#endif
dc.SetBackground(wxBrush(newColour));
dc.Clear();
int offset = 3;
if (pusher)
{
if (!up)
{
offset += 1;
}
}
dc.DrawBitmap(pic, offset, offset, true);
dc.SelectObject(wxNullBitmap);
return mod;
}
#endif
// ============================================================================ // ============================================================================
// EffectUIHost implementation // EffectUIHost implementation
// ============================================================================ // ============================================================================
@ -2126,7 +2087,6 @@ bool EffectUIHost::Initialize()
w->SetScrollRate(0, 20); w->SetScrollRate(0, 20);
#if defined(TRY_BUTTONS)
mPlaying = gAudioIO->IsStreamActive(); // not exactly right, but will suffice mPlaying = gAudioIO->IsStreamActive(); // not exactly right, but will suffice
mCapturing = gAudioIO->IsStreamActive() && gAudioIO->GetNumCaptureChannels() > 0; mCapturing = gAudioIO->IsStreamActive() && gAudioIO->GetNumCaptureChannels() > 0;
@ -2135,13 +2095,15 @@ bool EffectUIHost::Initialize()
bar->SetSizer(bs); bar->SetSizer(bs);
mMenuBtn = new wxBitmapButton(bar, kMenuID, CreateBitmap(effect_menu_xpm, true, false)); mMenuBtn = new wxBitmapButton(bar, kMenuID, CreateBitmap(effect_menu_xpm, true, false));
mMenuBtn->SetToolTip(_("Mannage effect")); mMenuBtn->SetToolTip(_("Manage effect"));
bs->Add(mMenuBtn); bs->Add(mMenuBtn);
mOnBM = CreateBitmap(effect_on_xpm, true, false); mOnBM = CreateBitmap(effect_on_xpm, true, false);
mOffBM = CreateBitmap(effect_off_xpm, true, false); mOffBM = CreateBitmap(effect_off_xpm, true, false);
mOffDisabledBM = CreateBitmap(effect_off_disabled_xpm, true, false);
mBypassBtn = new wxBitmapButton(bar, kBypassID, mOnBM); mBypassBtn = new wxBitmapButton(bar, kBypassID, mOnBM);
mBypassBtn->SetBitmapDisabled(mOffDisabledBM);
mBypassBtn->SetToolTip(_("Bypass effect")); mBypassBtn->SetToolTip(_("Bypass effect"));
mOnToggle = true; mOnToggle = true;
bs->Add(mBypassBtn); bs->Add(mBypassBtn);
@ -2155,7 +2117,6 @@ bool EffectUIHost::Initialize()
mPlayBtn = new wxBitmapButton(bar, kPlayID, mPlayBM); mPlayBtn = new wxBitmapButton(bar, kPlayID, mPlayBM);
mPlayBtn->SetBitmapDisabled(mPlayDisabledBM); mPlayBtn->SetBitmapDisabled(mPlayDisabledBM);
mPlayBtn->SetToolTip(_("Play/Stop")); mPlayBtn->SetToolTip(_("Play/Stop"));
mPlayToggle = true;
bs->Add(mPlayBtn); bs->Add(mPlayBtn);
mRewindBtn = new wxBitmapButton(bar, kRewindID, CreateBitmap(effect_rewind_xpm, true, true)); mRewindBtn = new wxBitmapButton(bar, kRewindID, CreateBitmap(effect_rewind_xpm, true, true));
@ -2190,10 +2151,6 @@ bool EffectUIHost::Initialize()
mCloseBtn = (wxButton *) FindWindowById(wxID_CANCEL); mCloseBtn = (wxButton *) FindWindowById(wxID_CANCEL);
UpdateControls(); UpdateControls();
#else
wxSizer *s = CreateStdButtonSizer(this, eSettingsButton | eApplyButton | eCloseButton);
#endif
hs->Add(w, 1, wxEXPAND); hs->Add(w, 1, wxEXPAND);
vs->Add(hs, 1, wxEXPAND); vs->Add(hs, 1, wxEXPAND);
@ -2227,7 +2184,6 @@ bool EffectUIHost::Initialize()
EffectManager::Get().RealtimeAddEffect(mEffect); EffectManager::Get().RealtimeAddEffect(mEffect);
#if defined(TRY_BUTTONS)
wxTheApp->Connect(EVT_AUDIOIO_PLAYBACK, wxTheApp->Connect(EVT_AUDIOIO_PLAYBACK,
wxCommandEventHandler(EffectUIHost::OnPlayback), wxCommandEventHandler(EffectUIHost::OnPlayback),
NULL, NULL,
@ -2237,7 +2193,6 @@ bool EffectUIHost::Initialize()
wxCommandEventHandler(EffectUIHost::OnCapture), wxCommandEventHandler(EffectUIHost::OnCapture),
NULL, NULL,
this); this);
#endif
mInitialized = true; mInitialized = true;
@ -2250,7 +2205,6 @@ void EffectUIHost::OnClose(wxCloseEvent & WXUNUSED(evt))
{ {
mInitialized = false; mInitialized = false;
#if defined(TRY_BUTTONS)
wxTheApp->Disconnect(EVT_AUDIOIO_PLAYBACK, wxTheApp->Disconnect(EVT_AUDIOIO_PLAYBACK,
wxCommandEventHandler(EffectUIHost::OnPlayback), wxCommandEventHandler(EffectUIHost::OnPlayback),
NULL, NULL,
@ -2260,7 +2214,6 @@ void EffectUIHost::OnClose(wxCloseEvent & WXUNUSED(evt))
wxCommandEventHandler(EffectUIHost::OnCapture), wxCommandEventHandler(EffectUIHost::OnCapture),
NULL, NULL,
this); this);
#endif
EffectManager::Get().RealtimeRemoveEffect(mEffect); EffectManager::Get().RealtimeRemoveEffect(mEffect);
mEffect->RealtimeFinalize(); mEffect->RealtimeFinalize();
@ -2283,15 +2236,26 @@ void EffectUIHost::OnApply(wxCommandEvent & WXUNUSED(evt))
mClient->SaveUserPreset(mEffect->GetCurrentSettingsGroup()); mClient->SaveUserPreset(mEffect->GetCurrentSettingsGroup());
if (mInitialized)
{
mInitialized = false;
EffectManager::Get().RealtimeRemoveEffect(mEffect);
mEffect->RealtimeFinalize();
}
if (IsModal()) if (IsModal())
{ {
if (mInitialized)
{
mInitialized = false;
wxTheApp->Disconnect(EVT_AUDIOIO_PLAYBACK,
wxCommandEventHandler(EffectUIHost::OnPlayback),
NULL,
this);
wxTheApp->Disconnect(EVT_AUDIOIO_CAPTURE,
wxCommandEventHandler(EffectUIHost::OnCapture),
NULL,
this);
EffectManager::Get().RealtimeRemoveEffect(mEffect);
mEffect->RealtimeFinalize();
}
SetReturnCode(true); SetReturnCode(true);
Close(); Close();
@ -2304,17 +2268,6 @@ void EffectUIHost::OnApply(wxCommandEvent & WXUNUSED(evt))
mEffect->Apply(); mEffect->Apply();
#if defined(CLOSE_ON_APPLY)
if (!mClient->HideUI())
{
return;
}
Hide();
Close();
#endif
return; return;
} }
@ -2324,7 +2277,6 @@ void EffectUIHost::OnCancel(wxCommandEvent & WXUNUSED(evt))
{ {
mInitialized = false; mInitialized = false;
#if defined(TRY_BUTTONS)
wxTheApp->Disconnect(EVT_AUDIOIO_PLAYBACK, wxTheApp->Disconnect(EVT_AUDIOIO_PLAYBACK,
wxCommandEventHandler(EffectUIHost::OnPlayback), wxCommandEventHandler(EffectUIHost::OnPlayback),
NULL, NULL,
@ -2334,7 +2286,6 @@ void EffectUIHost::OnCancel(wxCommandEvent & WXUNUSED(evt))
wxCommandEventHandler(EffectUIHost::OnCapture), wxCommandEventHandler(EffectUIHost::OnCapture),
NULL, NULL,
this); this);
#endif
EffectManager::Get().RealtimeRemoveEffect(mEffect); EffectManager::Get().RealtimeRemoveEffect(mEffect);
mEffect->RealtimeFinalize(); mEffect->RealtimeFinalize();
@ -2360,12 +2311,6 @@ void EffectUIHost::OnCancel(wxCommandEvent & WXUNUSED(evt))
return; return;
} }
void EffectUIHost::OnPreview(wxCommandEvent & WXUNUSED(evt))
{
mEffect->Preview();
}
#if defined(TRY_BUTTONS)
void EffectUIHost::OnMenu(wxCommandEvent & evt) void EffectUIHost::OnMenu(wxCommandEvent & evt)
{ {
wxBitmapButton *b = (wxBitmapButton *)evt.GetEventObject(); wxBitmapButton *b = (wxBitmapButton *)evt.GetEventObject();
@ -2375,12 +2320,19 @@ void EffectUIHost::OnMenu(wxCommandEvent & evt)
LoadUserPresets(); LoadUserPresets();
sub = new wxMenu(); if (mUserPresets.GetCount() == 0)
for (size_t i = 0, cnt = mUserPresets.GetCount(); i < cnt; i++)
{ {
sub->Append(kUserPresetsID + i, mUserPresets[i]); menu->Append(kUserPresetsDummyID, _("User Presets"))->Enable(false);
}
else
{
sub = new wxMenu();
for (size_t i = 0, cnt = mUserPresets.GetCount(); i < cnt; i++)
{
sub->Append(kUserPresetsID + i, mUserPresets[i]);
}
menu->Append(0, _("User Presets"), sub);
} }
menu->Append(0, _("User Presets"), sub);
wxArrayString factory = mClient->GetFactoryPresets(); wxArrayString factory = mClient->GetFactoryPresets();
@ -2402,20 +2354,27 @@ void EffectUIHost::OnMenu(wxCommandEvent & evt)
} }
menu->Append(0, _("Factory Presets"), sub); menu->Append(0, _("Factory Presets"), sub);
sub = new wxMenu(); if (mUserPresets.GetCount() == 0)
for (size_t i = 0, cnt = mUserPresets.GetCount(); i < cnt; i++)
{ {
sub->Append(kDeletePresetID + i, mUserPresets[i]); menu->Append(kDeletePresetDummyID, _("Delete Preset"))->Enable(false);
}
else
{
sub = new wxMenu();
for (size_t i = 0, cnt = mUserPresets.GetCount(); i < cnt; i++)
{
sub->Append(kDeletePresetID + i, mUserPresets[i]);
}
menu->Append(0, _("Delete Preset"), sub);
} }
menu->Append(0, _("Delete Preset"), sub);
menu->AppendSeparator(); menu->AppendSeparator();
menu->Append(kSaveAsID, _("Save As...")); menu->Append(kSaveAsID, _("Save As..."));
menu->AppendSeparator(); menu->AppendSeparator();
menu->Append(kImportID, _("Import...")); menu->Append(kImportID, _("Import..."))->Enable(mClient->CanExport());
menu->Append(kExportID, _("Export...")); menu->Append(kExportID, _("Export..."))->Enable(mClient->CanExport());
menu->AppendSeparator(); menu->AppendSeparator();
menu->Append(kOptionsID, _("Options...")); menu->Append(kOptionsID, _("Options..."))->Enable(mClient->HasOptions());
menu->AppendSeparator(); menu->AppendSeparator();
sub = new wxMenu(); sub = new wxMenu();
@ -2454,31 +2413,84 @@ void EffectUIHost::OnBypass(wxCommandEvent & WXUNUSED(evt))
void EffectUIHost::OnPlay(wxCommandEvent & WXUNUSED(evt)) void EffectUIHost::OnPlay(wxCommandEvent & WXUNUSED(evt))
{ {
if (mPlayToggle) AudacityProject *p = GetActiveProject();
if (mPlaying)
{ {
mPlayToggle = false; mPlayPos = gAudioIO->GetStreamTime();
GetActiveProject()->OnPlayStop(); p->GetControlToolBar()->StopPlaying();
} }
else else
{ {
mPlayToggle = true; if (p->mViewInfo.selectedRegion.t0() != mRegion.t0() ||
GetActiveProject()->OnPlayStop(); p->mViewInfo.selectedRegion.t1() != mRegion.t1())
{
mRegion = p->mViewInfo.selectedRegion;
mPlayPos = mRegion.t0();
}
if (mPlayPos > mRegion.t1())
{
mPlayPos = mRegion.t1();
}
p->GetControlToolBar()->PlayPlayRegion(mPlayPos, mRegion.t1());
} }
} }
void EffectUIHost::OnRewind(wxCommandEvent & WXUNUSED(evt)) void EffectUIHost::OnRewind(wxCommandEvent & WXUNUSED(evt))
{ {
GetActiveProject()->OnSeekLeftShort(); if (mPlaying)
{
double seek;
gPrefs->Read(wxT("/AudioIO/SeekShortPeriod"), &seek, 1.0);
double pos = gAudioIO->GetStreamTime();
if (pos - seek < mRegion.t0())
{
seek = pos - mRegion.t0();
}
gAudioIO->SeekStream(-seek);
}
else
{
mPlayPos = mRegion.t0();
}
} }
void EffectUIHost::OnFFwd(wxCommandEvent & WXUNUSED(evt)) void EffectUIHost::OnFFwd(wxCommandEvent & WXUNUSED(evt))
{ {
GetActiveProject()->OnSeekRightShort(); if (mPlaying)
{
double seek;
gPrefs->Read(wxT("/AudioIO/SeekShortPeriod"), &seek, 1.0);
double pos = gAudioIO->GetStreamTime();
if (mRegion.t0() < mRegion.t1() && pos + seek > mRegion.t1())
{
seek = mRegion.t1() - pos;
}
gAudioIO->SeekStream(seek);
}
else
{
// It allows to play past end of selection...probably useless
mPlayPos = mRegion.t1();
}
} }
void EffectUIHost::OnPlayback(wxCommandEvent & evt) void EffectUIHost::OnPlayback(wxCommandEvent & evt)
{ {
mPlaying = evt.GetInt() != 0; mPlaying = evt.GetInt() != 0;
if (mPlaying)
{
mRegion = GetActiveProject()->mViewInfo.selectedRegion;
mPlayPos = mRegion.t0();
}
UpdateControls(); UpdateControls();
} }
@ -2489,95 +2501,37 @@ void EffectUIHost::OnCapture(wxCommandEvent & evt)
UpdateControls(); UpdateControls();
} }
void EffectUIHost::UpdateControls() void EffectUIHost::OnUserPreset(wxCommandEvent & evt)
{ {
mApplyBtn->Enable(!mCapturing); int preset = evt.GetId() - kUserPresetsID;
mBypassBtn->Enable(!mCapturing);
mPlayBtn->Enable(!mCapturing);
mRewindBtn->Enable(!mCapturing);
mFFwdBtn->Enable(!mCapturing);
mOnToggle = !EffectManager::Get().RealtimeIsSuspended(); mClient->LoadUserPreset(mEffect->GetUserPresetsGroup(mUserPresets[preset]));
if (mOnToggle && mCapturing)
{
mOnToggle = false;
EffectManager::Get().RealtimeSuspend();
}
mPlayBtn->SetBitmapLabel(mPlaying ? mStopBM : mPlayBM); return;
mPlayBtn->SetBitmapDisabled(mPlaying ? mStopDisabledBM: mPlayDisabledBM);
mBypassBtn->SetBitmapLabel(mOnToggle ? mOnBM : mOffBM);
} }
#endif
void EffectUIHost::OnSettings(wxCommandEvent & evt) void EffectUIHost::OnFactoryPreset(wxCommandEvent & evt)
{ {
wxButton *b = (wxButton *)evt.GetEventObject(); mClient->LoadFactoryPreset(evt.GetId() - kFactoryPresetsID);
wxMenu *menu = new wxMenu(); return;
wxMenu *sub; }
void EffectUIHost::OnDeletePreset(wxCommandEvent & evt)
{
wxString preset = mUserPresets[evt.GetId() - kDeletePresetID];
int res = wxMessageBox(wxString::Format(_("Are you sure you want to delete \"%s\"?"), preset.c_str()),
_("Delete Preset"),
wxICON_QUESTION | wxYES_NO);
if (res == wxYES)
{
mEffect->RemovePrivateConfigSubgroup(mEffect->GetUserPresetsGroup(preset));
}
LoadUserPresets(); LoadUserPresets();
sub = new wxMenu(); return;
for (size_t i = 0, cnt = mUserPresets.GetCount(); i < cnt; i++)
{
sub->Append(kUserPresetsID + i, mUserPresets[i]);
}
menu->Append(0, _("User Presets"), sub);
wxArrayString factory = mClient->GetFactoryPresets();
sub = new wxMenu();
sub->Append(kDefaultsID, _("Defaults"));
if (factory.GetCount() > 0)
{
sub->AppendSeparator();
for (size_t i = 0, cnt = factory.GetCount(); i < cnt; i++)
{
wxString label = factory[i];
if (label.IsEmpty())
{
label = _("None");
}
sub->Append(kFactoryPresetsID + i, label);
}
}
menu->Append(0, _("Factory Presets"), sub);
sub = new wxMenu();
for (size_t i = 0, cnt = mUserPresets.GetCount(); i < cnt; i++)
{
sub->Append(kDeletePresetID + i, mUserPresets[i]);
}
menu->Append(0, _("Delete Preset"), sub);
menu->AppendSeparator();
menu->Append(kSaveAsID, _("Save As..."));
menu->AppendSeparator();
menu->Append(kImportID, _("Import..."));
menu->Append(kExportID, _("Export..."));
menu->AppendSeparator();
menu->Append(kOptionsID, _("Options..."));
menu->AppendSeparator();
sub = new wxMenu();
sub->Append(kDummyID, wxString::Format(_("Type: %s"), mEffect->GetFamily().c_str()));
sub->Append(kDummyID, wxString::Format(_("Name: %s"), mEffect->GetName().c_str()));
sub->Append(kDummyID, wxString::Format(_("Version: %s"), mEffect->GetVersion().c_str()));
sub->Append(kDummyID, wxString::Format(_("Vendor: %s"), mEffect->GetVendor().c_str()));
sub->Append(kDummyID, wxString::Format(_("Description: %s"), mEffect->GetDescription().c_str()));
// sub->Append(kDummyID, wxString::Format(_("Audio In: %d"), mEffect->GetAudioInCount()));
// sub->Append(kDummyID, wxString::Format(_("Audio Out: %d"), mEffect->GetAudioOutCount()));
menu->Append(0, _("About"), sub);
wxRect r = b->GetRect();
PopupMenu(menu, wxPoint(r.GetLeft(), r.GetBottom()));
delete menu;
} }
void EffectUIHost::OnSaveAs(wxCommandEvent & WXUNUSED(evt)) void EffectUIHost::OnSaveAs(wxCommandEvent & WXUNUSED(evt))
@ -2646,13 +2600,6 @@ void EffectUIHost::OnExport(wxCommandEvent & WXUNUSED(evt))
return; return;
} }
void EffectUIHost::OnDefaults(wxCommandEvent & WXUNUSED(evt))
{
mClient->LoadFactoryDefaults();
return;
}
void EffectUIHost::OnOptions(wxCommandEvent & WXUNUSED(evt)) void EffectUIHost::OnOptions(wxCommandEvent & WXUNUSED(evt))
{ {
mClient->ShowOptions(); mClient->ShowOptions();
@ -2660,43 +2607,67 @@ void EffectUIHost::OnOptions(wxCommandEvent & WXUNUSED(evt))
return; return;
} }
void EffectUIHost::OnUserPreset(wxCommandEvent & evt) void EffectUIHost::OnDefaults(wxCommandEvent & WXUNUSED(evt))
{ {
int preset = evt.GetId() - kUserPresetsID; mClient->LoadFactoryDefaults();
mClient->LoadUserPreset(mEffect->GetUserPresetsGroup(mUserPresets[preset]));
return; return;
} }
void EffectUIHost::OnFactoryPreset(wxCommandEvent & evt) wxBitmap EffectUIHost::CreateBitmap(const char *xpm[], bool up, bool pusher)
{ {
mClient->LoadFactoryPreset(evt.GetId() - kFactoryPresetsID); wxMemoryDC dc;
wxBitmap pic(xpm);
return; wxBitmap mod(pic.GetWidth() + 6, pic.GetHeight() + 6);
} dc.SelectObject(mod);
void EffectUIHost::OnDeletePreset(wxCommandEvent & evt) #if !defined(__WXMAC__)
{
mEffect->RemovePrivateConfigSubgroup(mEffect->GetUserPresetsGroup(mUserPresets[evt.GetId() - kDeletePresetID]));
LoadUserPresets(); #if defined(__WXGTK__)
wxColour newColour = wxSystemSettings::GetColour(wxSYS_COLOUR_BACKGROUND);
#elif defined(__WXMSW__)
wxColour newColour = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
#endif
return; dc.SetBackground(wxBrush(newColour));
} dc.Clear();
#endif
void EffectUIHost::OnDeleteAllPresets(wxCommandEvent & WXUNUSED(evt)) int offset = 3;
{ if (pusher)
int res = wxMessageBox(_("This will delete all of your user presets. Are you sure?"),
_("Delete All Presets"),
wxICON_QUESTION | wxYES_NO);
if (res == wxID_YES)
{ {
mEffect->RemovePrivateConfigSubgroup(mEffect->GetUserPresetsGroup(wxEmptyString)); if (!up)
mUserPresets.Clear(); {
offset += 1;
}
} }
return; dc.DrawBitmap(pic, offset, offset, true);
dc.SelectObject(wxNullBitmap);
return mod;
}
void EffectUIHost::UpdateControls()
{
mApplyBtn->Enable(!mCapturing);
mBypassBtn->Enable(!mCapturing);
mPlayBtn->Enable(!mCapturing);
mRewindBtn->Enable(!mCapturing);
mFFwdBtn->Enable(!mCapturing);
mOnToggle = !EffectManager::Get().RealtimeIsSuspended();
if (mOnToggle && mCapturing)
{
mOnToggle = false;
EffectManager::Get().RealtimeSuspend();
}
mPlayBtn->SetBitmapLabel(mPlaying ? mStopBM : mPlayBM);
mPlayBtn->SetBitmapDisabled(mPlaying ? mStopDisabledBM: mPlayDisabledBM);
mBypassBtn->SetBitmapLabel(mOnToggle ? mOnBM : mOffBM);
} }
void EffectUIHost::LoadUserPresets() void EffectUIHost::LoadUserPresets()

View File

@ -12,8 +12,6 @@
#ifndef __AUDACITY_EFFECT__ #ifndef __AUDACITY_EFFECT__
#define __AUDACITY_EFFECT__ #define __AUDACITY_EFFECT__
#define TRY_BUTTONS 1
#include <set> #include <set>
#include <wx/bmpbuttn.h> #include <wx/bmpbuttn.h>
@ -29,6 +27,7 @@ class wxWindow;
#include "../Experimental.h" #include "../Experimental.h"
#include "../WaveTrack.h" #include "../WaveTrack.h"
#include "../SelectedRegion.h"
#include "../Shuttle.h" #include "../Shuttle.h"
#include "../ShuttleGui.h" #include "../ShuttleGui.h"
#include "../Internat.h" #include "../Internat.h"
@ -488,7 +487,9 @@ public:
bool Initialize(); bool Initialize();
private: private:
#if defined(TRY_BUTTONS) void OnClose(wxCloseEvent & evt);
void OnApply(wxCommandEvent & evt);
void OnCancel(wxCommandEvent & evt);
void OnMenu(wxCommandEvent & evt); void OnMenu(wxCommandEvent & evt);
void OnBypass(wxCommandEvent & evt); void OnBypass(wxCommandEvent & evt);
void OnPlay(wxCommandEvent & evt); void OnPlay(wxCommandEvent & evt);
@ -496,25 +497,17 @@ private:
void OnFFwd(wxCommandEvent & evt); void OnFFwd(wxCommandEvent & evt);
void OnPlayback(wxCommandEvent & evt); void OnPlayback(wxCommandEvent & evt);
void OnCapture(wxCommandEvent & evt); void OnCapture(wxCommandEvent & evt);
void UpdateControls(); void OnUserPreset(wxCommandEvent & evt);
wxBitmap CreateBitmap(const char *xpm[], bool up, bool pusher); void OnFactoryPreset(wxCommandEvent & evt);
#endif void OnDeletePreset(wxCommandEvent & evt);
void OnClose(wxCloseEvent & evt);
void OnApply(wxCommandEvent & evt);
void OnCancel(wxCommandEvent & evt);
void OnPreview(wxCommandEvent & evt);
void OnSettings(wxCommandEvent & evt);
void OnSaveAs(wxCommandEvent & evt); void OnSaveAs(wxCommandEvent & evt);
void OnImport(wxCommandEvent & evt); void OnImport(wxCommandEvent & evt);
void OnExport(wxCommandEvent & evt); void OnExport(wxCommandEvent & evt);
void OnOptions(wxCommandEvent & evt); void OnOptions(wxCommandEvent & evt);
void OnUserPreset(wxCommandEvent & evt);
void OnDeletePreset(wxCommandEvent & evt);
void OnFactoryPreset(wxCommandEvent & evt);
void OnDefaults(wxCommandEvent & evt); void OnDefaults(wxCommandEvent & evt);
void OnDeleteAllPresets(wxCommandEvent & evt);
void UpdateControls();
wxBitmap CreateBitmap(const char *xpm[], bool up, bool pusher);
void LoadUserPresets(); void LoadUserPresets();
private: private:
@ -525,7 +518,6 @@ private:
wxArrayString mUserPresets; wxArrayString mUserPresets;
bool mInitialized; bool mInitialized;
#if defined(TRY_BUTTONS)
wxButton *mApplyBtn; wxButton *mApplyBtn;
wxButton *mCloseBtn; wxButton *mCloseBtn;
wxBitmapButton *mMenuBtn; wxBitmapButton *mMenuBtn;
@ -534,7 +526,6 @@ private:
wxBitmapButton *mRewindBtn; wxBitmapButton *mRewindBtn;
wxBitmapButton *mFFwdBtn; wxBitmapButton *mFFwdBtn;
bool mPlayToggle;
wxBitmap mPlayBM; wxBitmap mPlayBM;
wxBitmap mPlayDisabledBM; wxBitmap mPlayDisabledBM;
wxBitmap mStopBM; wxBitmap mStopBM;
@ -543,10 +534,13 @@ private:
bool mOnToggle; bool mOnToggle;
wxBitmap mOnBM; wxBitmap mOnBM;
wxBitmap mOffBM; wxBitmap mOffBM;
wxBitmap mOffDisabledBM;
bool mPlaying; bool mPlaying;
bool mCapturing; bool mCapturing;
#endif
SelectedRegion mRegion;
double mPlayPos;
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
}; };

View File

@ -625,9 +625,8 @@ public:
private: private:
EffectHostInterface *mHost; EffectHostInterface *mHost;
int mBufferSize; int mBufferSize;
bool mUseBufferDelay; bool mUseLatency;
bool mUseGUI; bool mUseGUI;
bool mRescan;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
@ -642,9 +641,8 @@ VSTEffectSettingsDialog::VSTEffectSettingsDialog(wxWindow * parent, EffectHostIn
mHost = host; mHost = host;
mHost->GetSharedConfig(wxT("Settings"), wxT("BufferSize"), mBufferSize, 8192); mHost->GetSharedConfig(wxT("Settings"), wxT("BufferSize"), mBufferSize, 8192);
mHost->GetSharedConfig(wxT("Settings"), wxT("UseBufferDelay"), mUseBufferDelay, true); mHost->GetSharedConfig(wxT("Settings"), wxT("UseLatency"), mUseLatency, true);
mHost->GetSharedConfig(wxT("Settings"), wxT("UseGUI"), mUseGUI, true); mHost->GetSharedConfig(wxT("Settings"), wxT("UseGUI"), mUseGUI, true);
mHost->GetSharedConfig(wxT("Settings"), wxT("Rescan"), mRescan, false);
ShuttleGui S(this, eIsCreating); ShuttleGui S(this, eIsCreating);
PopulateOrExchange(S); PopulateOrExchange(S);
@ -686,7 +684,7 @@ void VSTEffectSettingsDialog::PopulateOrExchange(ShuttleGui & S)
} }
S.EndStatic(); S.EndStatic();
S.StartStatic(_("Buffer Delay Compensation")); S.StartStatic(_("Latency Compensation"));
{ {
S.AddVariableText(wxString() + S.AddVariableText(wxString() +
_("As part of their processing, some VST effects must delay returning ") + _("As part of their processing, some VST effects must delay returning ") +
@ -698,7 +696,7 @@ void VSTEffectSettingsDialog::PopulateOrExchange(ShuttleGui & S)
S.StartHorizontalLay(wxALIGN_LEFT); S.StartHorizontalLay(wxALIGN_LEFT);
{ {
S.TieCheckBox(_("Enable &compensation"), S.TieCheckBox(_("Enable &compensation"),
mUseBufferDelay); mUseLatency);
} }
S.EndHorizontalLay(); S.EndHorizontalLay();
} }
@ -714,18 +712,6 @@ void VSTEffectSettingsDialog::PopulateOrExchange(ShuttleGui & S)
mUseGUI); mUseGUI);
} }
S.EndStatic(); S.EndStatic();
S.StartStatic(_("Rescan Effects"));
{
S.AddVariableText(wxString() +
_("To improve Audacity startup, a search for VST effects is performed ") +
_("once and relevant information is recorded. When you add VST effects ") +
_("to your system, you need to tell Audacity to rescan so the new ") +
_("information can be recorded."))->Wrap(650);
S.TieCheckBox(_("&Rescan effects on next launch"),
mRescan);
}
S.EndStatic();
} }
S.EndVerticalLay(); S.EndVerticalLay();
} }
@ -749,9 +735,8 @@ void VSTEffectSettingsDialog::OnOk(wxCommandEvent & WXUNUSED(evt))
PopulateOrExchange(S); PopulateOrExchange(S);
mHost->SetSharedConfig(wxT("Settings"), wxT("BufferSize"), mBufferSize); mHost->SetSharedConfig(wxT("Settings"), wxT("BufferSize"), mBufferSize);
mHost->SetSharedConfig(wxT("Settings"), wxT("UseBufferDelay"), mUseBufferDelay); mHost->SetSharedConfig(wxT("Settings"), wxT("UseLatency"), mUseLatency);
mHost->SetSharedConfig(wxT("Settings"), wxT("UseGUI"), mUseGUI); mHost->SetSharedConfig(wxT("Settings"), wxT("UseGUI"), mUseGUI);
mHost->SetSharedConfig(wxT("Settings"), wxT("Rescan"), mRescan);
EndModal(wxID_OK); EndModal(wxID_OK);
} }
@ -1418,7 +1403,7 @@ VSTEffect::VSTEffect(const wxString & path, VSTEffect *master)
mWantsEditIdle = false; mWantsEditIdle = false;
mUserBlockSize = 8192; mUserBlockSize = 8192;
mBlockSize = mUserBlockSize; mBlockSize = mUserBlockSize;
mUseBufferDelay = true; mUseLatency = true;
mReady = false; mReady = false;
mMasterIn = NULL; mMasterIn = NULL;
@ -1634,19 +1619,19 @@ bool VSTEffect::SetHost(EffectHostInterface *host)
if (mHost) if (mHost)
{ {
mHost->GetSharedConfig(wxT("Settings"), wxT("BufferSize"), mUserBlockSize, 8192); mHost->GetSharedConfig(wxT("Settings"), wxT("BufferSize"), mUserBlockSize, 8192);
mHost->GetSharedConfig(wxT("Settings"), wxT("UseBufferDelay"), mUseBufferDelay, true); mHost->GetSharedConfig(wxT("Settings"), wxT("UseLatency"), mUseLatency, true);
mBlockSize = mUserBlockSize; mBlockSize = mUserBlockSize;
bool haveDefaults; bool haveDefaults;
mHost->GetPrivateConfig(wxT("Default"), wxT("Initialized"), haveDefaults, false); mHost->GetPrivateConfig(mHost->GetFactoryDefaultsGroup(), wxT("Initialized"), haveDefaults, false);
if (!haveDefaults) if (!haveDefaults)
{ {
SaveParameters(wxT("Default")); SaveParameters(mHost->GetFactoryDefaultsGroup());
mHost->SetPrivateConfig(wxT("Default"), wxT("Initialized"), true); mHost->SetPrivateConfig(mHost->GetFactoryDefaultsGroup(), wxT("Initialized"), true);
} }
LoadParameters(wxT("Current")); LoadParameters(mHost->GetCurrentSettingsGroup());
} }
return true; return true;
@ -1693,7 +1678,7 @@ void VSTEffect::SetSampleRate(sampleCount rate)
sampleCount VSTEffect::GetLatency() sampleCount VSTEffect::GetLatency()
{ {
if (mUseBufferDelay) if (mUseLatency)
{ {
// ??? Threading issue ??? // ??? Threading issue ???
sampleCount delay = mBufferDelay; sampleCount delay = mBufferDelay;
@ -2118,6 +2103,8 @@ bool VSTEffect::CloseUI()
void VSTEffect::LoadUserPreset(const wxString & name) void VSTEffect::LoadUserPreset(const wxString & name)
{ {
LoadParameters(name); LoadParameters(name);
RefreshParameters();
} }
void VSTEffect::SaveUserPreset(const wxString & name) void VSTEffect::SaveUserPreset(const wxString & name)
@ -2125,18 +2112,6 @@ void VSTEffect::SaveUserPreset(const wxString & name)
SaveParameters(name); SaveParameters(name);
} }
void VSTEffect::LoadFactoryPreset(int id)
{
callDispatcher(effSetProgram, 0, id, NULL, 0.0);
RefreshParameters();
}
void VSTEffect::LoadFactoryDefaults()
{
LoadParameters(mHost->GetFactoryDefaultsGroup());
}
wxArrayString VSTEffect::GetFactoryPresets() wxArrayString VSTEffect::GetFactoryPresets()
{ {
wxArrayString progs; wxArrayString progs;
@ -2152,6 +2127,25 @@ wxArrayString VSTEffect::GetFactoryPresets()
return progs; return progs;
} }
void VSTEffect::LoadFactoryPreset(int id)
{
callDispatcher(effSetProgram, 0, id, NULL, 0.0);
RefreshParameters();
}
void VSTEffect::LoadFactoryDefaults()
{
LoadParameters(mHost->GetFactoryDefaultsGroup());
RefreshParameters();
}
bool VSTEffect::CanExport()
{
return true;
}
void VSTEffect::ExportPresets() void VSTEffect::ExportPresets()
{ {
wxString path; wxString path;
@ -2265,6 +2259,11 @@ void VSTEffect::ImportPresets()
return; return;
} }
bool VSTEffect::HasOptions()
{
return true;
}
void VSTEffect::ShowOptions() void VSTEffect::ShowOptions()
{ {
VSTEffectSettingsDialog dlg(mParent, mHost); VSTEffectSettingsDialog dlg(mParent, mHost);
@ -2614,8 +2613,11 @@ void VSTEffect::LoadParameters(const wxString & group)
if (len) if (len)
{ {
callDispatcher(effSetChunk, 1, len, buf, 0.0); callDispatcher(effSetChunk, 1, len, buf, 0.0);
for (size_t i = 0, cnt = mSlaves.GetCount(); i < cnt; i++)
{
mSlaves[i]->callDispatcher(effSetChunk, 1, len, buf, 0.0);
}
} }
delete [] buf; delete [] buf;
return; return;
@ -2623,6 +2625,8 @@ void VSTEffect::LoadParameters(const wxString & group)
if (mHost->GetPrivateConfig(group, wxT("Value"), value, wxEmptyString)) if (mHost->GetPrivateConfig(group, wxT("Value"), value, wxEmptyString))
{ {
size_t cnt = mSlaves.GetCount();
wxStringTokenizer st(value, wxT(',')); wxStringTokenizer st(value, wxT(','));
for (int i = 0; st.HasMoreTokens(); i++) for (int i = 0; st.HasMoreTokens(); i++)
{ {
@ -2632,6 +2636,10 @@ void VSTEffect::LoadParameters(const wxString & group)
if (val >= -1.0 && val <= 1.0) if (val >= -1.0 && val <= 1.0)
{ {
callSetParameter(i, val); callSetParameter(i, val);
for (size_t i = 0; i < cnt; i++)
{
mSlaves[i]->callSetParameter(i, val);
}
} }
} }
} }
@ -2788,7 +2796,7 @@ void VSTEffect::Automate(int index, float value)
void VSTEffect::SetBufferDelay(int samples) void VSTEffect::SetBufferDelay(int samples)
{ {
// We do not support negative delay // We do not support negative delay
if (samples >= 0 && mUseBufferDelay) if (samples >= 0 && mUseLatency)
{ {
mBufferDelay = samples; mBufferDelay = samples;
} }

View File

@ -138,13 +138,15 @@ class VSTEffect : public EffectClientInterface,
virtual void LoadUserPreset(const wxString & name); virtual void LoadUserPreset(const wxString & name);
virtual void SaveUserPreset(const wxString & name); virtual void SaveUserPreset(const wxString & name);
virtual wxArrayString GetFactoryPresets();
virtual void LoadFactoryPreset(int id); virtual void LoadFactoryPreset(int id);
virtual void LoadFactoryDefaults(); virtual void LoadFactoryDefaults();
virtual wxArrayString GetFactoryPresets(); virtual bool CanExport();
virtual void ExportPresets(); virtual void ExportPresets();
virtual void ImportPresets(); virtual void ImportPresets();
virtual bool HasOptions();
virtual void ShowOptions(); virtual void ShowOptions();
// VSTEffect implementation // VSTEffect implementation
@ -272,7 +274,7 @@ private:
VstTimeInfo mTimeInfo; VstTimeInfo mTimeInfo;
bool mUseBufferDelay; bool mUseLatency;
int mBufferDelay; int mBufferDelay;
sampleCount mBlockSize; sampleCount mBlockSize;

View File

@ -92,7 +92,7 @@ wxString AudioUnitEffectsModule::GetPath()
wxString AudioUnitEffectsModule::GetName() wxString AudioUnitEffectsModule::GetName()
{ {
return _("AudioUnit Effects Module"); return _("Audio Unit Effects Module");
} }
wxString AudioUnitEffectsModule::GetVendor() wxString AudioUnitEffectsModule::GetVendor()
@ -108,7 +108,7 @@ wxString AudioUnitEffectsModule::GetVersion()
wxString AudioUnitEffectsModule::GetDescription() wxString AudioUnitEffectsModule::GetDescription()
{ {
return _("Provides AudioUnit Effects support to Audacity"); return _("Provides Audio Unit Effects support to Audacity");
} }
// ============================================================================ // ============================================================================
@ -291,10 +291,8 @@ public:
private: private:
EffectHostInterface *mHost; EffectHostInterface *mHost;
int mBufferSize; bool mUseLatency;
bool mUseBufferDelay;
bool mUseGUI; bool mUseGUI;
bool mRescan;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
@ -304,11 +302,11 @@ BEGIN_EVENT_TABLE(AudioUnitEffectSettingsDialog, wxDialog)
END_EVENT_TABLE() END_EVENT_TABLE()
AudioUnitEffectSettingsDialog::AudioUnitEffectSettingsDialog(wxWindow * parent, EffectHostInterface *host) AudioUnitEffectSettingsDialog::AudioUnitEffectSettingsDialog(wxWindow * parent, EffectHostInterface *host)
: wxDialog(parent, wxID_ANY, wxString(_("AudioUnit Effect Settings"))) : wxDialog(parent, wxID_ANY, wxString(_("Audio Unit Effect Settings")))
{ {
mHost = host; mHost = host;
mHost->GetSharedConfig(wxT("Settings"), wxT("UseBufferDelay"), mUseBufferDelay, true); mHost->GetSharedConfig(wxT("Settings"), wxT("UseLatency"), mUseLatency, true);
mHost->GetSharedConfig(wxT("Settings"), wxT("UseGUI"), mUseGUI, true); mHost->GetSharedConfig(wxT("Settings"), wxT("UseGUI"), mUseGUI, true);
ShuttleGui S(this, eIsCreating); ShuttleGui S(this, eIsCreating);
@ -326,19 +324,19 @@ void AudioUnitEffectSettingsDialog::PopulateOrExchange(ShuttleGui & S)
{ {
S.StartVerticalLay(false); S.StartVerticalLay(false);
{ {
S.StartStatic(_("Buffer Delay Compensation")); S.StartStatic(_("Latency Compensation"));
{ {
S.AddVariableText(wxString() + S.AddVariableText(wxString() +
_("As part of their processing, some AudioUnit effects must delay returning ") + _("As part of their processing, some Audio Unit effects must delay returning ") +
_("audio to Audacity. When not compensating for this delay, you will ") + _("audio to Audacity. When not compensating for this delay, you will ") +
_("notice that small silences have been inserted into the audio. ") + _("notice that small silences have been inserted into the audio. ") +
_("Enabling this setting will provide that compensation, but it may ") + _("Enabling this setting will provide that compensation, but it may ") +
_("not work for all AudioUnit effects."))->Wrap(650); _("not work for all Audio Unit effects."))->Wrap(650);
S.StartHorizontalLay(wxALIGN_LEFT); S.StartHorizontalLay(wxALIGN_LEFT);
{ {
S.TieCheckBox(_("Enable &compensation"), S.TieCheckBox(_("Enable &compensation"),
mUseBufferDelay); mUseLatency);
} }
S.EndHorizontalLay(); S.EndHorizontalLay();
} }
@ -347,7 +345,7 @@ void AudioUnitEffectSettingsDialog::PopulateOrExchange(ShuttleGui & S)
S.StartStatic(_("Graphical Mode")); S.StartStatic(_("Graphical Mode"));
{ {
S.AddVariableText(wxString() + S.AddVariableText(wxString() +
_("Most AudioUnit effects have a graphical interface for setting parameter values.") + _("Most Audio Unit effects have a graphical interface for setting parameter values.") +
_(" A basic text-only method is also available. ") + _(" A basic text-only method is also available. ") +
_(" Reopen the effect for this to take effect."))->Wrap(650); _(" Reopen the effect for this to take effect."))->Wrap(650);
S.TieCheckBox(_("Enable &graphical interface"), S.TieCheckBox(_("Enable &graphical interface"),
@ -376,7 +374,7 @@ void AudioUnitEffectSettingsDialog::OnOk(wxCommandEvent & WXUNUSED(evt))
ShuttleGui S(this, eIsGettingFromDialog); ShuttleGui S(this, eIsGettingFromDialog);
PopulateOrExchange(S); PopulateOrExchange(S);
mHost->SetSharedConfig(wxT("Settings"), wxT("UseBufferDelay"), mUseBufferDelay); mHost->SetSharedConfig(wxT("Settings"), wxT("UseLatency"), mUseLatency);
mHost->SetSharedConfig(wxT("Settings"), wxT("UseGUI"), mUseGUI); mHost->SetSharedConfig(wxT("Settings"), wxT("UseGUI"), mUseGUI);
EndModal(wxID_OK); EndModal(wxID_OK);
@ -415,7 +413,7 @@ BEGIN_EVENT_TABLE(AudioUnitEffectExportDialog, wxDialog)
END_EVENT_TABLE() END_EVENT_TABLE()
AudioUnitEffectExportDialog::AudioUnitEffectExportDialog(wxWindow * parent, AudioUnitEffect *effect) AudioUnitEffectExportDialog::AudioUnitEffectExportDialog(wxWindow * parent, AudioUnitEffect *effect)
: wxDialog(parent, wxID_ANY, wxString(_("Export AudioUnit Presets"))) : wxDialog(parent, wxID_ANY, wxString(_("Export Audio Unit Presets")))
{ {
mEffect = effect; mEffect = effect;
@ -582,7 +580,7 @@ BEGIN_EVENT_TABLE(AudioUnitEffectImportDialog, wxDialog)
END_EVENT_TABLE() END_EVENT_TABLE()
AudioUnitEffectImportDialog::AudioUnitEffectImportDialog(wxWindow * parent, AudioUnitEffect *effect) AudioUnitEffectImportDialog::AudioUnitEffectImportDialog(wxWindow * parent, AudioUnitEffect *effect)
: wxDialog(parent, wxID_ANY, wxString(_("Import AudioUnit Presets"))) : wxDialog(parent, wxID_ANY, wxString(_("Import Audio Unit Presets")))
{ {
mEffect = effect; mEffect = effect;
@ -1131,19 +1129,18 @@ bool AudioUnitEffect::SetHost(EffectHostInterface *host)
// mHost will be null during registration // mHost will be null during registration
if (mHost) if (mHost)
{ {
mHost->GetSharedConfig(wxT("Settings"), wxT("BufferSize"), mBufferSize, 8192); mHost->GetSharedConfig(wxT("Settings"), wxT("UseLatency"), mUseLatency, true);
mHost->GetSharedConfig(wxT("Settings"), wxT("UseBufferDelay"), mUseBufferDelay, true);
mHost->GetSharedConfig(wxT("Settings"), wxT("UseGUI"), mUseGUI, true); mHost->GetSharedConfig(wxT("Settings"), wxT("UseGUI"), mUseGUI, true);
bool haveDefaults; bool haveDefaults;
mHost->GetPrivateConfig(wxT("Default"), wxT("Initialized"), haveDefaults, false); mHost->GetPrivateConfig(mHost->GetFactoryDefaultsGroup(), wxT("Initialized"), haveDefaults, false);
if (!haveDefaults) if (!haveDefaults)
{ {
SaveParameters(wxT("Default")); SaveParameters(mHost->GetFactoryDefaultsGroup());
mHost->SetPrivateConfig(wxT("Default"), wxT("Initialized"), true); mHost->SetPrivateConfig(mHost->GetFactoryDefaultsGroup(), wxT("Initialized"), true);
} }
LoadParameters(wxT("Current")); LoadParameters(mHost->GetCurrentSettingsGroup());
} }
if (!mMaster) if (!mMaster)
@ -1264,7 +1261,7 @@ sampleCount AudioUnitEffect::GetBlockSize(sampleCount maxBlockSize)
sampleCount AudioUnitEffect::GetLatency() sampleCount AudioUnitEffect::GetLatency()
{ {
if (!mLatencyDone) if (mUseLatency && !mLatencyDone)
{ {
mLatencyDone = true; mLatencyDone = true;
return mLatency * mSampleRate; return mLatency * mSampleRate;
@ -2026,6 +2023,11 @@ wxArrayString AudioUnitEffect::GetFactoryPresets()
return presets; return presets;
} }
bool AudioUnitEffect::CanExport()
{
return true;
}
void AudioUnitEffect::ExportPresets() void AudioUnitEffect::ExportPresets()
{ {
AudioUnitEffectExportDialog dlg(mDialog, this); AudioUnitEffectExportDialog dlg(mDialog, this);
@ -2038,6 +2040,11 @@ void AudioUnitEffect::ImportPresets()
dlg.ShowModal(); dlg.ShowModal();
} }
bool AudioUnitEffect::HasOptions()
{
return true;
}
void AudioUnitEffect::ShowOptions() void AudioUnitEffect::ShowOptions()
{ {
AudioUnitEffectSettingsDialog dlg(mParent, mHost); AudioUnitEffectSettingsDialog dlg(mParent, mHost);

View File

@ -117,8 +117,11 @@ public:
virtual wxArrayString GetFactoryPresets(); virtual wxArrayString GetFactoryPresets();
virtual bool CanExport();
virtual void ExportPresets(); virtual void ExportPresets();
virtual void ImportPresets(); virtual void ImportPresets();
virtual bool HasOptions();
virtual void ShowOptions(); virtual void ShowOptions();
// AudioUnitEffect implementation // AudioUnitEffect implementation
@ -186,7 +189,7 @@ private:
double mSampleRate; double mSampleRate;
int mBufferSize; int mBufferSize;
bool mUseBufferDelay; bool mUseLatency;
AudioTimeStamp mTimeStamp; AudioTimeStamp mTimeStamp;
bool mReady; bool mReady;

View File

@ -48,6 +48,7 @@ effects from this one class.
#include "LadspaEffect.h" // This class's header file #include "LadspaEffect.h" // This class's header file
#include "../../Internat.h" #include "../../Internat.h"
#include "../../ShuttleGui.h"
#include "../../widgets/valnum.h" #include "../../widgets/valnum.h"
// ============================================================================ // ============================================================================
@ -373,6 +374,99 @@ void LadspaEffectsModule::DeleteInstance(IdentInterface *instance)
} }
} }
///////////////////////////////////////////////////////////////////////////////
//
// LadspaEffectSettingsDialog
//
///////////////////////////////////////////////////////////////////////////////
class LadspaEffectSettingsDialog:public wxDialog
{
public:
LadspaEffectSettingsDialog(wxWindow * parent, EffectHostInterface *host);
virtual ~LadspaEffectSettingsDialog();
void PopulateOrExchange(ShuttleGui & S);
void OnOk(wxCommandEvent & evt);
private:
EffectHostInterface *mHost;
bool mUseLatency;
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(LadspaEffectSettingsDialog, wxDialog)
EVT_BUTTON(wxID_OK, LadspaEffectSettingsDialog::OnOk)
END_EVENT_TABLE()
LadspaEffectSettingsDialog::LadspaEffectSettingsDialog(wxWindow * parent, EffectHostInterface *host)
: wxDialog(parent, wxID_ANY, wxString(_("Ladspa Effect Settings")))
{
mHost = host;
mHost->GetSharedConfig(wxT("Settings"), wxT("UseLatency"), mUseLatency, true);
ShuttleGui S(this, eIsCreating);
PopulateOrExchange(S);
}
LadspaEffectSettingsDialog::~LadspaEffectSettingsDialog()
{
}
void LadspaEffectSettingsDialog::PopulateOrExchange(ShuttleGui & S)
{
S.SetBorder(5);
S.StartHorizontalLay(wxEXPAND, 1);
{
S.StartVerticalLay(false);
{
S.StartStatic(_("Latency Compensation"));
{
S.AddVariableText(wxString() +
_("As part of their processing, some Ladspa effects must delay returning ") +
_("audio to Audacity. When not compensating for this delay, you will ") +
_("notice that small silences have been inserted into the audio. ") +
_("Enabling this setting will provide that compensation, but it may ") +
_("not work for all Ladspa effects."))->Wrap(650);
S.StartHorizontalLay(wxALIGN_LEFT);
{
S.TieCheckBox(_("Enable &compensation"),
mUseLatency);
}
S.EndHorizontalLay();
}
S.EndStatic();
}
S.EndVerticalLay();
}
S.EndHorizontalLay();
S.AddStandardButtons();
Layout();
Fit();
Center();
}
void LadspaEffectSettingsDialog::OnOk(wxCommandEvent & WXUNUSED(evt))
{
if (!Validate())
{
return;
}
ShuttleGui S(this, eIsGettingFromDialog);
PopulateOrExchange(S);
mHost->SetSharedConfig(wxT("Settings"), wxT("UseLatency"), mUseLatency);
EndModal(wxID_OK);
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// //
// LadspaEffectEventHelper // LadspaEffectEventHelper
@ -739,18 +833,17 @@ bool LadspaEffect::SetHost(EffectHostInterface *host)
// mHost will be null during registration // mHost will be null during registration
if (mHost) if (mHost)
{ {
mHost->GetSharedConfig(wxT("Settings"), wxT("BufferSize"), mUserBlockSize, 8192); mHost->GetSharedConfig(wxT("Settings"), wxT("UseLatency"), mUseLatency, true);
mBlockSize = mUserBlockSize;
bool haveDefaults; bool haveDefaults;
mHost->GetPrivateConfig(wxT("Default"), wxT("Initialized"), haveDefaults, false); mHost->GetPrivateConfig(mHost->GetFactoryDefaultsGroup(), wxT("Initialized"), haveDefaults, false);
if (!haveDefaults) if (!haveDefaults)
{ {
SaveParameters(wxT("Default")); SaveParameters(mHost->GetFactoryDefaultsGroup());
mHost->SetPrivateConfig(wxT("Default"), wxT("Initialized"), true); mHost->SetPrivateConfig(mHost->GetFactoryDefaultsGroup(), wxT("Initialized"), true);
} }
LoadParameters(wxT("Current")); LoadParameters(mHost->GetCurrentSettingsGroup());
} }
return true; return true;
@ -783,24 +876,12 @@ void LadspaEffect::SetSampleRate(sampleCount rate)
sampleCount LadspaEffect::GetBlockSize(sampleCount maxBlockSize) sampleCount LadspaEffect::GetBlockSize(sampleCount maxBlockSize)
{ {
#if 0
// TODO: Allow user to specify the max blocksize
if (mUserBlockSize > maxBlockSize)
{
mBlockSize = maxBlockSize;
}
else
{
mBlockSize = mUserBlockSize;
}
#endif
return mBlockSize; return mBlockSize;
} }
sampleCount LadspaEffect::GetLatency() sampleCount LadspaEffect::GetLatency()
{ {
if (mLatencyPort >= 0 && !mLatencyDone) if (mUseLatency && mLatencyPort >= 0 && !mLatencyDone)
{ {
mLatencyDone = true; mLatencyDone = true;
return mOutputControls[mLatencyPort] * 2; return mOutputControls[mLatencyPort] * 2;
@ -1284,6 +1365,7 @@ bool LadspaEffect::CloseUI()
void LadspaEffect::LoadUserPreset(const wxString & name) void LadspaEffect::LoadUserPreset(const wxString & name)
{ {
LoadParameters(name); LoadParameters(name);
RefreshControls();
} }
void LadspaEffect::SaveUserPreset(const wxString & name) void LadspaEffect::SaveUserPreset(const wxString & name)
@ -1291,6 +1373,11 @@ void LadspaEffect::SaveUserPreset(const wxString & name)
SaveParameters(name); SaveParameters(name);
} }
wxArrayString LadspaEffect::GetFactoryPresets()
{
return wxArrayString();
}
void LadspaEffect::LoadFactoryPreset(int WXUNUSED(id)) void LadspaEffect::LoadFactoryPreset(int WXUNUSED(id))
{ {
return; return;
@ -1299,11 +1386,12 @@ void LadspaEffect::LoadFactoryPreset(int WXUNUSED(id))
void LadspaEffect::LoadFactoryDefaults() void LadspaEffect::LoadFactoryDefaults()
{ {
LoadParameters(mHost->GetFactoryDefaultsGroup()); LoadParameters(mHost->GetFactoryDefaultsGroup());
RefreshControls();
} }
wxArrayString LadspaEffect::GetFactoryPresets() bool LadspaEffect::CanExport()
{ {
return wxArrayString(); return false;
} }
void LadspaEffect::ExportPresets() void LadspaEffect::ExportPresets()
@ -1314,8 +1402,19 @@ void LadspaEffect::ImportPresets()
{ {
} }
bool LadspaEffect::HasOptions()
{
return true;
}
void LadspaEffect::ShowOptions() void LadspaEffect::ShowOptions()
{ {
LadspaEffectSettingsDialog dlg(mParent, mHost);
if (dlg.ShowModal())
{
// Reinitialize configuration settings
SetHost(mHost);
}
} }
// ============================================================================ // ============================================================================

View File

@ -109,13 +109,15 @@ public:
virtual void LoadUserPreset(const wxString & name); virtual void LoadUserPreset(const wxString & name);
virtual void SaveUserPreset(const wxString & name); virtual void SaveUserPreset(const wxString & name);
virtual wxArrayString GetFactoryPresets();
virtual void LoadFactoryPreset(int id); virtual void LoadFactoryPreset(int id);
virtual void LoadFactoryDefaults(); virtual void LoadFactoryDefaults();
virtual wxArrayString GetFactoryPresets(); virtual bool CanExport();
virtual void ExportPresets(); virtual void ExportPresets();
virtual void ImportPresets(); virtual void ImportPresets();
virtual bool HasOptions();
virtual void ShowOptions(); virtual void ShowOptions();
// LadspaEffect implementation // LadspaEffect implementation
@ -167,6 +169,7 @@ private:
int mNumOutputControls; int mNumOutputControls;
float *mOutputControls; float *mOutputControls;
bool mUseLatency;
int mLatencyPort; int mLatencyPort;
bool mLatencyDone; bool mLatencyDone;