Audacity  3.0.3
VampEffect.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  VampEffect.cpp
6 
7  Chris Cannam, with heavy borrowing from LadspaEffect.cpp
8 
9  Vamp is an audio analysis and feature extraction plugin API.
10  http://www.vamp-plugins.org/
11 
12 **********************************************************************/
13 
14 
15 
16 #if defined(USE_VAMP)
17 #include "VampEffect.h"
18 
19 #include <vamp-hostsdk/Plugin.h>
20 #include <vamp-hostsdk/PluginChannelAdapter.h>
21 #include <vamp-hostsdk/PluginInputDomainAdapter.h>
22 
23 #include <wx/wxprec.h>
24 #include <wx/button.h>
25 #include <wx/checkbox.h>
26 #include <wx/choice.h>
27 #include <wx/combobox.h>
28 #include <wx/sizer.h>
29 #include <wx/slider.h>
30 #include <wx/statbox.h>
31 #include <wx/stattext.h>
32 #include <wx/textctrl.h>
33 #include <wx/tokenzr.h>
34 #include <wx/intl.h>
35 #include <wx/scrolwin.h>
36 #include <wx/version.h>
37 
38 
39 #include "../../ShuttleGui.h"
40 #include "../../widgets/valnum.h"
41 #include "../../widgets/AudacityMessageBox.h"
42 
43 #include "../../LabelTrack.h"
44 #include "../../WaveTrack.h"
45 
46 enum
47 {
48  ID_Program = 10000,
49  ID_Sliders = 11000,
50  ID_Choices = 12000,
51  ID_Texts = 13000,
52  ID_Toggles = 14000,
53 };
54 
56 //
57 // VampEffect
58 //
60 
61 BEGIN_EVENT_TABLE(VampEffect, wxEvtHandler)
62  EVT_SLIDER(wxID_ANY, VampEffect::OnSlider)
63  EVT_TEXT(wxID_ANY, VampEffect::OnTextCtrl)
64  EVT_CHECKBOX(wxID_ANY, VampEffect::OnCheckBox)
65  EVT_CHOICE(wxID_ANY, VampEffect::OnChoice)
67 
68 VampEffect::VampEffect(std::unique_ptr<Vamp::Plugin> &&plugin,
69  const PluginPath & path,
70  int output,
71  bool hasParameters)
72 : mPlugin(std::move(plugin)),
73  mPath(path),
74  mOutput(output),
75  mHasParameters(hasParameters),
76  mRate(0)
77 {
78  mKey = mPath.BeforeLast(wxT('/')).ToUTF8();
79  mName = mPath.AfterLast(wxT('/'));
80 }
81 
83 {
84 }
85 
86 // ============================================================================
87 // ComponentInterface implementation
88 // ============================================================================
89 
91 {
92  return mPath;
93 }
94 
96 {
97  return mName;
98 }
99 
101 {
102  return { wxString::FromUTF8(mPlugin->getMaker().c_str()) };
103 }
104 
106 {
107  return wxString::Format(wxT("%d"), mPlugin->getPluginVersion());
108 }
109 
111 {
112  return Verbatim(
113  wxString::FromUTF8(mPlugin->getCopyright().c_str()) );
114 }
115 
116 // ============================================================================
117 // EffectDefinitionInterface implementation
118 // ============================================================================
119 
121 {
122  return EffectTypeAnalyze;
123 }
124 
126 {
127  return VAMPEFFECTS_FAMILY;
128 }
129 
131 {
132  return mHasParameters;
133 }
134 
136 {
137  return false;
138 }
139 
140 
141 // EffectClientInterface implementation
142 
144 {
145  return mPlugin->getMaxChannelCount();
146 }
147 
149 {
150  for (size_t p = 0, paramCount = mParameters.size(); p < paramCount; p++)
151  {
152  wxString key = wxString::FromUTF8(mParameters[p].identifier.c_str());
153  float value = mPlugin->getParameter(mParameters[p].identifier);
154  float lower = mParameters[p].minValue;
155  float upper = mParameters[p].maxValue;
156 
157  if (mParameters[p].isQuantized &&
158  mParameters[p].quantizeStep == 1.0 &&
159  lower == 0.0 &&
160  upper == 1.0)
161  {
162  bool val = value > 0.5;
163 
164  parms.Write(key, val);
165  }
166  else if (mParameters[p].isQuantized &&
167  mParameters[p].quantizeStep == 1.0 &&
168  !mParameters[p].valueNames.empty())
169  {
170  std::vector<EnumValueSymbol> choices;
171  int val = 0;
172 
173  for (size_t i = 0, choiceCount = mParameters[p].valueNames.size(); i < choiceCount; i++)
174  {
175  wxString choice = wxString::FromUTF8(mParameters[p].valueNames[i].c_str());
176  if (size_t(value - mParameters[p].minValue + 0.5) == i)
177  {
178  val = i;
179  }
180  choices.push_back(choice);
181  }
182 
183  parms.WriteEnum(key, val, choices.data(), choices.size());
184  }
185  else
186  {
187  parms.Write(key, value);
188  }
189  }
190 
191  return true;
192 }
193 
195 {
196  // First pass verifies values
197  for (size_t p = 0, paramCount = mParameters.size(); p < paramCount; p++)
198  {
199  wxString key = wxString::FromUTF8(mParameters[p].identifier.c_str());
200  float lower = mParameters[p].minValue;
201  float upper = mParameters[p].maxValue;
202  bool good = false;
203 
204  if (mParameters[p].isQuantized &&
205  mParameters[p].quantizeStep == 1.0 &&
206  lower == 0.0 &&
207  upper == 1.0)
208  {
209  bool val;
210 
211  good = parms.Read(key, &val);
212  }
213  else if (mParameters[p].isQuantized &&
214  mParameters[p].quantizeStep == 1.0 &&
215  !mParameters[p].valueNames.empty())
216  {
217  std::vector<EnumValueSymbol> choices;
218  int val;
219 
220  for (size_t i = 0, choiceCount = mParameters[p].valueNames.size(); i < choiceCount; i++)
221  {
222  wxString choice = wxString::FromUTF8(mParameters[p].valueNames[i].c_str());
223  choices.push_back(choice);
224  }
225 
226  good = parms.ReadEnum(key, &val, choices.data(), choices.size()) && val != wxNOT_FOUND;
227  }
228  else
229  {
230  double val;
231 
232  good = parms.Read(key, &val) && val >= lower && val <= upper;
233  }
234 
235  if (!good)
236  {
237  return false;
238  }
239  }
240 
241  // Second pass sets the variables
242  for (size_t p = 0, paramCount = mParameters.size(); p < paramCount; p++)
243  {
244  wxString key = wxString::FromUTF8(mParameters[p].identifier.c_str());
245  float lower = mParameters[p].minValue;
246  float upper = mParameters[p].maxValue;
247 
248  if (mParameters[p].isQuantized &&
249  mParameters[p].quantizeStep == 1.0 &&
250  lower == 0.0 &&
251  upper == 1.0)
252  {
253  bool val;
254 
255  parms.Read(key, &val);
256 
257  mPlugin->setParameter(mParameters[p].identifier, val ? upper : lower);
258  }
259  else if (mParameters[p].isQuantized &&
260  mParameters[p].quantizeStep == 1.0 &&
261  !mParameters[p].valueNames.empty())
262  {
263  std::vector<EnumValueSymbol> choices;
264  int val = 0;
265 
266  for (size_t i = 0, choiceCount = mParameters[p].valueNames.size(); i < choiceCount; i++)
267  {
268  wxString choice = wxString::FromUTF8(mParameters[p].valueNames[i].c_str());
269  choices.push_back(choice);
270  }
271 
272  parms.ReadEnum(key, &val, choices.data(), choices.size());
273 
274  mPlugin->setParameter(mParameters[p].identifier, (float) val);
275  }
276  else
277  {
278  double val;
279 
280  parms.Read(key, &val);
281 
282  if (mParameters[p].isQuantized)
283  {
284  float qs = mParameters[p].quantizeStep;
285 
286  if (qs != 0.0)
287  {
288  val = (int)((val - lower) / qs + 0.5) * qs + lower;
289  }
290  }
291 
292  mPlugin->setParameter(mParameters[p].identifier, val);
293  }
294  }
295 
296  return true;
297 }
298 
300 {
301  mRate = 0.0;
302 
303  // PRL: this loop checked that channels of a track have the same rate,
304  // but there was no check that all tracks have one rate, and only the first
305  // is remembered in mRate. Is that correct?
306 
307  for (auto leader : inputTracks()->Leaders<const WaveTrack>()) {
308  auto channelGroup = TrackList::Channels( leader );
309  auto rate = (*channelGroup.first++) -> GetRate();
310  for(auto channel : channelGroup) {
311  if (rate != channel->GetRate())
312  // PRL: Track rate might not match individual clip rates.
313  // So is this check not adequate?
314  {
315  // TODO: more-than-two-channels-message
317  XO(
318 "Sorry, Vamp Plug-ins cannot be run on stereo tracks where the individual channels of the track do not match.") );
319  return false;
320  }
321  }
322  if (mRate == 0.0)
323  mRate = rate;
324  }
325 
326  if (mRate <= 0.0)
327  {
329  }
330 
331  // The plugin must be reloaded to allow changing parameters
332 
333  Vamp::HostExt::PluginLoader *loader = Vamp::HostExt::PluginLoader::getInstance();
334  mPlugin.reset(loader->loadPlugin(mKey, mRate, Vamp::HostExt::PluginLoader::ADAPT_ALL));
335  if (!mPlugin)
336  {
337  Effect::MessageBox( XO("Sorry, failed to load Vamp Plug-in.") );
338  return false;
339  }
340 
341  return true;
342 }
343 
345 {
346  if (!mPlugin)
347  {
348  return false;
349  }
350 
351  int count = 0;
352 
353  bool multiple = false;
354  unsigned prevTrackChannels = 0;
355 
356  if (GetNumWaveGroups() > 1)
357  {
358  // if there is another track beyond this one and any linked one,
359  // then we're processing more than one track. That means we
360  // should use the originating track name in each NEW label
361  // track's name, to make clear which is which
362  multiple = true;
363  }
364 
365  std::vector<std::shared_ptr<Effect::AddedAnalysisTrack>> addedTracks;
366 
367  for (auto leader : inputTracks()->Leaders<const WaveTrack>())
368  {
369  auto channelGroup = TrackList::Channels(leader);
370  auto left = *channelGroup.first++;
371 
372  unsigned channels = 1;
373 
374  // channelGroup now contains all but the first channel
375  const WaveTrack *right =
376  channelGroup.size() ? *channelGroup.first++ : nullptr;
377  if (right)
378  channels = 2;
379 
380  sampleCount start = 0;
381  sampleCount len = 0;
382  GetBounds(*left, right, &start, &len);
383 
384  // TODO: more-than-two-channels
385 
386  size_t step = mPlugin->getPreferredStepSize();
387  size_t block = mPlugin->getPreferredBlockSize();
388 
389  bool initialiseRequired = true;
390 
391  if (block == 0)
392  {
393  if (step != 0)
394  {
395  block = step;
396  }
397  else
398  {
399  block = 1024;
400  }
401  }
402 
403  if (step == 0)
404  {
405  step = block;
406  }
407 
408  if (prevTrackChannels > 0)
409  {
410  // Plugin has already been initialised, so if the number of
411  // channels remains the same, we only need to do a reset.
412  // Otherwise we need to re-construct the whole plugin,
413  // because a Vamp plugin can't be re-initialised.
414  if (prevTrackChannels == channels)
415  {
416  mPlugin->reset();
417  initialiseRequired = false;
418  }
419  else
420  {
422  Init();
423  }
424  }
425 
426  if (initialiseRequired)
427  {
428  if (!mPlugin->initialise(channels, step, block))
429  {
431  XO("Sorry, Vamp Plug-in failed to initialize.") );
432  return false;
433  }
434  }
435 
436  const auto effectName = GetSymbol().Translation();
437  addedTracks.push_back(AddAnalysisTrack(
438  multiple
439  ? wxString::Format( _("%s: %s"), left->GetName(), effectName )
440  : effectName
441  ));
442  LabelTrack *ltrack = addedTracks.back()->get();
443 
444  FloatBuffers data{ channels, block };
445 
446  auto originalLen = len;
447 
448  auto pos = start;
449 
450  while (len != 0)
451  {
452  const auto request = limitSampleBufferSize( block, len );
453 
454  if (left)
455  {
456  left->Get((samplePtr)data[0].get(), floatSample, pos, request);
457  }
458 
459  if (right)
460  {
461  right->Get((samplePtr)data[1].get(), floatSample, pos, request);
462  }
463 
464  if (request < block)
465  {
466  for (unsigned int c = 0; c < channels; ++c)
467  {
468  for (decltype(block) i = request; i < block; ++i)
469  {
470  data[c][i] = 0.f;
471  }
472  }
473  }
474 
475  // UNSAFE_SAMPLE_COUNT_TRUNCATION
476  // Truncation in case of very long tracks!
477  Vamp::RealTime timestamp = Vamp::RealTime::frame2RealTime(
478  long( pos.as_long_long() ),
479  (int)(mRate + 0.5)
480  );
481 
482  Vamp::Plugin::FeatureSet features = mPlugin->process(
483  reinterpret_cast< float** >( data.get() ), timestamp);
484  AddFeatures(ltrack, features);
485 
486  if (len > (int)step)
487  {
488  len -= step;
489  }
490  else
491  {
492  len = 0;
493  }
494 
495  pos += step;
496 
497  if (channels > 1)
498  {
499  if (TrackGroupProgress(count,
500  (pos - start).as_double() /
501  originalLen.as_double() ))
502  {
503  return false;
504  }
505  }
506  else
507  {
508  if (TrackProgress(count,
509  (pos - start).as_double() /
510  originalLen.as_double() ))
511  {
512  return false;
513  }
514  }
515  }
516 
517  Vamp::Plugin::FeatureSet features = mPlugin->getRemainingFeatures();
518  AddFeatures(ltrack, features);
519 
520  prevTrackChannels = channels;
521  }
522 
523  // All completed without cancellation, so commit the addition of tracks now
524  for (auto &addedTrack : addedTracks)
525  addedTrack->Commit();
526 
527  return true;
528 }
529 
531 {
532  mPlugin.reset();
533 }
534 
536 {
537  Vamp::Plugin::ProgramList programs = mPlugin->getPrograms();
538 
539  mParameters = mPlugin->getParameterDescriptors();
540 
541  auto count = mParameters.size();
542 
543  mToggles.reinit( count );
544  mSliders.reinit( count );
545  mFields.reinit( count );
546  mLabels.reinit( count );
547  mChoices.reinit( count );
548  mValues.reinit( count );
549 
550  wxScrolledWindow *scroller = S.Style(wxVSCROLL | wxTAB_TRAVERSAL)
551  .StartScroller(2);
552  {
553  S.StartStatic(XO("Plugin Settings"));
554  {
555  S.StartMultiColumn(5, wxEXPAND);
556  {
557  S.SetStretchyCol(3);
558 
559  if (!programs.empty())
560  {
561  S.AddPrompt(XXO("Program"));
562 
563  S.Id(ID_Program);
564  mProgram = S.Name(XO("Program"))
565  .MinSize( { -1, -1 } )
566  .Position(wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL)
567  .AddChoice( {},
568  [&]{
569  TranslatableStrings choices;
570  for (const auto &program : programs)
571  choices.push_back(
572  Verbatim(wxString::FromUTF8(program.c_str())));
573  return choices;
574  }(),
575  Verbatim( wxString::FromUTF8(mPlugin->getCurrentProgram().c_str()) )
576  );
577 
578  S.AddSpace(1, 1);
579  S.AddSpace(1, 1);
580  S.AddSpace(1, 1);
581  }
582 
583  for (size_t p = 0; p < count; p++)
584  {
585  wxString tip = wxString::FromUTF8(mParameters[p].description.c_str());
586  wxString unit = wxString::FromUTF8(mParameters[p].unit.c_str());
587 
588  float value = mPlugin->getParameter(mParameters[p].identifier);
589 
590  mToggles[p] = NULL;
591  mChoices[p] = NULL;
592  mSliders[p] = NULL;
593  mFields[p] = NULL;
594  mValues[p] = 0.0;
595 
596  wxString labelText = wxString::FromUTF8(mParameters[p].name.c_str());
597  if (!unit.empty())
598  {
599  labelText += wxT(" (") + unit + wxT(")");
600  }
601  /* i18n-hint: An item name introducing a value, which is not part of the string but
602  appears in a following text box window; translate with appropriate punctuation */
603  S.AddPrompt(XXO("%s:").Format( labelText ));
604 
605  if (mParameters[p].isQuantized &&
606  mParameters[p].quantizeStep == 1.0 &&
607  mParameters[p].minValue == 0.0 &&
608  mParameters[p].maxValue == 1.0)
609  {
610  S.Id(ID_Toggles + p);
611  mToggles[p] = S.ToolTip( Verbatim( tip ) )
612  .Name( Verbatim( labelText ) )
613  .Position(wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL)
614  .AddCheckBox( {},
615  value > 0.5 );
616 
617  S.AddSpace(1, 1);
618  S.AddSpace(1, 1);
619  S.AddSpace(1, 1);
620 
621  }
622  else if (mParameters[p].isQuantized &&
623  mParameters[p].quantizeStep == 1.0 &&
624  !mParameters[p].valueNames.empty())
625  {
626  TranslatableStrings choices;
627  int selected = -1;
628 
629  for (size_t i = 0, cnt = mParameters[p].valueNames.size(); i < cnt; i++)
630  {
631  wxString choice = wxString::FromUTF8(mParameters[p].valueNames[i].c_str());
632  if (size_t(value - mParameters[p].minValue + 0.5) == i)
633  {
634  selected = i;
635  }
636  choices.push_back( Verbatim( choice ) );
637  }
638 
639  S.Id(ID_Choices + p);
640  mChoices[p] = S.ToolTip( Verbatim( tip ) )
641  .Name( Verbatim( labelText ) )
642  .Position(wxEXPAND | wxALIGN_CENTER_VERTICAL | wxALL)
643  .MinSize( { -1, -1 } )
644  .AddChoice( {}, choices, selected );
645 
646  S.AddSpace(1, 1);
647  S.AddSpace(1, 1);
648  S.AddSpace(1, 1);
649  }
650  else
651  {
652  mValues[p] = value;
653 
654  float range = mParameters[p].maxValue - mParameters[p].minValue;
655 
656  S.Id(ID_Texts + p);
657  mFields[p] = S.ToolTip( Verbatim( tip ) )
658  .Name( Verbatim( labelText ) )
659  .Position(wxALIGN_CENTER_VERTICAL | wxALL)
660  .Validator<FloatingPointValidator<float>>(
661  6, &mValues[p],
662  (range < 10
663  ? NumValidatorStyle::THREE_TRAILING_ZEROES
664  : range < 100
665  ? NumValidatorStyle::TWO_TRAILING_ZEROES
666  : NumValidatorStyle::ONE_TRAILING_ZERO),
667  mParameters[p].minValue, mParameters[p].maxValue)
668  .AddTextBox( {}, wxT(""), 12);
669 
670  wxString str = Internat::ToDisplayString(mParameters[p].minValue);
671  S.AddPrompt( Verbatim( str ) );
672 
673  S.Id(ID_Sliders + p);
674  mSliders[p] = S.ToolTip( Verbatim( tip ) )
675  .Name( Verbatim( labelText ) )
676  .Style(wxSL_HORIZONTAL)
677  .MinSize( { 150, -1 } )
678  .AddSlider( {}, 0, 1000, 0);
679 
680  str = Internat::ToDisplayString(mParameters[p].maxValue);
681  S.AddUnits( Verbatim( str ) );
682  }
683  }
684  }
685  S.EndMultiColumn();
686  }
687  S.EndStatic();
688  }
689  S.EndScroller();
690 
691  scroller->SetScrollRate(0, 20);
692 
693  return;
694 }
695 
697 {
698  if (!mUIParent->TransferDataToWindow())
699  {
700  return false;
701  }
702 
704 
705  return true;
706 }
707 
709 {
710  if (!mUIParent->Validate() || !mUIParent->TransferDataFromWindow())
711  {
712  return false;
713  }
714 
715  return true;
716 }
717 
718 // VampEffect implementation
719 
721  Vamp::Plugin::FeatureSet &features)
722 {
723  for (Vamp::Plugin::FeatureList::iterator fli = features[mOutput].begin();
724  fli != features[mOutput].end(); ++fli)
725  {
726  Vamp::RealTime ftime0 = fli->timestamp;
727  double ltime0 = ftime0.sec + (double(ftime0.nsec) / 1000000000.0);
728 
729  Vamp::RealTime ftime1 = ftime0;
730  if (fli->hasDuration) ftime1 = ftime0 + fli->duration;
731  double ltime1 = ftime1.sec + (double(ftime1.nsec) / 1000000000.0);
732 
733  wxString label = LAT1CTOWX(fli->label.c_str());
734  if (label == wxString())
735  {
736  if (fli->values.empty())
737  {
738  label = wxString::Format(LAT1CTOWX("%.3f"), ltime0);
739  }
740  else
741  {
742  label = wxString::Format(LAT1CTOWX("%.3f"), *fli->values.begin());
743  }
744  }
745 
746  ltrack->AddLabel(SelectedRegion(ltime0, ltime1), label);
747  }
748 }
749 
751 {
752  for (size_t p = 0, cnt = mParameters.size(); p < cnt; p++)
753  {
754  float value = mPlugin->getParameter(mParameters[p].identifier);
755 
756  if (mParameters[p].isQuantized &&
757  mParameters[p].quantizeStep == 1.0 &&
758  mParameters[p].minValue == 0.0 &&
759  mParameters[p].maxValue == 1.0)
760  {
761  mToggles[p]->SetValue(value > 0.5);
762  }
763  else if (mParameters[p].isQuantized &&
764  mParameters[p].quantizeStep == 1.0 &&
765  !mParameters[p].valueNames.empty())
766  {
767  mChoices[p]->SetSelection(size_t(value - mParameters[p].minValue + 0.5));
768  }
769  else
770  {
771  mValues[p] = value;
772  mFields[p]->GetValidator()->TransferToWindow();
773 
774  float lower = mParameters[p].minValue;
775  float upper = mParameters[p].maxValue;
776  float range = upper - lower;
777 
778  if (mParameters[p].isQuantized)
779  {
780  float qs = mParameters[p].quantizeStep;
781 
782  if (qs != 0.0)
783  {
784  value = (int)((value - lower) / qs + 0.5) * qs + lower;
785  }
786  }
787 
788  mSliders[p]->SetValue((int)(((value - lower) / range) * 1000.0 + 0.5));
789  }
790  }
791 }
792 
793 void VampEffect::OnCheckBox(wxCommandEvent &event)
794 {
795  int p = event.GetId() - ID_Toggles;
796 
797  mPlugin->setParameter(mParameters[p].identifier, mToggles[p]->GetValue());
798 }
799 
800 void VampEffect::OnChoice(wxCommandEvent & evt)
801 {
802  int p = evt.GetId();
803 
804  // special value for programs
805  if (p == ID_Program)
806  {
807  Vamp::Plugin::ProgramList programs = mPlugin->getPrograms();
808  mPlugin->selectProgram(programs[evt.GetInt()]);
810  return;
811  }
812 
813  mPlugin->setParameter(mParameters[p - ID_Choices].identifier, evt.GetInt());
814 }
815 
816 void VampEffect::OnSlider(wxCommandEvent & evt)
817 {
818  int p = evt.GetId() - ID_Sliders;
819 
820  float lower = mParameters[p].minValue;
821  float upper = mParameters[p].maxValue;
822  float range = upper - lower;
823  float val = (evt.GetInt() / 1000.0) * range;
824 
825  if (mParameters[p].isQuantized)
826  {
827  float qs = mParameters[p].quantizeStep;
828 
829  if (qs != 0.0)
830  {
831  val = (int)(val / qs + 0.5) * qs;
832  }
833  }
834 
835  val += lower;
836 
837  mValues[p] = val;
838  mFields[p]->GetValidator()->TransferToWindow();
839 
840  mPlugin->setParameter(mParameters[p].identifier, val);
841 }
842 
843 void VampEffect::OnTextCtrl(wxCommandEvent & evt)
844 {
845  int p = evt.GetId() - ID_Texts;
846 
847  mFields[p]->GetValidator()->TransferFromWindow();
848 
849  float lower = mParameters[p].minValue;
850  float upper = mParameters[p].maxValue;
851  float range = upper - lower;
852  float val = mValues[p];
853 
854  if (mParameters[p].isQuantized)
855  {
856  float qs = mParameters[p].quantizeStep;
857 
858  if (qs != 0.0)
859  {
860  val = (int)((val - lower) / qs + 0.5) * qs + lower;
861  }
862  }
863 
864  mPlugin->setParameter(mParameters[p].identifier, val);
865 
866  mSliders[p]->SetValue((int)(((val - lower) / range) * 1000.0 + 0.5));
867 }
868 
869 #endif
TranslatableString
Definition: Types.h:290
CommandParameters
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
Definition: EffectAutomationParameters.h:67
VampEffect::OnChoice
void OnChoice(wxCommandEvent &evt)
Definition: VampEffect.cpp:800
ShuttleGuiBase::AddChoice
wxChoice * AddChoice(const TranslatableString &Prompt, const TranslatableStrings &choices, int Selected=-1)
Definition: ShuttleGui.cpp:391
VampEffect::~VampEffect
virtual ~VampEffect()
Definition: VampEffect.cpp:82
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:68
CommandParameters::WriteEnum
bool WriteEnum(const wxString &key, int value, const EnumValueSymbol choices[], size_t nChoices)
Definition: EffectAutomationParameters.h:203
ShuttleGuiBase::AddCheckBox
wxCheckBox * AddCheckBox(const TranslatableString &Prompt, bool Selected)
Definition: ShuttleGui.cpp:302
VampEffect::mPath
PluginPath mPath
Definition: VampEffect.h:87
VampEffect::TransferDataToWindow
bool TransferDataToWindow() override
Definition: VampEffect.cpp:696
VampEffect::mKey
Vamp::HostExt::PluginLoader::PluginKey mKey
Definition: VampEffect.h:91
VampEffect::GetDescription
TranslatableString GetDescription() override
Definition: VampEffect.cpp:110
ComponentInterfaceSymbol::Translation
const wxString Translation() const
Definition: ComponentInterface.h:91
VampEffect::TransferDataFromWindow
bool TransferDataFromWindow() override
Definition: VampEffect.cpp:708
VampEffect::Init
bool Init() override
Definition: VampEffect.cpp:299
ID_Texts
@ ID_Texts
Definition: VampEffect.cpp:51
Effect::MessageBox
int MessageBox(const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
Definition: Effect.cpp:2478
ShuttleGui::ToolTip
ShuttleGui & ToolTip(const TranslatableString &tip)
Definition: ShuttleGui.h:663
VampEffect::IsInteractive
bool IsInteractive() override
Definition: VampEffect.cpp:130
VampEffect::Process
bool Process() override
Definition: VampEffect.cpp:344
TrackList::Channels
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1467
Format
Abstract base class used in importing a file.
VampEffect::OnTextCtrl
void OnTextCtrl(wxCommandEvent &evt)
Definition: VampEffect.cpp:843
ArrayOf::reinit
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:112
VampEffect::GetPath
PluginPath GetPath() override
Definition: VampEffect.cpp:90
ID_Toggles
@ ID_Toggles
Definition: VampEffect.cpp:52
VampEffect::mOutput
int mOutput
Definition: VampEffect.h:88
ShuttleGui::AddSpace
wxSizerItem * AddSpace(int width, int height, int prop=0)
Definition: ShuttleGui.cpp:2421
ShuttleGui::MinSize
ShuttleGui & MinSize()
Definition: ShuttleGui.h:740
XO
#define XO(s)
Definition: Internat.h:32
ClientData::Site::size
size_t size() const
How many attachment pointers are in the Site.
Definition: ClientData.h:251
LabelTrack
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:88
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1212
VampEffect::mName
wxString mName
Definition: VampEffect.h:92
floatSample
@ floatSample
Definition: Types.h:722
VampEffect::mToggles
ArrayOf< wxCheckBox * > mToggles
Definition: VampEffect.h:105
VampEffect::GetType
EffectType GetType() override
Definition: VampEffect.cpp:120
VampEffect::mValues
Floats mValues
Definition: VampEffect.h:100
VampEffect::mParameters
Vamp::Plugin::ParameterList mParameters
Definition: VampEffect.h:98
VampEffect::mChoices
ArrayOf< wxChoice * > mChoices
Definition: VampEffect.h:106
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterface.h:60
Effect::AddAnalysisTrack
std::shared_ptr< AddedAnalysisTrack > AddAnalysisTrack(const wxString &name=wxString())
Definition: Effect.cpp:2134
ShuttleGui::Id
ShuttleGui & Id(int id)
Definition: ShuttleGui.cpp:2248
LabelTrack::AddLabel
int AddLabel(const SelectedRegion &region, const wxString &title)
Definition: LabelTrack.cpp:930
WaveTrack::Get
bool Get(samplePtr buffer, sampleFormat format, sampleCount start, size_t len, fillFormat fill=fillZero, bool mayThrow=true, sampleCount *pNumWithinClips=nullptr) const
Definition: WaveTrack.cpp:1895
limitSampleBufferSize
size_t limitSampleBufferSize(size_t bufferSize, sampleCount limit)
Definition: Types.h:706
VampEffect::mPlugin
std::unique_ptr< Vamp::Plugin > mPlugin
Definition: VampEffect.h:86
ShuttleGuiBase::EndScroller
void EndScroller()
Definition: ShuttleGui.cpp:964
ID_Program
@ ID_Program
Definition: VampEffect.cpp:48
CommandParameters::ReadEnum
bool ReadEnum(const wxString &key, int *pi, const EnumValueSymbol choices[], size_t nChoices, const ObsoleteMap obsoletes[]=nullptr, size_t nObsoletes=0) const
Definition: EffectAutomationParameters.h:166
ShuttleGui::Style
ShuttleGui & Style(long iStyle)
Definition: ShuttleGui.h:734
Effect::mProjectRate
double mProjectRate
Definition: Effect.h:457
TranslatableStrings
std::vector< TranslatableString > TranslatableStrings
Definition: Types.h:555
VampEffect::AddFeatures
void AddFeatures(LabelTrack *track, Vamp::Plugin::FeatureSet &features)
Definition: VampEffect.cpp:720
VampEffect::UpdateFromPlugin
void UpdateFromPlugin()
Definition: VampEffect.cpp:750
samplePtr
char * samplePtr
Definition: Types.h:737
XXO
#define XXO(s)
Definition: Internat.h:45
ShuttleGuiBase::StartScroller
wxScrolledWindow * StartScroller(int iStyle=0)
Definition: ShuttleGui.cpp:931
Effect::inputTracks
const TrackList * inputTracks() const
Definition: Effect.h:462
VampEffect::SetAutomationParameters
bool SetAutomationParameters(CommandParameters &parms) override
Definition: VampEffect.cpp:194
ArraysOf< float >
VampEffect::GetVendor
VendorSymbol GetVendor() override
Definition: VampEffect.cpp:100
label
TranslatableString label
Definition: Tags.cpp:755
ShuttleGuiBase::AddTextBox
wxTextCtrl * AddTextBox(const TranslatableString &Caption, const wxString &Value, const int nChars)
Definition: ShuttleGui.cpp:631
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1203
VampEffect::OnSlider
void OnSlider(wxCommandEvent &evt)
Definition: VampEffect.cpp:816
VampEffect::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: VampEffect.cpp:535
ShuttleGuiBase::AddUnits
void AddUnits(const TranslatableString &Prompt, int wrapWidth=0)
Left aligned text string.
Definition: ShuttleGui.cpp:256
VampEffect::End
void End() override
Definition: VampEffect.cpp:530
name
const TranslatableString name
Definition: Distortion.cpp:98
VampEffect::IsDefault
bool IsDefault() override
Definition: VampEffect.cpp:135
PluginPath
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
Definition: Types.h:257
VampEffect::GetAutomationParameters
bool GetAutomationParameters(CommandParameters &parms) override
Definition: VampEffect.cpp:148
ShuttleGui::Validator
ShuttleGui & Validator(const Factory &f)
Definition: ShuttleGui.h:685
VampEffect::mLabels
ArrayOf< wxStaticText * > mLabels
Definition: VampEffect.h:104
VampEffect::OnCheckBox
void OnCheckBox(wxCommandEvent &evt)
Definition: VampEffect.cpp:793
VAMPEFFECTS_FAMILY
#define VAMPEFFECTS_FAMILY
Definition: VampEffect.h:32
VampEffect::GetSymbol
ComponentInterfaceSymbol GetSymbol() override
Definition: VampEffect.cpp:95
VampEffect.h
VampEffect::mSliders
ArrayOf< wxSlider * > mSliders
Definition: VampEffect.h:102
VampEffect::mRate
double mRate
Definition: VampEffect.h:93
VampEffect::GetAudioInCount
unsigned GetAudioInCount() override
Definition: VampEffect.cpp:143
ShuttleGuiBase::StartStatic
wxStaticBox * StartStatic(const TranslatableString &Str, int iProp=0)
Definition: ShuttleGui.cpp:886
LAT1CTOWX
#define LAT1CTOWX(X)
Definition: Internat.h:161
ShuttleGui::Name
ShuttleGui & Name(const TranslatableString &name)
Definition: ShuttleGui.h:670
Effect::GetNumWaveGroups
int GetNumWaveGroups()
Definition: Effect.h:345
key
static const AudacityProject::AttachedObjects::RegisteredFactory key
Definition: CommandManager.cpp:196
ShuttleGui::Position
ShuttleGui & Position(int flags)
Definition: ShuttleGui.h:719
VampEffect::mFields
ArrayOf< wxTextCtrl * > mFields
Definition: VampEffect.h:103
Effect::mUIParent
wxWindow * mUIParent
Definition: Effect.h:477
_
#define _(s)
Definition: Internat.h:76
sampleCount
Definition: Types.h:589
EffectTypeAnalyze
@ EffectTypeAnalyze
Definition: EffectInterface.h:60
Effect::GetBounds
void GetBounds(const WaveTrack &track, const WaveTrack *pRight, sampleCount *start, sampleCount *len)
Definition: Effect.cpp:2040
Verbatim
TranslatableString Verbatim(wxString str)
Definition: Types.h:581
VampEffect::mHasParameters
bool mHasParameters
Definition: VampEffect.h:89
ShuttleGuiBase::AddPrompt
void AddPrompt(const TranslatableString &Prompt, int wrapWidth=0)
Right aligned text string.
Definition: ShuttleGui.cpp:231
Internat::ToDisplayString
static wxString ToDisplayString(double numberToConvert, int digitsAfterDecimalPoint=-1)
Convert a number to a string, uses the user's locale's decimal separator.
Definition: Internat.cpp:166
ID_Sliders
@ ID_Sliders
Definition: VampEffect.cpp:49
VampEffect::GetVersion
wxString GetVersion() override
Definition: VampEffect.cpp:105
ShuttleGuiBase::EndStatic
void EndStatic()
Definition: ShuttleGui.cpp:915
EffectType
EffectType
Definition: EffectInterface.h:55
VampEffect::mProgram
wxChoice * mProgram
Definition: VampEffect.h:107
ShuttleGuiBase::SetStretchyCol
void SetStretchyCol(int i)
Used to modify an already placed FlexGridSizer to make a column stretchy.
Definition: ShuttleGui.cpp:195
Effect::TrackGroupProgress
bool TrackGroupProgress(int whichGroup, double frac, const TranslatableString &={})
Definition: Effect.cpp:2032
VampEffect::GetFamily
EffectFamilySymbol GetFamily() override
Definition: VampEffect.cpp:125
END_EVENT_TABLE
END_EVENT_TABLE()
VampEffect
Definition: VampEffect.h:35
Effect::TrackProgress
bool TrackProgress(int whichTrack, double frac, const TranslatableString &={})
Definition: Effect.cpp:2024
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:638
ID_Choices
@ ID_Choices
Definition: VampEffect.cpp:50
SelectedRegion
Defines a selected portion of a project.
Definition: SelectedRegion.h:38