1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-04 14:39:08 +02:00

Bug 2237 - Equalization effects have no Import or Export for curves

This is a minimal fix for this bug, and can be improved on in time.  There is almost no error checking in the file read and write, so if you use a bad presets file, you won't be told (yet).

It does provide import and export for all effects that have presets.
This commit is contained in:
James Crook 2020-02-17 11:59:40 +00:00
parent 5c85deb944
commit 83c294c844

View File

@ -658,15 +658,99 @@ bool Effect::CloseUI()
bool Effect::CanExportPresets() bool Effect::CanExportPresets()
{ {
return false; return true;
} }
void Effect::ExportPresets() void Effect::ExportPresets()
{ {
wxString params;
if (!GetAutomationParameters(params))
{
wxLogDebug("No Params");
}
wxFileName path;
path = gPrefs->Read(wxT("Presets/Path"), wxEmptyString);
wxFileDialog dlog(NULL,
_("Export Effect Parameters"),
path.GetFullPath(),
wxEmptyString,
_("Presets (*.txt)|*.txt|All files|*"),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER);
if (dlog.ShowModal() != wxID_OK) {
return;
}
path = dlog.GetPath();
gPrefs->Write(wxT("Presets/Path"), path.GetFullPath());
wxLogDebug("Params: %s", params);
// Create/Open the file
wxFFile f(path.GetFullPath(), wxT("wb"));
if (!f.IsOpened())
{
AudacityMessageBox(
XO("Could not open file: \"%s\"").Format( path.GetFullPath() ),
XO("Error Saving Effect Presets"),
wxICON_EXCLAMATION,
NULL);
return;
}
f.Write(params);
if (f.Error())
{
AudacityMessageBox(
XO("Error writing to file: \"%s\"").Format( path.GetFullPath() ),
XO("Error Saving Effect Presets"),
wxICON_EXCLAMATION,
NULL);
}
f.Close();
//SetWindowTitle();
} }
void Effect::ImportPresets() void Effect::ImportPresets()
{ {
wxString params;
wxFileName path;
path = gPrefs->Read(wxT("Presets/Path"), wxEmptyString);
wxFileDialog dlog(NULL,
_("Import Effect Parameters"),
path.GetPath(),
wxEmptyString,
_("Presets (*.txt)|*.txt|All files|*"),
wxFD_OPEN | wxRESIZE_BORDER);
if (dlog.ShowModal() != wxID_OK) {
return;
}
path = dlog.GetPath();
if( !path.IsOk())
return;
gPrefs->Write(wxT("Presets/Path"), path.GetFullPath());
wxFFile f(path.GetFullPath());
if (f.IsOpened()) {
if (f.ReadAll(&params)) {
SetAutomationParameters(params);
}
}
//SetWindowTitle();
} }
bool Effect::HasOptions() bool Effect::HasOptions()