1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-08 22:23:59 +01:00

Update Nyquist v4 property lists and comments

Comments added where documentation is required.
This commit is contained in:
Steve Daulton
2016-10-14 13:35:16 +01:00
committed by James Crook
parent 73b421a5c3
commit 1a5a025b70

View File

@@ -506,7 +506,7 @@ bool NyquistEffect::Process()
{ {
list += wxT("\"") + EscapeString(paths[i]) + wxT("\" "); list += wxT("\"") + EscapeString(paths[i]) + wxT("\" ");
} }
mProps += wxString::Format(wxT("(putprop '*SYSTEM-DIR* (list %s) 'PLUGIN)\n"), list.RemoveLast().c_str()); mProps += wxString::Format(wxT("(putprop '*SYSTEM-DIR* (list %s) 'PLUG-IN)\n"), list.RemoveLast().c_str());
// Date and time: // Date and time:
@@ -517,7 +517,7 @@ bool NyquistEffect::Process()
// enumerated constants // enumerated constants
wxDateTime::Month month = now.GetMonth(); wxDateTime::Month month = now.GetMonth();
wxDateTime::WeekDay day = now.GetWeekDay(); wxDateTime::WeekDay day = now.GetWeekDay();
// Date/time as a list: year, day of year, hour, minute, seconds // Date/time as a list: year, day of year, hour, minute, seconds
mProps += wxString::Format(wxT("(setf *SYSTEM-TIME* (list %d %d %d %d %d))\n"), mProps += wxString::Format(wxT("(setf *SYSTEM-TIME* (list %d %d %d %d %d))\n"),
year, doy, now.GetHour(), now.GetMinute(), now.GetSecond()); year, doy, now.GetHour(), now.GetMinute(), now.GetSecond());
@@ -532,6 +532,10 @@ bool NyquistEffect::Process()
mProps += wxString::Format(wxT("(putprop '*SYSTEM-TIME* \"%s\" 'MONTH-NAME)\n"), now.GetMonthName(month).c_str()); mProps += wxString::Format(wxT("(putprop '*SYSTEM-TIME* \"%s\" 'MONTH-NAME)\n"), now.GetMonthName(month).c_str());
mProps += wxString::Format(wxT("(putprop '*SYSTEM-TIME* \"%s\" 'DAY-NAME)\n"), now.GetWeekDayName(day).c_str()); mProps += wxString::Format(wxT("(putprop '*SYSTEM-TIME* \"%s\" 'DAY-NAME)\n"), now.GetWeekDayName(day).c_str());
// TODO: Document: Number of open projects
mProps += wxString::Format(wxT("(putprop '*PROJECT* %d 'PROJECTS)\n"), gAudacityProjects.size());
// TODO: Document. NOTE: unnamed project returns an empty string.
mProps += wxString::Format(wxT("(putprop '*PROJECT* \"%s\" 'NAME)\n"), project->GetName().c_str());
TrackListIterator all(project->GetTracks()); TrackListIterator all(project->GetTracks());
Track *t; Track *t;
@@ -852,11 +856,13 @@ bool NyquistEffect::ProcessOne()
wxString type; wxString type;
wxString view; wxString view;
wxString bitFormat; wxString bitFormat;
wxString spectralEditp;
switch (mCurTrack[0]->GetKind()) switch (mCurTrack[0]->GetKind())
{ {
case Track::Wave: case Track::Wave:
type = wxT("wave"); type = wxT("wave");
spectralEditp = mCurTrack[0]->GetSpectrogramSettings().SpectralSelectionEnabled()? wxT("T") : wxT("NIL");
switch (((WaveTrack *) mCurTrack[0])->GetDisplay()) switch (((WaveTrack *) mCurTrack[0])->GetDisplay())
{ {
case WaveTrack::Waveform: case WaveTrack::Waveform:
@@ -891,6 +897,9 @@ bool NyquistEffect::ProcessOne()
cmd += wxString::Format(wxT("(putprop '*TRACK* %s 'VIEW)\n"), view.c_str()); cmd += wxString::Format(wxT("(putprop '*TRACK* %s 'VIEW)\n"), view.c_str());
cmd += wxString::Format(wxT("(putprop '*TRACK* %d 'CHANNELS)\n"), mCurNumChannels); cmd += wxString::Format(wxT("(putprop '*TRACK* %d 'CHANNELS)\n"), mCurNumChannels);
//TODO: Document NOTE: Audacity 2.1.3 True if spectral selection is enabled regardless of track view.
cmd += wxString::Format(wxT("(putprop '*TRACK* %s 'SPECTRAL-EDIT-ENABLED)\n"), spectralEditp.c_str());
double startTime = 0.0; double startTime = 0.0;
double endTime = 0.0; double endTime = 0.0;
@@ -934,11 +943,14 @@ bool NyquistEffect::ProcessOne()
cmd += wxString::Format(wxT("(putprop '*TRACK* %s 'FORMAT)\n"), bitFormat.c_str()); cmd += wxString::Format(wxT("(putprop '*TRACK* %s 'FORMAT)\n"), bitFormat.c_str());
float maxPeak = 0.0; float maxPeak = 0.0;
wxString clips; wxString clips, rmsString;
for (int i = 0; i < mCurNumChannels; i++) { for (int i = 0; i < mCurNumChannels; i++) {
auto ca = mCurTrack[i]->SortedClipArray(); auto ca = mCurTrack[i]->SortedClipArray();
// A list of clips for mono, or an array of lists for multi-channel. // A list of clips for mono, or an array of lists for multi-channel.
if (mCurNumChannels > 1) clips += wxT("(list "); if (mCurNumChannels > 1) {
clips += wxT("(list ");
}
// Each clip is a list (start-time, end-time) // Each clip is a list (start-time, end-time)
for (const auto clip: ca) { for (const auto clip: ca) {
clips += wxString::Format(wxT("(list (float %s) (float %s))"), clips += wxString::Format(wxT("(list (float %s) (float %s))"),
@@ -950,13 +962,29 @@ bool NyquistEffect::ProcessOne()
float min, max; float min, max;
mCurTrack[i]->GetMinMax(&min, &max, mT0, mT1); mCurTrack[i]->GetMinMax(&min, &max, mT0, mT1);
maxPeak = wxMax(wxMax(fabs(min), fabs(max)), maxPeak); maxPeak = wxMax(wxMax(fabs(min), fabs(max)), maxPeak);
float rms = 0.0;
mCurTrack[i]->GetRMS(&rms, mT0, mT1);
if (!std::isinf(rms) && !std::isnan(rms)) {
rmsString += wxString::Format(wxT("(float %s) "), Internat::ToString(rms).c_str());
} else {
rmsString += wxT("nil ");
}
} }
// A list of clips for mono, or an array of lists for multi-channel. // A list of clips for mono, or an array of lists for multi-channel.
cmd += wxString::Format(wxT("(putprop '*TRACK* %s%s ) 'CLIPS)\n"), cmd += wxString::Format(wxT("(putprop '*TRACK* %s%s ) 'CLIPS)\n"),
(mCurNumChannels == 1) ? wxT("(list ") : wxT("(vector "), (mCurNumChannels == 1) ? wxT("(list ") : wxT("(vector "),
clips.c_str()); clips.c_str());
cmd += wxString::Format(wxT("(putprop '*SELECTION* (float %s) 'PEAK-LEVEL)\n"), // TODO: Document, PEAK is nil if NaN or INF.
Internat::ToString(maxPeak).c_str()); // On Debian, NaN samples give maxPeak = 3.40282e+38 (FLT_MAX)
if (!std::isinf(maxPeak) && !std::isnan(maxPeak) && (maxPeak < FLT_MAX)) {
cmd += wxString::Format(wxT("(putprop '*SELECTION* (float %s) 'PEAK)\n"),
Internat::ToString(maxPeak).c_str());
}
// TODO: Document, RMS is linear RMS per channel.
(mCurNumChannels > 1)?
cmd += wxString::Format(wxT("(putprop '*SELECTION* (vector %s) 'RMS)\n"), rmsString) :
cmd += wxString::Format(wxT("(putprop '*SELECTION* %s 'RMS)\n"), rmsString);
} }
if (GetType() == EffectTypeGenerate) { if (GetType() == EffectTypeGenerate) {
@@ -1611,7 +1639,7 @@ void NyquistEffect::Parse(const wxString &line)
} }
if (ctrl.high < ctrl.low) { if (ctrl.high < ctrl.low) {
ctrl.high = ctrl.low + 1; ctrl.high = ctrl.low;
} }
if (ctrl.val < ctrl.low) { if (ctrl.val < ctrl.low) {
@@ -2265,7 +2293,7 @@ NyquistOutputDialog::NyquistOutputDialog(wxWindow * parent, wxWindowID id,
item->SetName(prompt); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) item->SetName(prompt); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
mainSizer->Add(item, 0, wxALIGN_LEFT | wxLEFT | wxTOP | wxRIGHT, 10); mainSizer->Add(item, 0, wxALIGN_LEFT | wxLEFT | wxTOP | wxRIGHT, 10);
// TODO use ShowInfoDialog() instead. // TODO: use ShowInfoDialog() instead.
// Beware this dialog MUST work with screen readers. // Beware this dialog MUST work with screen readers.
item = safenew wxTextCtrl(this, -1, message, item = safenew wxTextCtrl(this, -1, message,
wxDefaultPosition, wxSize(400, 200), wxDefaultPosition, wxSize(400, 200),