Krotos Modules 3
Loading...
Searching...
No Matches
KwidgetGUI_Reformer.cpp
Go to the documentation of this file.
1namespace krotos
2{
6 // This had to be renamed from LevelRND to differentiate it from the KwidgetGUI_CoreEngine equivalent
7 const String KwidgetGUI_Reformer::ComponentIds::SliderLevelRandId("ReformerLevelRND");
9 // This had to be renamed from PanRND to differentiate it from the KwidgetGUI_CoreEngine equivalent
10 const String KwidgetGUI_Reformer::ComponentIds::SliderPanRandId("ReformerPanRND");
31 const String KwidgetGUI_Reformer::ComponentIds::ButtonSampleBrowserId("SampleSelectDropdown");
39
40 const std::string KwidgetGUI_Reformer::analyticsEventClearedEngine{"analyticsEventClearedEngine"};
41 const std::string KwidgetGUI_Reformer::analyticsEventAddedSamplesEngine{"analyticsEventAddedSamplesEngine"};
42 const std::string KwidgetGUI_Reformer::analyticsEventRemovedEngine{"analyticsEventRemovedEngine"};
43
45 : KwidgetGUI(owner), m_soSound(sound), m_owner(owner), m_sampleBrowserButton(""),
46 m_removeEngineButton("", DrawableButton::ImageStretched), m_zoomInButton("", DrawableButton::ImageStretched),
47 m_zoomInButtonImage(
48 Drawable::createFromImageData(KrotosBinaryData::Plus_Icon_svg, KrotosBinaryData::Plus_Icon_svgSize)),
49 m_zoomInButtonImageHover(
50 Drawable::createFromImageData(KrotosBinaryData::Plus_Icon_svg, KrotosBinaryData::Plus_Icon_svgSize)),
51 m_zoomOutButton("", DrawableButton::ImageStretched),
52 m_zoomOutButtonImage(Drawable::createFromImageData(KrotosBinaryData::Minus_Icon_svg,
53 KrotosBinaryData::Minus_Icon_svgSize)),
54 m_zoomOutButtonImageHover(
55 Drawable::createFromImageData(KrotosBinaryData::Minus_Icon_svg, KrotosBinaryData::Minus_Icon_svgSize))
56 {
57 setComponentID("Reformer");
59 addAndMakeVisible(m_reformerNameLabel);
60 m_reformerNameLabel.setFont(Font(layout.modeFontSize).withExtraKerningFactor(layout.modeExtraKerning));
61 m_controlsTab.setOutline(0);
62
63 m_controlsTab.addTab("MAIN", findColour(TabbedComponent::backgroundColourId), &m_SynthesisControls, false);
64 m_controlsTab.addTab("RND", findColour(TabbedComponent::backgroundColourId), &m_randTab, false);
65 m_controlsTab.addTab("CONTROL", findColour(TabbedComponent::backgroundColourId), &m_controlTab, false);
66 m_controlsTab.addTab("ADSR", findColour(TabbedComponent::backgroundColourId), &m_AdsrControls, false);
67 m_controlsTab.addTab("ANALYSIS", findColour(TabbedComponent::backgroundColourId), &m_AnalysisControls, false);
68#if IS_DEVELOPMENT_BUILD
69 m_controlsTab.addTab("DISPLAY", findColour(TabbedComponent::backgroundColourId), &m_DisplayControls, false);
70#endif
71
72 // Loop through every tab button
73 for (int tabIndex = 0; tabIndex < m_controlsTab.getNumTabs(); tabIndex++)
74 {
75 const auto& tabButton = m_controlsTab.getTabbedButtonBar().getTabButton(tabIndex);
76 // Construct and set a unique ID for each button
77 tabButton->setComponentID("ReformerTab" + tabButton->getName());
78 }
79
80 addAndMakeVisible(m_controlsTab);
81
82 m_segmentationLabel.setText("Segmentation", dontSendNotification);
83 m_segmentationLabel.setJustificationType(Justification::left);
84 m_schemeLabel.setText("Scheme", dontSendNotification);
85 m_schemeLabel.setJustificationType(Justification::left);
86
87 m_AnalysisControls.addAndMakeVisible(m_segmentationLabel);
88 m_AnalysisControls.addAndMakeVisible(m_schemeLabel);
89
90 // Left panel
91 addAttachedComponent(m_Pan, Params::Pan);
92 addAttachedComponent(m_Level, Params::Level);
93 addAttachedComponent(m_PanRand, Params::PanRand);
94 addAttachedComponent(m_LevelRand, Params::LevelRand);
95
96 // Slider specific layout
97 m_Pan.getSlider().setSliderStyle(Slider::SliderStyle::LinearHorizontal);
101 m_Pan.setValueFormat("%.1f");
102
103 m_Level.getSlider().setSliderStyle(Slider::SliderStyle::LinearHorizontal);
108 m_Level.setValueFormat("%.1f");
109
110 m_LevelRand.getSlider().setSliderStyle(Slider::SliderStyle::LinearHorizontal);
115
116 m_PanRand.getSlider().setSliderStyle(Slider::SliderStyle::LinearHorizontal);
121
122 // Sliders
123 m_Start.getSlider().setTextValueSuffix(" % ");
124
134
136
137 m_Size.getSlider().setTextValueSuffix(" % ");
138
149
150 // Rand Sliders
151 addAttachedComponent(m_randTab, m_StartRand, Params::StartRand);
153 addAttachedComponent(m_randTab, m_SizeRand, Params::SizeRand);
155 addAttachedComponent(m_randTab, m_RateRand, Params::RateRand);
157 addAttachedComponent(m_randTab, m_DetuneRand, Params::PitchRand);
159 addAttachedComponent(m_randTab, m_WidthRand, Params::WidthRand);
161
162 // Extras Sliders
165 addAttachedComponent(m_controlTab, m_GrainMax, Params::GrainMax);
179
180 // Sliders for adjustung the graphical display
184
185 // Mute- Solo Text Buttons
188
189 // Segmentation select combobox
191 for (const auto& [itemId, itemText] : Kwidget_Reformer::SegmentationMethods)
192 {
194 m_segmentation.addItem(itemText, itemId + 1);
195 }
196 auto newValue = m_owner.getParameter(Kwidget_Reformer::Parameters::Segmentation)->getValue();
197 auto newItemId = static_cast<int>(newValue * (Kwidget_Reformer::MaxSegmentationMethods - 1));
198 m_segmentation.setSelectedId((int)newItemId + 1);
199 m_AnalysisControls.addAndMakeVisible(m_segmentation);
200 setCoefSliderLabels(newItemId);
201
202 m_segmentation.onChange = [this] {
203 auto newItemId = m_segmentation.getSelectedId() - 1;
204 auto newValue = newItemId / static_cast<float>(Kwidget_Reformer::MaxSegmentationMethods - 1);
205 m_owner.getParameter(Kwidget_Reformer::Parameters::Segmentation)->set(newValue);
206 setCoefSliderLabels(newItemId);
207 };
208
209 // Feature Extraction select combobox
211 for (const auto& [itemId, itemText] : Kwidget_Reformer::FeatureExtrMethods)
212 {
214 m_featureExtr.addItem(itemText, itemId + 1);
215 }
216 newValue = m_owner.getParameter(Kwidget_Reformer::Parameters::FeatureExtr)->getValue();
217 newItemId = static_cast<int>(newValue * (Kwidget_Reformer::MaxFeatureExtrMethods - 1));
218 m_featureExtr.setSelectedId((int)newItemId + 1);
219 m_AnalysisControls.addAndMakeVisible(m_featureExtr);
220
221 m_featureExtr.onChange = [this] {
222 auto newItemId = m_featureExtr.getSelectedId() - 1;
223 auto newValue = newItemId / static_cast<float>(Kwidget_Reformer::MaxFeatureExtrMethods - 1);
224 m_owner.getParameter(Kwidget_Reformer::Parameters::FeatureExtr)->set(newValue);
225 };
226
227 // Trigger select combobox - adds and makes visible
228 addAttachedComponent(m_trigger, Params::MIDIMode);
229
230 // Vehicle colours
231 m_Tracking.setDebugColour(Colours::sandybrown);
232
233 // Misc colours
234 m_Shape.setDebugColour(Colours::darkred);
235 m_GrainMax.setDebugColour(Colours::darkred);
236
237 addAndMakeVisible(m_clearButton);
238 addAndMakeVisible(m_tweakButton1);
239 addAndMakeVisible(m_tweakButton2);
240
241 // delete button
242 addAndMakeVisible(m_removeEngineButton);
243
244 m_removeEngineButton.setButtonText("X");
246 m_removeEngineButton.onClick = [&]() {
247 if (onDelete)
248 {
250 }
251 };
252
253 Kwidget_Reformer* owningKwidget = dynamic_cast<Kwidget_Reformer*>(&getOwner());
254
255 if (owningKwidget != nullptr)
256 {
257 if (!owningKwidget->isUCSEnabled())
258 {
259 m_tweakButton1.setEnabled(false);
260 m_tweakButton2.setEnabled(false);
261 }
262 }
263
264 addAndMakeVisible(m_muteButton);
265 addAndMakeVisible(m_soloButton);
266
267 m_defaultDeleteButton = Drawable::createFromImageData(KrotosBinaryData::remove_engine_icon_default_png,
268 KrotosBinaryData::remove_engine_icon_default_pngSize);
269
270 m_hoverDeleteButton = Drawable::createFromImageData(KrotosBinaryData::remove_engine_icon_hover_png,
271 KrotosBinaryData::remove_engine_icon_hover_pngSize);
272
273 // delete button
274 addAndMakeVisible(m_removeEngineButton);
275 m_removeEngineButton.toFront(true);
276 m_removeEngineButton.setImages(
277 /*normal*/ m_defaultDeleteButton.get(),
278 /* hover */ m_hoverDeleteButton.get(),
279 /* clicked */ m_hoverDeleteButton.get());
280
281 m_removeEngineButton.onClick = [&]() {
282 if (onDelete)
283 {
284 std::function<void(int)> removeEngineCallback = [this](int option) {
285 if (option == 0) // clicked remove
286 {
287 // Mixpanel analytics: removed engine
288 sendActionMessage(analyticsEventRemovedEngine);
289
290 // defer deletion to ensure the action message is sent and processed
291 MessageManager::callAsync([this]() {
292 auto ownerId = m_owner.getKwidgetID();
293 onDelete(ownerId);
294 });
295 }
296 };
297
300
301 AlertWindow::showAsync(MessageBoxOptions()
302 .withIconType(MessageBoxIconType::WarningIcon)
303 .withTitle("Removing Engine")
304 .withMessage("Are you sure you want to proceed with the\nremoval? This "
305 "action cannot be undone!")
306 .withButton("Cancel")
307 .withButton("Remove")
308 .withAssociatedComponent(this),
309 removeEngineCallback);
310 }
311 };
312
313 addAndMakeVisible(m_PopcornToggle);
315 addAndMakeVisible(m_ProximityToggle);
317 addAndMakeVisible(m_SALoopToggle);
318 addAndMakeVisible(m_NormaliseToggle);
319 addAndMakeVisible(m_AutoplayToggle);
320 addAndMakeVisible(m_QuenchToggle);
321
322#ifdef USE_LEGACY_GUI_FEATURES
323 addAndMakeVisible(m_RobinToggle);
324 addAndMakeVisible(m_AutoRateToggle);
325 addAndMakeVisible(m_PhaseLockToggle);
326 addAndMakeVisible(m_PhaseSyncToggle);
327#endif
328
329 m_clearButton.setButtonText("CLEAR");
330 m_clearButton.onClick = [this] { clearEngine(); };
331
332 // Mute Button
333 m_muteButton.setClickingTogglesState(true);
334 m_muteButton.setButtonText("M");
336
337 // Solo Button
338 m_soloButton.setClickingTogglesState(true);
339 m_soloButton.setButtonText("S");
341
342 // Toggle Switches
353
354 m_PopcornToggle.getButton().onClick = [this] {
355 auto toggleState = m_PopcornToggle.getButton().getToggleState();
356 if (toggleState)
357 {
358 m_ProximityToggle.getButton().setToggleState(false, NotificationType::dontSendNotification);
359 }
360 };
361
362 m_ProximityToggle.getButton().onClick = [this] {
363 auto toggleState = m_ProximityToggle.getButton().getToggleState();
364 if (toggleState)
365 {
366 m_PopcornToggle.getButton().setToggleState(false, NotificationType::dontSendNotification);
367 }
368 };
369
371 std::make_unique<krotos::WaveformViewerAndEditor>(Colour(152, 152, 152), false, true);
372 addAndMakeVisible(m_waveformViewerAndEditor.get());
374 m_waveformViewerAndEditor->setViewerDropText("DRAG & DROP HERE");
375 m_waveformViewerAndEditor->getWaveformViewer()->setDrawGrid(false);
376 m_waveformViewerAndEditor->getWaveformViewer()->setShowBorderOnDragHover(true);
377 m_waveformViewerAndEditor->getWaveformViewer()->setShowFileName(false);
378 m_waveformViewerAndEditor->getWaveformViewer()->setRegexFileFilter(
379 String("")); // Empty string - loads everything which is in the dragged folder
380 m_waveformViewerAndEditor->addListener(this);
381 // TODO: Implement waveform range selection state [KST-2198]
382 // m_waveformViewerAndEditor->getAreaSelectionComp()->setWaveformMode(AreaSelectionComp::WaveformMode::onlyStartLine);
383
385 jassert(m_samplesTree); // Must exist for sampler state to function!
386
388 m_waveformViewerAndEditor->setSelectionEnabled(false); // Reformer does not require segment selection
390
391 // start-point change
392 addParameterCallback(Parameters::Start, [this](float val) {
393 // if called from marquee
395 {
397 return;
398 }
399 else // if changed from slider
400 {
401 // repaint the viewer
402 m_waveformViewerAndEditor->setStartPosInPercentage(val * 0.01f);
403 }
404 });
405
406 // end-point change
407 addParameterCallback(Parameters::Size, [this](float val) {
408 // if called from the marquee
410 {
412 return;
413 }
414 else // if changed from the slider
415 {
416 auto startVal = getOwner().getParameter(Parameters::Start)->get();
417 if (val <= startVal)
418 val = startVal;
419 // repaint the viewer
420 // TODO: Implement waveform range selection state [KST-2198]
421 // m_waveformViewerAndEditor->setEndPosInPercentage(val * 0.01f);
422 }
423 });
424
425 // Sample Browser Dropdown Menu
426 m_sampleBrowserButton.getSampleCounter().setVisible(false);
427 m_sampleBrowserButton.getPreviousButton().setVisible(false);
428 m_sampleBrowserButton.getNextButton().setVisible(false);
429 addAndMakeVisible(m_sampleBrowserButton);
431 m_sampleBrowserButton.onClick = [&] {
432 OwnedArray<SampleBrowser::Sample> samplesToShow;
433 auto* sampler = m_soSound.getSampleEngine();
434 if (sampler)
435 {
437 }
438
439 int sampleItemCount = jlimit(0, layout.sampleBrowserMaxItemsToShow, samplesToShow.size());
440
441 enum item
442 {
443 Browser = -1,
444 Add = 1,
445 RemoveAll
446 };
447
448 auto browser = std::make_unique<SampleBrowser>(layout.sampleBrowserWidth,
449 layout.sampleBrowserItemHeight * sampleItemCount,
450 layout.sampleBrowserItemHeight, std::move(samplesToShow));
451
452 // KST-2413 temporarily disable sample mute,solo,delete buttons
453 browser->setSampleFunctionButtonsVisibility(/*isVisible*/ false);
454
455 PopupMenu menu;
456
457 menu.addCustomItem(item::Browser, std::move(browser));
458
459 menu.addItem(item::Add, "Add More Samples", true, false,
460 Drawable::createFromImageData(KrotosBinaryData::Add_Sample_Icon_svg,
461 KrotosBinaryData::Add_Sample_Icon_svgSize));
462 menu.addItem(item::RemoveAll, "Remove All Samples", true, false,
463 Drawable::createFromImageData(KrotosBinaryData::Remove_All_Samples_svg,
464 KrotosBinaryData::Remove_All_Samples_svgSize));
465
466 std::function<void(int)> menuCallback = [&](int itemResultID) {
467 switch (itemResultID)
468 {
469 case item::Add:
470 m_waveformViewerAndEditor->showFileChooser();
471 break;
472 case item::RemoveAll:
473 std::function<void(int)> removeCallback = [this,
474 target = WeakReference<Component>{this}](int option) {
475 if (target && option == 0)
476 {
477 clearEngine();
478
479 // Mixpanel: reformer clear all samples
480 sendActionMessage(analyticsEventClearedEngine);
481 }
482 };
484 440);
485 m_sampleBrowserButton.getProperties().set(
487 AlertWindow::showAsync(
488 MessageBoxOptions()
489 .withIconType(MessageBoxIconType::WarningIcon)
490 .withTitle("Sample Removal")
491 .withMessage("Are you sure you want to proceed with the\nremoval? This "
492 "action cannot be undone!")
493 .withButton("Cancel")
494 .withButton("Remove")
495 .withAssociatedComponent(&m_sampleBrowserButton),
496 removeCallback);
497 break;
498 }
499 };
500
501 menu.showMenuAsync(PopupMenu::Options{}
502 .withTargetComponent(m_sampleBrowserButton)
503 .withMinimumNumColumns(1)
504 .withStandardItemHeight(layout.sampleBrowserItemHeight),
505 menuCallback);
506 };
508
510 if (m_samplesTree->getSamples().size() == 0)
511 {
512 clearEngine();
513 }
514 }
515 /* End Reformer Constructor */
516
518 {
519 // Set zoom in/out button images and hover states
520 const Colour defaultIconColour(177, 177, 177);
521 const Colour hoverIconColour(217, 217, 217);
522 m_zoomInButtonImage->replaceColour(Colours::white, Colours::transparentWhite);
523 m_zoomOutButtonImage->replaceColour(Colours::white, Colours::transparentWhite);
524 m_zoomInButtonImageHover->replaceColour(defaultIconColour, hoverIconColour);
525 m_zoomInButtonImageHover->replaceColour(Colours::white, Colours::transparentWhite);
526 m_zoomOutButtonImageHover->replaceColour(defaultIconColour, hoverIconColour);
527 m_zoomOutButtonImageHover->replaceColour(Colours::white, Colours::transparentWhite);
530 m_zoomInButton.setButtonStyle(DrawableButton::ButtonStyle::ImageStretched);
531 m_zoomOutButton.setButtonStyle(DrawableButton::ButtonStyle::ImageStretched);
532 addAndMakeVisible(m_zoomInButton);
533 addAndMakeVisible(m_zoomOutButton);
534
539 m_zoomInButton.onClick = [this] { m_waveformViewerAndEditor->zoomIn(); };
540 m_zoomOutButton.onClick = [this] { m_waveformViewerAndEditor->zoomOut(); };
541
542 // set scroll bar colour and behaviour
543 m_waveformViewScrollbar.setRangeLimits(Range<double>(0.0, 1.0), NotificationType::dontSendNotification);
544 m_waveformViewScrollbar.setCurrentRange(
545 /*starting point*/ 0.0,
546 /*size*/ 1.0, NotificationType::dontSendNotification);
547 m_waveformViewScrollbar.setColour(ScrollBar::ColourIds::thumbColourId, Colour(74, 74, 74));
548 m_waveformViewScrollbar.addListener(this);
550 m_waveformViewScrollbar.setAutoHide(false);
551 addAndMakeVisible(m_waveformViewScrollbar);
552 }
553
555 {
556 m_waveformViewerAndEditor->clear(); // stop grain display
558 m_waveformViewerAndEditor->setViewerDropText("DRAG & DROP HERE");
560 m_waveformViewerAndEditor->copySegmentsToSelectors();
561 }
562
564 {
565 KrotosAudioBufferDSP::SegmentationMethod segmentation = static_cast<Segmentation>(segmentationId);
566
567 switch (segmentation)
568 {
569 case Segmentation::SegmentationNone:
570 m_Coeff0.getLabel().setText("Unused", NotificationType::dontSendNotification);
571 m_Coeff1.getLabel().setText("Unused", NotificationType::dontSendNotification);
572 m_Coeff2.getLabel().setText("Unused", NotificationType::dontSendNotification);
573 m_Coeff3.getLabel().setText("Unused", NotificationType::dontSendNotification);
574 m_Coeff4.getLabel().setText("Unused", NotificationType::dontSendNotification);
575 m_Coeff7.getLabel().setText("Unused", NotificationType::dontSendNotification);
576 break;
577 case Segmentation::STFT:
578 m_Coeff0.getLabel().setText("FrameSize", NotificationType::dontSendNotification);
579 m_Coeff1.getLabel().setText("HopSize", NotificationType::dontSendNotification);
580 m_Coeff2.getLabel().setText("Unused", NotificationType::dontSendNotification);
581 m_Coeff3.getLabel().setText("Unused", NotificationType::dontSendNotification);
582 m_Coeff4.getLabel().setText("Unused", NotificationType::dontSendNotification);
583 m_Coeff7.getLabel().setText("Unused", NotificationType::dontSendNotification);
584 break;
585 case Segmentation::EnvOnset:
586 m_Coeff0.getLabel().setText("Thresh", NotificationType::dontSendNotification);
587 m_Coeff1.getLabel().setText("Onset", NotificationType::dontSendNotification);
588 m_Coeff2.getLabel().setText("Decay", NotificationType::dontSendNotification);
589 m_Coeff3.getLabel().setText("Unused", NotificationType::dontSendNotification);
590 m_Coeff4.getLabel().setText("Unused", NotificationType::dontSendNotification);
591 m_Coeff7.getLabel().setText("Unused", NotificationType::dontSendNotification);
592 break;
593 case Segmentation::OverlapWindow:
594 m_Coeff0.getLabel().setText("Unused", NotificationType::dontSendNotification);
595 m_Coeff1.getLabel().setText("Unused", NotificationType::dontSendNotification);
596 m_Coeff2.getLabel().setText("Unused", NotificationType::dontSendNotification);
597 m_Coeff3.getLabel().setText("Unused", NotificationType::dontSendNotification);
598 m_Coeff4.getLabel().setText("Unused", NotificationType::dontSendNotification);
599 m_Coeff7.getLabel().setText("Unused", NotificationType::dontSendNotification);
600 break;
601 case Segmentation::SuperFlux:
602 m_Coeff0.getLabel().setText("PreMax", NotificationType::dontSendNotification);
603 m_Coeff1.getLabel().setText("PostMax", NotificationType::dontSendNotification);
604 m_Coeff2.getLabel().setText("PreAvg", NotificationType::dontSendNotification);
605 m_Coeff3.getLabel().setText("PostAvg", NotificationType::dontSendNotification);
606 m_Coeff4.getLabel().setText("CombWidth", NotificationType::dontSendNotification);
607 m_Coeff7.getLabel().setText("Thresh", NotificationType::dontSendNotification);
608 break;
609 default:
610 jassertfalse;
611 break;
612 }
613 }
614
616 {
617 // initial start value setting
618 auto startValue = getOwner().getParameter(Parameters::Start)->get();
619 m_waveformViewerAndEditor->setStartPosInPercentage(startValue * 0.01f);
620
621 // intial end value setting
622 auto sizeValue = getOwner().getParameter(Parameters::Size)->get();
623 m_waveformViewerAndEditor->setEndPosInPercentage(sizeValue * 0.01f);
624 }
625
627
629 {
630 Colour bgColour(31, 37, 46);
631 g.setColour(bgColour);
632 g.fillRoundedRectangle(getLocalBounds().reduced(2).toFloat(), /*corner*/ 3.0f);
633
634 g.setColour(Colours::black);
635 g.drawRoundedRectangle(getLocalBounds().reduced(1).toFloat(), /*corner*/ 5.0f, /*thickness*/ 2.0f);
636
638 }
639
641 {
643
644 // left panel bounds
646
647 m_removeEngineButton.setBounds(Rectangle<int>(470, 5, 284, 6));
648
651
652 m_Pan.setBounds(layout.leftPanel.panSlider);
654
657
658 // wavefrom area bounds
660
661 // zoom area
665
666 // toggle group bounds
667 Rectangle<int> buttonRect(layout.toggleGroupArea);
668 m_SALoopToggle.setBounds(buttonRect.removeFromLeft(layout.loopToggleWidth));
669 m_NormaliseToggle.setBounds(buttonRect.removeFromLeft(layout.normalizeToggleWidth));
670 m_AutoplayToggle.setBounds(buttonRect.removeFromLeft(layout.autoplayToggleWidth));
671 m_ProximityToggle.setBounds(buttonRect.removeFromLeft(layout.proximityToggleWidth));
672 m_PopcornToggle.setBounds(buttonRect.removeFromLeft(layout.oneShotToggleWidth));
673
675
677
678 auto kwidgetID = getKwidgetID();
679
680 // amp env
681 auto adsr0 = m_AdsrControls.findChildWithID(kwidgetID + ":Adsr0");
682 if (adsr0 != nullptr)
683 {
684 adsr0->setBounds(layout.controlsTabs.ampEnvBounds);
685 }
686
687 // synth tab
694
695 // rand tab
701
702 // control tab
709
710 // analysis tab
713
716
717 // display tab
718 m_AAlpha.setBounds(layout.controlsTabs.rotSliderTopL); // GAlpha
719 m_AH.setBounds(layout.controlsTabs.rotSliderTopM); // Hue
720 m_AA.setBounds(layout.controlsTabs.rotSliderBottomL); // Alpha
723
725 }
726
728 {
729 m_waveformViewerAndEditor->update(*sound);
730 MouseCursor::hideWaitCursor();
731 }
732
734 {
735 MouseCursor::showWaitCursor();
736 m_waveformViewerAndEditor->clear(); // switch off the Grain display
737
738 // This is is a safety check to ensure sure none of the file paths contain a return char
739 for (const auto& s : files)
740 {
741 if (s.containsChar('\n'))
742 {
743 jassertfalse;
744 return;
745 }
746
747 // Add new samples to samples tree
748 m_samplesTree->addSample(File(s).getFileNameWithoutExtension(), s, false);
749 }
750
752 {
754 }
755
756 // Mixpanel analytics: added samples to core engine
757 sendActionMessage(analyticsEventAddedSamplesEngine);
758 }
759
761 {
762 // Update sample browser button text
763 if (auto* sampleEngine = m_soSound.getSampleEngine())
764 {
765 m_sampleBrowserButton.setButtonText(String(sampleEngine->getNumAudioSegments()) + " Samples Loaded");
766 }
767 }
768
770 {
771 const Range currentRange = m_waveformViewScrollbar.getCurrentRange();
772 const double newStart = currentRange.getStart() + ((currentRange.getLength() - newThumbSize) / 2);
773 m_waveformViewScrollbar.setCurrentRange(/*starting point*/ newStart, /*size*/ double(newThumbSize),
774 NotificationType::dontSendNotification);
775 }
776
778 {
779 float scrollBarSize = m_waveformViewScrollbar.getCurrentRangeSize();
780 newPosition -= (scrollBarSize * 0.5f);
781 m_waveformViewScrollbar.setCurrentRangeStart(newPosition, NotificationType::dontSendNotification);
782 }
783
784 void KwidgetGUI_Reformer::scrollBarMoved(ScrollBar* /*scrollBarThatHasMoved*/, double newRangeStart)
785 {
786 m_waveformViewerAndEditor->setViewCentre(float(newRangeStart));
787 }
788} // namespace krotos
void setValueSuffix(String valueSuffix)
Definition AttachedSlider.h:56
Label & getLabel()
Definition AttachedSlider.cpp:163
void setDebugColour(Colour newColour)
Definition AttachedSlider.cpp:171
void setValueFormat(String valueFormat)
Definition AttachedSlider.h:59
Slider & getSlider()
Definition AttachedSlider.cpp:165
void setLabelPosition(LabelPosition position)
Definition AttachedSlider.h:49
Button & getButton()
Definition AttachedToggleButton.cpp:26
std::unique_ptr< ButtonParameterAttachment > & getAttachment()
Definition AttachedToggleButton.cpp:30
void removeAllChildren()
Removes all children from the tree.
Definition CustomParameterTree.h:88
float get() const
Definition KParameter.cpp:126
float getValue() const override
Definition KParameter.cpp:181
void set(float newValue)
Definition KParameter.cpp:128
SegmentationMethod
Definition KrotosAudioBufferDSP.h:292
Definition KrotosSynthesiserSound.h:19
void clearAndFreeBuffer()
Definition KrotosSynthesiserSound.cpp:115
void removeListener(Listener *l)
Definition KrotosSynthesiserSound.h:49
SampleEngine * getSampleEngine() override
Definition KrotosSynthesiserSound.h:44
void addListener(Listener *l)
Definition KrotosSynthesiserSound.h:48
Definition Kwidget_Reformer.h:4
static const int MaxSegmentationMethods
Definition Kwidget_Reformer.h:86
static const std::map< int, String > SegmentationMethods
Definition Kwidget_Reformer.h:87
bool isUCSEnabled()
Returns true if the UCS-based search has initialised successfully and is ready for use.
Definition Kwidget_Reformer.cpp:387
static const int MaxFeatureExtrMethods
Definition Kwidget_Reformer.h:88
static const std::map< int, String > FeatureExtrMethods
Definition Kwidget_Reformer.h:89
void paint(Graphics &g) override
Definition KwidgetGUI_Reformer.cpp:628
bool m_calledFromMarqueeEnd
Definition KwidgetGUI_Reformer.h:300
AttachedToggleButton m_QuenchToggle
Definition KwidgetGUI_Reformer.h:142
std::unique_ptr< ButtonParameterAttachment > m_muteButtonAttachment
Definition KwidgetGUI_Reformer.h:158
Kwidget & m_owner
Definition KwidgetGUI_Reformer.h:296
ComboBox m_segmentation
Definition KwidgetGUI_Reformer.h:135
ComboBox m_featureExtr
Definition KwidgetGUI_Reformer.h:136
Component m_randTab
Definition KwidgetGUI_Reformer.h:258
std::unique_ptr< Drawable > m_hoverDeleteButton
Definition KwidgetGUI_Reformer.h:305
AttachedSlider m_Level
Definition KwidgetGUI_Reformer.h:105
DrawableButton m_zoomInButton
Definition KwidgetGUI_Reformer.h:307
AttachedSlider m_Coeff2
Definition KwidgetGUI_Reformer.h:120
AttachedSlider m_StartRand
Definition KwidgetGUI_Reformer.h:108
AttachedSlider m_Nearest
Definition KwidgetGUI_Reformer.h:98
AttachedToggleButton m_ProximityToggle
Definition KwidgetGUI_Reformer.h:141
AttachedSlider m_Coeff4
Definition KwidgetGUI_Reformer.h:122
void scrollBarMoved(ScrollBar *scrollBarThatHasMoved, double newRangeStart) override
Definition KwidgetGUI_Reformer.cpp:784
~KwidgetGUI_Reformer() override
Definition KwidgetGUI_Reformer.cpp:626
static const std::string analyticsEventClearedEngine
Definition KwidgetGUI_Reformer.h:89
AttachedSlider m_RateRand
Definition KwidgetGUI_Reformer.h:110
Component m_SynthesisControls
Definition KwidgetGUI_Reformer.h:256
AttachedSlider m_Coeff0
Definition KwidgetGUI_Reformer.h:118
SamplesTree * m_samplesTree
Definition KwidgetGUI_Reformer.h:292
std::unique_ptr< Drawable > m_zoomInButtonImageHover
Definition KwidgetGUI_Reformer.h:308
AttachedSlider m_AH
Definition KwidgetGUI_Reformer.h:132
Component m_DisplayControls
Definition KwidgetGUI_Reformer.h:261
TextButton m_clearButton
Definition KwidgetGUI_Reformer.h:152
void fileHasBeenDropped(WaveformViewerAndEditor *areaSelectionComp, const StringArray &files) override
Definition KwidgetGUI_Reformer.cpp:733
TextButton m_muteButton
Definition KwidgetGUI_Reformer.h:157
void initialiseZoomControls()
Definition KwidgetGUI_Reformer.cpp:517
AttachedToggleButton m_AutoplayToggle
Definition KwidgetGUI_Reformer.h:146
Label m_segmentationLabel
Definition KwidgetGUI_Reformer.h:254
Label m_reformerNameLabel
Definition KwidgetGUI_Reformer.h:149
std::unique_ptr< Drawable > m_zoomInButtonImage
Definition KwidgetGUI_Reformer.h:308
SampleBrowserButton m_sampleBrowserButton
Definition KwidgetGUI_Reformer.h:302
AttachedComboBox m_trigger
Definition KwidgetGUI_Reformer.h:137
Component m_AnalysisControls
Definition KwidgetGUI_Reformer.h:259
AttachedSlider m_DetuneRand
Definition KwidgetGUI_Reformer.h:111
std::unique_ptr< ButtonParameterAttachment > m_soloButtonAttachment
Definition KwidgetGUI_Reformer.h:160
AttachedSlider m_Detune
Definition KwidgetGUI_Reformer.h:102
std::unique_ptr< Drawable > m_defaultDeleteButton
Definition KwidgetGUI_Reformer.h:305
struct krotos::KwidgetGUI_Reformer::Layout layout
AttachedSlider m_Tracking
Definition KwidgetGUI_Reformer.h:117
TextButton m_soloButton
Definition KwidgetGUI_Reformer.h:159
AttachedSlider m_PuckY
Definition KwidgetGUI_Reformer.h:97
std::unique_ptr< Drawable > m_zoomOutButtonImage
Definition KwidgetGUI_Reformer.h:311
AttachedSlider m_AA
Definition KwidgetGUI_Reformer.h:133
AttachedSlider m_Start
Definition KwidgetGUI_Reformer.h:95
AttachedSlider m_SelectY
Definition KwidgetGUI_Reformer.h:127
AttachedSlider m_Size
Definition KwidgetGUI_Reformer.h:100
TextButton m_tweakButton1
Definition KwidgetGUI_Reformer.h:154
TextButton m_tweakButton2
Definition KwidgetGUI_Reformer.h:155
AttachedSlider m_Rate
Definition KwidgetGUI_Reformer.h:101
void finalSetup() override
Definition KwidgetGUI_Reformer.cpp:615
AttachedSlider m_SelectZ
Definition KwidgetGUI_Reformer.h:128
AttachedSlider m_Coeff1
Definition KwidgetGUI_Reformer.h:119
static const std::string analyticsEventAddedSamplesEngine
Definition KwidgetGUI_Reformer.h:90
std::unique_ptr< krotos::WaveformViewerAndEditor > m_waveformViewerAndEditor
Definition KwidgetGUI_Reformer.h:164
AttachedSlider m_LevelMod
Definition KwidgetGUI_Reformer.h:106
DrawableButton m_removeEngineButton
Definition KwidgetGUI_Reformer.h:304
Label m_schemeLabel
Definition KwidgetGUI_Reformer.h:254
AttachedToggleButton m_PopcornToggle
Definition KwidgetGUI_Reformer.h:140
AttachedSlider m_SizeRand
Definition KwidgetGUI_Reformer.h:109
AttachedSlider m_GranularLevel
Definition KwidgetGUI_Reformer.h:107
void moveScrollBarThumb(float newPosition) override
Definition KwidgetGUI_Reformer.cpp:777
void updateBrowserButtonStatus()
Updates the browser button status displaying active samples.
Definition KwidgetGUI_Reformer.cpp:760
bool m_calledFromMarqueeStart
Definition KwidgetGUI_Reformer.h:299
void setCoefSliderLabels(int segmentationId)
Definition KwidgetGUI_Reformer.cpp:563
void resized() override
Definition KwidgetGUI_Reformer.cpp:640
AttachedSlider m_SelectX
Definition KwidgetGUI_Reformer.h:126
TabbedComponent m_controlsTab
Definition KwidgetGUI_Reformer.h:77
void clearEngine()
Definition KwidgetGUI_Reformer.cpp:554
AttachedSlider m_AAlpha
Definition KwidgetGUI_Reformer.h:131
void soundChanged(KrotosSampleOscillatorSound *sound) override
Definition KwidgetGUI_Reformer.cpp:727
AttachedSlider m_Shape
Definition KwidgetGUI_Reformer.h:115
AttachedSlider m_Radius
Definition KwidgetGUI_Reformer.h:99
AttachedSlider m_Pan
Definition KwidgetGUI_Reformer.h:104
ScrollBar m_waveformViewScrollbar
Definition KwidgetGUI_Reformer.h:313
AttachedSlider m_Coeff6
Definition KwidgetGUI_Reformer.h:124
std::unique_ptr< Drawable > m_zoomOutButtonImageHover
Definition KwidgetGUI_Reformer.h:311
static const std::string analyticsEventRemovedEngine
Definition KwidgetGUI_Reformer.h:91
AttachedToggleButton m_NormaliseToggle
Definition KwidgetGUI_Reformer.h:145
AttachedSlider m_PuckX
Definition KwidgetGUI_Reformer.h:96
AttachedSlider m_LevelRand
Definition KwidgetGUI_Reformer.h:114
KwidgetGUI_Reformer(Kwidget &owner, KrotosSampleOscillatorSound &sound)
Definition KwidgetGUI_Reformer.cpp:44
Component m_AdsrControls
Definition KwidgetGUI_Reformer.h:260
AttachedSlider m_Coeff3
Definition KwidgetGUI_Reformer.h:121
Component m_controlTab
Definition KwidgetGUI_Reformer.h:257
AttachedSlider m_Width
Definition KwidgetGUI_Reformer.h:103
AttachedSlider m_PanRand
Definition KwidgetGUI_Reformer.h:113
AttachedToggleButton m_SALoopToggle
Definition KwidgetGUI_Reformer.h:144
KrotosSampleOscillatorSound & m_soSound
Definition KwidgetGUI_Reformer.h:294
AttachedSlider m_Coeff5
Definition KwidgetGUI_Reformer.h:123
AttachedSlider m_Coeff7
Definition KwidgetGUI_Reformer.h:125
void resizeScrollBar(float newThumbSize) override
Definition KwidgetGUI_Reformer.cpp:769
AttachedToggleButton m_RobinToggle
Definition KwidgetGUI_Reformer.h:143
AttachedSlider m_WidthRand
Definition KwidgetGUI_Reformer.h:112
AttachedSlider m_GrainMax
Definition KwidgetGUI_Reformer.h:116
DrawableButton m_zoomOutButton
Definition KwidgetGUI_Reformer.h:310
Interface for a UI Component that controls a KwidgetProcessor.
Definition KwidgetGUI.h:24
std::unique_ptr< SliderParameterAttachment > createParameterAttachment(const String &paramID, Slider &slider)
Definition KwidgetGUI.cpp:72
void addParameterCallback(const String &paramID, std::function< void(float)> callback)
Definition KwidgetGUI.cpp:108
Kwidget & getOwner()
Definition KwidgetGUI.cpp:106
void addAttachedComponent(AttachedComponentType &component, const String &paramID, bool isDraggable=true)
Definition KwidgetGUI.h:112
void resized() override
Definition KwidgetGUI.cpp:45
const String & getKwidgetID() const
Definition KwidgetGUI.cpp:70
std::function< void(const String &)> onDelete
Definition KwidgetGUI.h:95
Definition Kwidget.h:8
KParameter * getParameter(const String &parameterID) const noexcept
Get a raw pointer to a KParameter belonging to this Kwidget's KwidgetProcessor. Useful for low overhe...
Definition Kwidget.cpp:168
const String & getKwidgetID() const
Definition Kwidget.cpp:367
CustomParameter * getCustomParameter(const String &parameterID)
Definition Kwidget.cpp:188
Kwidget_Reformer::Parameters Parameters
Definition KwidgetProcessor_Reformer.h:6
Label & getSampleCounter()
Definition SampleBrowserButton.h:44
DrawableButton & getPreviousButton()
Definition SampleBrowserButton.h:47
DrawableButton & getNextButton()
Definition SampleBrowserButton.h:50
void setSampleCount(size_t count)
Sets the number of samples loaded in the sampler to display in the sample counter e....
Definition SampleBrowserButton.cpp:96
A CustomParameterTree for managing a list of samples, with parameters for mute, solo,...
Definition SampleDataTree.h:9
std::function< void()> dropCompleted
Assign this to do something once a "drop" action has been completed. This is called internally by the...
Definition SampleDataTree.h:175
const OwnedArray< Sample > & getSamples() const
Definition SampleDataTree.h:140
OwnedArray< SampleBrowser::Sample > getSampleDataAsBrowserSamples()
Helper function to return an array of SampleBrowser::Sample objects populated from the SamplesTree....
Definition SampleDataTree.cpp:180
void addSample(const String &name, const String &path, bool isMuted)
Add a new sample into the tree.
Definition SampleDataTree.cpp:98
Definition WaveformViewerAndEditor.h:8
Definition AirAbsorptionFilter.cpp:2
static const Identifier AlertHeightID
Definition Krotos_LookAndFeel.h:24
static const Identifier AlertWidthID
Definition Krotos_LookAndFeel.h:23
static const String Start
Definition Kwidget_Reformer.h:23
static const String Size
Definition Kwidget_Reformer.h:27
static const String ComboboxSegmentationId
Definition KwidgetGUI_Reformer.h:41
static const String WaveformViewerId
Definition KwidgetGUI_Reformer.h:68
static const String SliderGrainPitchId
Definition KwidgetGUI_Reformer.h:47
static const String SliderGrainSizeRNDId
Definition KwidgetGUI_Reformer.h:59
static const String SliderPanRandId
Definition KwidgetGUI_Reformer.h:46
static const String SliderLevelRandId
Definition KwidgetGUI_Reformer.h:44
static const String SliderPanId
Definition KwidgetGUI_Reformer.h:45
static const String ButtonOneShotToggleId
Definition KwidgetGUI_Reformer.h:73
static const String SliderGrainWidthId
Definition KwidgetGUI_Reformer.h:51
static const String ButtonProximityToggleId
Definition KwidgetGUI_Reformer.h:74
static const String ButtonSampleBrowserId
Definition KwidgetGUI_Reformer.h:67
static const String SliderPuckXId
Definition KwidgetGUI_Reformer.h:55
static const String SliderGrainShapeId
Definition KwidgetGUI_Reformer.h:53
static const String ButtonLoopToggleId
Definition KwidgetGUI_Reformer.h:65
static const String ComboboxFeatureExtrId
Definition KwidgetGUI_Reformer.h:42
static const String SliderNearestId
Definition KwidgetGUI_Reformer.h:54
static const String ButtonZoomInId
Definition KwidgetGUI_Reformer.h:69
static const String ButtonZoomOutId
Definition KwidgetGUI_Reformer.h:70
static const String ButtonMuteId
Definition KwidgetGUI_Reformer.h:62
static const String SliderLevelId
Definition KwidgetGUI_Reformer.h:43
static const String SliderGrainSizeId
Definition KwidgetGUI_Reformer.h:49
static const String SliderPuckYId
Definition KwidgetGUI_Reformer.h:56
static const String SliderGrainPitchRNDId
Definition KwidgetGUI_Reformer.h:57
static const String SliderGrainStartRNDId
Definition KwidgetGUI_Reformer.h:58
static const String SliderGrainWidthRNDId
Definition KwidgetGUI_Reformer.h:61
static const String ButtonSoloId
Definition KwidgetGUI_Reformer.h:63
static const String ButtonNormaliseToggleId
Definition KwidgetGUI_Reformer.h:66
static const String ScrollBarWaveformViewId
Definition KwidgetGUI_Reformer.h:71
static const String SliderGrainRateId
Definition KwidgetGUI_Reformer.h:50
static const String ButtonAutoplayId
Definition KwidgetGUI_Reformer.h:64
static const String SliderGrainStartId
Definition KwidgetGUI_Reformer.h:48
static const String ButtonClearEngineId
Definition KwidgetGUI_Reformer.h:72
static const String SliderGrainMaxId
Definition KwidgetGUI_Reformer.h:52
static const String SliderGrainRateRNDId
Definition KwidgetGUI_Reformer.h:60
const Rectangle< int > rotSliderBottomM
Definition KwidgetGUI_Reformer.h:223
const Rectangle< int > rotSliderBottomR
Definition KwidgetGUI_Reformer.h:225
const Rectangle< int > rotSliderBottomL
Definition KwidgetGUI_Reformer.h:221
const Rectangle< int > ampEnvBounds
Definition KwidgetGUI_Reformer.h:208
const Rectangle< int > segmentationBounds
Definition KwidgetGUI_Reformer.h:211
const Rectangle< int > tabbedComponentBounds
Definition KwidgetGUI_Reformer.h:207
const Rectangle< int > rotSliderTopL
Definition KwidgetGUI_Reformer.h:220
const Rectangle< int > rotSliderTopM
Definition KwidgetGUI_Reformer.h:222
const Rectangle< int > schemeBounds
Definition KwidgetGUI_Reformer.h:214
const Rectangle< int > rotSliderTopR
Definition KwidgetGUI_Reformer.h:224
const Rectangle< int > segmentationLabelBounds
Definition KwidgetGUI_Reformer.h:210
const Rectangle< int > schemeLabelBounds
Definition KwidgetGUI_Reformer.h:213
const Rectangle< int > modeLabel
Definition KwidgetGUI_Reformer.h:202
const Rectangle< int > panRandSlider
Definition KwidgetGUI_Reformer.h:199
const Rectangle< int > levelSlider
Definition KwidgetGUI_Reformer.h:195
const Rectangle< int > panSlider
Definition KwidgetGUI_Reformer.h:198
const Rectangle< int > muteButton
Definition KwidgetGUI_Reformer.h:183
const Rectangle< int > soloButton
Definition KwidgetGUI_Reformer.h:184
const Rectangle< int > levelRandSlider
Definition KwidgetGUI_Reformer.h:196
Rectangle< int > toggleGroupArea
Definition KwidgetGUI_Reformer.h:234
const Rectangle< int > waveformZoomOutButton
Definition KwidgetGUI_Reformer.h:246
const float modeFontSize
Definition KwidgetGUI_Reformer.h:250
const Rectangle< int > sampleBrowserButton
Definition KwidgetGUI_Reformer.h:236
const int oneShotToggleWidth
Definition KwidgetGUI_Reformer.h:232
const int autoplayToggleWidth
Definition KwidgetGUI_Reformer.h:230
const float modeExtraKerning
Definition KwidgetGUI_Reformer.h:251
struct krotos::KwidgetGUI_Reformer::Layout::ControlsTabs controlsTabs
const int proximityToggleWidth
Definition KwidgetGUI_Reformer.h:231
const Rectangle< int > waveformArea
Definition KwidgetGUI_Reformer.h:244
const int normalizeToggleWidth
Definition KwidgetGUI_Reformer.h:229
const Rectangle< int > removeEngineButton
Definition KwidgetGUI_Reformer.h:242
const int sampleBrowserItemHeight
Definition KwidgetGUI_Reformer.h:237
const int loopToggleWidth
Definition KwidgetGUI_Reformer.h:228
const Rectangle< int > waveformZoomInButton
Definition KwidgetGUI_Reformer.h:247
const int sampleBrowserMaxItemsToShow
Definition KwidgetGUI_Reformer.h:238
struct krotos::KwidgetGUI_Reformer::Layout::LeftPanel leftPanel
const int sampleBrowserWidth
Definition KwidgetGUI_Reformer.h:240
const Rectangle< int > waveformZoomScrollbar
Definition KwidgetGUI_Reformer.h:245
static const Identifier Samples
Definition SampleDataTree.h:13