mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-22 15:20:15 +02:00
Remove obsolete 'rate' keyword to prevent crash
and added numeric-text controls.
This commit is contained in:
parent
d1d83596cd
commit
8828ab50b7
@ -257,7 +257,7 @@ bool NyquistEffect::GetAutomationParameters(EffectAutomationParameters & parms)
|
|||||||
d = GetCtrlValue(ctrl.valStr);
|
d = GetCtrlValue(ctrl.valStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctrl.type == NYQ_CTRL_REAL)
|
if (ctrl.type == NYQ_CTRL_REAL || ctrl.type == NYQ_CTRL_FLOAT_TEXT)
|
||||||
{
|
{
|
||||||
parms.Write(ctrl.var, d);
|
parms.Write(ctrl.var, d);
|
||||||
}
|
}
|
||||||
@ -300,14 +300,14 @@ bool NyquistEffect::SetAutomationParameters(EffectAutomationParameters & parms)
|
|||||||
NyqControl & ctrl = mControls[c];
|
NyqControl & ctrl = mControls[c];
|
||||||
bool good = false;
|
bool good = false;
|
||||||
|
|
||||||
if (ctrl.type == NYQ_CTRL_REAL)
|
if (ctrl.type == NYQ_CTRL_REAL || ctrl.type == NYQ_CTRL_FLOAT_TEXT)
|
||||||
{
|
{
|
||||||
double val;
|
double val;
|
||||||
good = parms.Read(ctrl.var, &val) &&
|
good = parms.Read(ctrl.var, &val) &&
|
||||||
val >= ctrl.low &&
|
val >= ctrl.low &&
|
||||||
val <= ctrl.high;
|
val <= ctrl.high;
|
||||||
}
|
}
|
||||||
else if (ctrl.type == NYQ_CTRL_INT)
|
else if (ctrl.type == NYQ_CTRL_INT || ctrl.type == NYQ_CTRL_INT_TEXT)
|
||||||
{
|
{
|
||||||
int val;
|
int val;
|
||||||
good = parms.Read(ctrl.var, &val) &&
|
good = parms.Read(ctrl.var, &val) &&
|
||||||
@ -344,11 +344,11 @@ bool NyquistEffect::SetAutomationParameters(EffectAutomationParameters & parms)
|
|||||||
d = GetCtrlValue(ctrl.valStr);
|
d = GetCtrlValue(ctrl.valStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctrl.type == NYQ_CTRL_REAL)
|
if (ctrl.type == NYQ_CTRL_REAL || ctrl.type == NYQ_CTRL_FLOAT_TEXT)
|
||||||
{
|
{
|
||||||
parms.Read(ctrl.var, &ctrl.val);
|
parms.Read(ctrl.var, &ctrl.val);
|
||||||
}
|
}
|
||||||
else if (ctrl.type == NYQ_CTRL_INT)
|
else if (ctrl.type == NYQ_CTRL_INT || ctrl.type == NYQ_CTRL_INT_TEXT)
|
||||||
{
|
{
|
||||||
int val;
|
int val;
|
||||||
parms.Read(ctrl.var, &val);
|
parms.Read(ctrl.var, &val);
|
||||||
@ -914,7 +914,7 @@ bool NyquistEffect::ProcessOne()
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int j = 0; j < mControls.GetCount(); j++) {
|
for (unsigned int j = 0; j < mControls.GetCount(); j++) {
|
||||||
if (mControls[j].type == NYQ_CTRL_REAL) {
|
if (mControls[j].type == NYQ_CTRL_REAL || mControls[j].type == NYQ_CTRL_FLOAT_TEXT) {
|
||||||
// We use Internat::ToString() rather than "%f" here because we
|
// We use Internat::ToString() rather than "%f" here because we
|
||||||
// always have to use the dot as decimal separator when giving
|
// always have to use the dot as decimal separator when giving
|
||||||
// numbers to Nyquist, whereas using "%f" will use the user's
|
// numbers to Nyquist, whereas using "%f" will use the user's
|
||||||
@ -924,6 +924,7 @@ bool NyquistEffect::ProcessOne()
|
|||||||
Internat::ToString(mControls[j].val, 14).c_str());
|
Internat::ToString(mControls[j].val, 14).c_str());
|
||||||
}
|
}
|
||||||
else if (mControls[j].type == NYQ_CTRL_INT ||
|
else if (mControls[j].type == NYQ_CTRL_INT ||
|
||||||
|
mControls[j].type == NYQ_CTRL_INT_TEXT ||
|
||||||
mControls[j].type == NYQ_CTRL_CHOICE) {
|
mControls[j].type == NYQ_CTRL_CHOICE) {
|
||||||
cmd += wxString::Format(wxT("(setf %s %d)\n"),
|
cmd += wxString::Format(wxT("(setf %s %d)\n"),
|
||||||
mControls[j].var.c_str(),
|
mControls[j].var.c_str(),
|
||||||
@ -1256,12 +1257,22 @@ wxString NyquistEffect::UnQuote(wxString s)
|
|||||||
|
|
||||||
double NyquistEffect::GetCtrlValue(wxString s)
|
double NyquistEffect::GetCtrlValue(wxString s)
|
||||||
{
|
{
|
||||||
if (s == wxT("rate")) {
|
/* For this to work correctly requires that the plug-in header is
|
||||||
TrackListOfKindIterator iter(Track::Wave, mTracks);
|
* parsed on each run so that the correct value for "half-srate" may
|
||||||
return ((WaveTrack *)iter.First())->GetRate();
|
* be determined.
|
||||||
|
*
|
||||||
|
AudacityProject *project = GetActiveProject();
|
||||||
|
double rate = INT_MAX;
|
||||||
|
if (project && s.IsSameAs(wxT("half-srate"), false)) {
|
||||||
|
SelectedTrackListOfKindIterator sel(Track::Wave, project->GetTracks());
|
||||||
|
for (WaveTrack *t = (WaveTrack *) sel.First(); t; t = (WaveTrack *) sel.Next()) {
|
||||||
|
rate = std::min(t->GetRate(), rate);
|
||||||
|
}
|
||||||
|
return (rate / 2.0);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return Internat::CompatibleToDouble(s);
|
return Internat::CompatibleToDouble(s);;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NyquistEffect::Parse(wxString line)
|
void NyquistEffect::Parse(wxString line)
|
||||||
@ -1471,11 +1482,15 @@ void NyquistEffect::Parse(wxString line)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((tokens[3] == wxT("real")) ||
|
if ((tokens[3] == wxT("float")) ||
|
||||||
(tokens[3] == wxT("float"))) // undocumented, but useful, alternative
|
(tokens[3] == wxT("real"))) // Deprecated
|
||||||
ctrl.type = NYQ_CTRL_REAL;
|
ctrl.type = NYQ_CTRL_REAL;
|
||||||
else if (tokens[3] == wxT("int"))
|
else if (tokens[3] == wxT("int"))
|
||||||
ctrl.type = NYQ_CTRL_INT;
|
ctrl.type = NYQ_CTRL_INT;
|
||||||
|
else if (tokens[3] == wxT("float-text"))
|
||||||
|
ctrl.type = NYQ_CTRL_FLOAT_TEXT;
|
||||||
|
else if (tokens[3] == wxT("int-text"))
|
||||||
|
ctrl.type = NYQ_CTRL_INT_TEXT;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxString str;
|
wxString str;
|
||||||
@ -1492,9 +1507,26 @@ void NyquistEffect::Parse(wxString line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctrl.lowStr = tokens[6];
|
ctrl.lowStr = tokens[6];
|
||||||
ctrl.low = GetCtrlValue(ctrl.lowStr);
|
if (ctrl.type == NYQ_CTRL_INT_TEXT && ctrl.lowStr.IsSameAs(wxT("nil"), false)) {
|
||||||
|
ctrl.low = INT_MIN;
|
||||||
|
}
|
||||||
|
else if (ctrl.type == NYQ_CTRL_FLOAT_TEXT && ctrl.lowStr.IsSameAs(wxT("nil"), false)) {
|
||||||
|
ctrl.low = -(FLT_MAX);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ctrl.low = GetCtrlValue(ctrl.lowStr);
|
||||||
|
}
|
||||||
|
|
||||||
ctrl.highStr = tokens[7];
|
ctrl.highStr = tokens[7];
|
||||||
ctrl.high = GetCtrlValue(ctrl.highStr);
|
if (ctrl.type == NYQ_CTRL_INT_TEXT && ctrl.highStr.IsSameAs(wxT("nil"), false)) {
|
||||||
|
ctrl.high = INT_MAX;
|
||||||
|
}
|
||||||
|
else if (ctrl.type == NYQ_CTRL_FLOAT_TEXT && ctrl.highStr.IsSameAs(wxT("nil"), false)) {
|
||||||
|
ctrl.high = FLT_MAX;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ctrl.high = GetCtrlValue(ctrl.highStr);
|
||||||
|
}
|
||||||
|
|
||||||
if (ctrl.high < ctrl.low) {
|
if (ctrl.high < ctrl.low) {
|
||||||
ctrl.high = ctrl.low + 1;
|
ctrl.high = ctrl.low + 1;
|
||||||
@ -1781,7 +1813,7 @@ bool NyquistEffect::TransferDataToEffectWindow()
|
|||||||
wxChoice *c = (wxChoice *) mUIParent->FindWindow(ID_Choice + i);
|
wxChoice *c = (wxChoice *) mUIParent->FindWindow(ID_Choice + i);
|
||||||
c->SetSelection(val);
|
c->SetSelection(val);
|
||||||
}
|
}
|
||||||
else if (ctrl.type != NYQ_CTRL_STRING)
|
else if (ctrl.type == NYQ_CTRL_INT || ctrl.type == NYQ_CTRL_REAL)
|
||||||
{
|
{
|
||||||
// wxTextCtrls are handled by the validators
|
// wxTextCtrls are handled by the validators
|
||||||
double range = ctrl.high - ctrl.low;
|
double range = ctrl.high - ctrl.low;
|
||||||
@ -1828,8 +1860,25 @@ bool NyquistEffect::TransferDataFromEffectWindow()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctrl->low = GetCtrlValue(ctrl->lowStr);
|
if (ctrl->type == NYQ_CTRL_INT_TEXT && ctrl->lowStr.IsSameAs(wxT("nil"), false)) {
|
||||||
ctrl->high = GetCtrlValue(ctrl->highStr);
|
ctrl->low = INT_MIN;
|
||||||
|
}
|
||||||
|
else if (ctrl->type == NYQ_CTRL_FLOAT_TEXT && ctrl->lowStr.IsSameAs(wxT("nil"), false)) {
|
||||||
|
ctrl->low = -(FLT_MAX);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ctrl->low = GetCtrlValue(ctrl->lowStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ctrl->type == NYQ_CTRL_INT_TEXT && ctrl->highStr.IsSameAs(wxT("nil"), false)) {
|
||||||
|
ctrl->high = INT_MAX;
|
||||||
|
}
|
||||||
|
else if (ctrl->type == NYQ_CTRL_FLOAT_TEXT && ctrl->highStr.IsSameAs(wxT("nil"), false)) {
|
||||||
|
ctrl->high = FLT_MAX;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ctrl->high = GetCtrlValue(ctrl->highStr);
|
||||||
|
}
|
||||||
|
|
||||||
if (ctrl->high < ctrl->low)
|
if (ctrl->high < ctrl->low)
|
||||||
{
|
{
|
||||||
@ -1923,11 +1972,18 @@ void NyquistEffect::BuildEffectWindow(ShuttleGui & S)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Integer or Real
|
// Integer or Real
|
||||||
wxTextCtrl *item = S.Id(ID_Text+i).AddTextBox(wxT(""), wxT(""), 12);
|
if (ctrl.type == NYQ_CTRL_INT_TEXT || ctrl.type == NYQ_CTRL_FLOAT_TEXT)
|
||||||
|
{
|
||||||
|
S.AddSpace(10, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxTextCtrl *item = S.Id(ID_Text+i).AddTextBox(wxT(""), wxT(""),
|
||||||
|
(ctrl.type == NYQ_CTRL_INT_TEXT ||
|
||||||
|
ctrl.type == NYQ_CTRL_FLOAT_TEXT) ? 25 : 12);
|
||||||
|
|
||||||
double range = ctrl.high - ctrl.low;
|
double range = ctrl.high - ctrl.low;
|
||||||
|
|
||||||
if (ctrl.type == NYQ_CTRL_REAL)
|
if (ctrl.type == NYQ_CTRL_REAL || ctrl.type == NYQ_CTRL_FLOAT_TEXT)
|
||||||
{
|
{
|
||||||
// > 12 decimal places can cause rounding errors in display.
|
// > 12 decimal places can cause rounding errors in display.
|
||||||
FloatingPointValidator<double> vld(12, &ctrl.val);
|
FloatingPointValidator<double> vld(12, &ctrl.val);
|
||||||
@ -1948,9 +2004,12 @@ void NyquistEffect::BuildEffectWindow(ShuttleGui & S)
|
|||||||
item->SetValidator(vld);
|
item->SetValidator(vld);
|
||||||
}
|
}
|
||||||
|
|
||||||
S.SetStyle(wxSL_HORIZONTAL);
|
if (ctrl.type == NYQ_CTRL_INT || ctrl.type == NYQ_CTRL_REAL)
|
||||||
S.Id(ID_Slider + i).AddSlider(wxT(""), 0, ctrl.ticks, 0);
|
{
|
||||||
S.SetSizeHints(150, -1);
|
S.SetStyle(wxSL_HORIZONTAL);
|
||||||
|
S.Id(ID_Slider + i).AddSlider(wxT(""), 0, ctrl.ticks, 0);
|
||||||
|
S.SetSizeHints(150, -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctrl.type == NYQ_CTRL_CHOICE || ctrl.label.IsEmpty())
|
if (ctrl.type == NYQ_CTRL_CHOICE || ctrl.label.IsEmpty())
|
||||||
@ -2080,7 +2139,7 @@ void NyquistEffect::OnText(wxCommandEvent & evt)
|
|||||||
|
|
||||||
if (wxDynamicCast(evt.GetEventObject(), wxWindow)->GetValidator()->TransferFromWindow())
|
if (wxDynamicCast(evt.GetEventObject(), wxWindow)->GetValidator()->TransferFromWindow())
|
||||||
{
|
{
|
||||||
if (ctrl.type != NYQ_CTRL_STRING)
|
if (ctrl.type == NYQ_CTRL_REAL || ctrl.type == NYQ_CTRL_INT)
|
||||||
{
|
{
|
||||||
int pos = (int)floor((ctrl.val - ctrl.low) /
|
int pos = (int)floor((ctrl.val - ctrl.low) /
|
||||||
(ctrl.high - ctrl.low) * ctrl.ticks + 0.5);
|
(ctrl.high - ctrl.low) * ctrl.ticks + 0.5);
|
||||||
|
@ -39,6 +39,8 @@ enum NyqControlType
|
|||||||
NYQ_CTRL_REAL,
|
NYQ_CTRL_REAL,
|
||||||
NYQ_CTRL_STRING,
|
NYQ_CTRL_STRING,
|
||||||
NYQ_CTRL_CHOICE,
|
NYQ_CTRL_CHOICE,
|
||||||
|
NYQ_CTRL_INT_TEXT,
|
||||||
|
NYQ_CTRL_FLOAT_TEXT
|
||||||
};
|
};
|
||||||
|
|
||||||
class NyqControl
|
class NyqControl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user