4 bool enableAreaSelection)
5 : m_minimumSelectionAreaOn(minimumSelectionAreaOn),
20 addMouseListener(
this,
true);
22 (File::getSpecialLocation(File::userDocumentsDirectory)),
31 if (sampleEngine !=
nullptr)
33 if (sampleEngine->isPlaying())
57 float width =
static_cast<float>(getWidth());
60 float segmentPercentOfWaveformStart =
static_cast<float>(selector.segment.getStart()) /
62 float segmentPercentOfWaveformEnd =
64 float selectionPercentOfWaveformStart =
static_cast<float>(selector.selection.getStart()) /
66 float selectionPercentOfWaveformEnd =
static_cast<float>(selector.selection.getEnd()) /
72 g, Rectangle<float>(segmentPercentOfWaveformStart, 0.0f,
73 selectionPercentOfWaveformStart - segmentPercentOfWaveformStart, 1.0f));
75 g, Rectangle<float>(selectionPercentOfWaveformEnd, 0.0f,
76 segmentPercentOfWaveformEnd - selectionPercentOfWaveformEnd, 1.0f));
79 if (selector.selectionHover.getVal() && !(selector.leftHover.getVal() || selector.rightHover.getVal()))
84 selectionPercentOfWaveformEnd - selectionPercentOfWaveformStart, 1.0f));
91 g, Line<float>(selectionPercentOfWaveformStart, 0.f, selectionPercentOfWaveformStart, 1.f),
98 g, Line<float>(selectionPercentOfWaveformEnd, 0.f, selectionPercentOfWaveformEnd, 1.f), 2.f);
109 auto bounds = getLocalBounds();
122 return m_grainDisplay->getDisplayedSampleEngine()->getGetLoadedFilePathsAsCSV();
137 update(
dynamic_cast<AudioBuffer<float>*
>(sampleEngine),
138 static_cast<int>(sampleEngine->getSampleRate()));
139 setGrainData(sampleEngine->getGrainArray(), sampleEngine->getNumSamples(), sampleEngine->getNumChannels());
207 if (sound ==
nullptr)
222 if (numAudioSegments == 0)
253 auto newStart =
m_selectors[segmentIndex].selection.getStart() + diff;
255 auto clipRange = Range<int>::between(
m_selectors[segmentIndex].segment.getStart(),
257 auto clippedStart = clipRange.clipValue(newStart);
258 m_selectors[segmentIndex].selection.setStart(clippedStart);
267 auto clipRange = Range<int>::between(
m_selectors[segmentIndex].segment.getStart(),
269 auto clippedStart = clipRange.clipValue(newStart);
270 m_selectors[segmentIndex].selection.setStart(clippedStart);
278 auto newEnd =
m_selectors[segmentIndex].selection.getEnd() + diff;
280 auto clipRange = Range<int>::between(
m_selectors[segmentIndex].selection.getStart(),
282 auto clippedEnd = clipRange.clipValue(newEnd);
283 m_selectors[segmentIndex].selection.setEnd(clippedEnd);
292 auto clipRange = Range<int>::between(
m_selectors[segmentIndex].segment.getStart(),
294 auto clippedEnd = clipRange.clipValue(newEnd);
295 m_selectors[segmentIndex].selection.setEnd(clippedEnd);
303 auto selection =
m_selectors[segmentIndex].selection;
304 auto newStart = selection.getStart() + diff;
305 auto movedSelection = selection.movedToStartAt(newStart);
306 auto movedClampedSelection =
m_selectors[segmentIndex].segment.constrainRange(movedSelection);
307 m_selectors[segmentIndex].selection = movedClampedSelection;
323 bool movingToTheLeft = mouseDeltaX < 0;
324 m_selectors[segmentIndex].leftHover = movingToTheLeft;
325 m_selectors[segmentIndex].rightHover = !movingToTheLeft;
353 int mouseX = e.getPosition().getX();
364 int mouseX = e.getPosition().getX();
370 static_cast<float>(getWidth())));
487 if (
m_selectors[segmentIndex].segmentHover.getVal())
493 else if (
m_selectors[segmentIndex].leftHover.getVal())
497 else if (
m_selectors[segmentIndex].rightHover.getVal())
501 else if (
m_selectors[segmentIndex].selectionHover.getVal())
516 MouseCursor customCursor;
521 customCursor = MouseCursor(juce::MouseCursor::StandardCursorType::DraggingHandCursor);
525 customCursor = MouseCursor(juce::MouseCursor::StandardCursorType::LeftEdgeResizeCursor);
531 customCursor = MouseCursor(juce::MouseCursor::StandardCursorType::PointingHandCursor);
536 customCursor = MouseCursor(juce::MouseCursor::StandardCursorType::NormalCursor);
560 bool m_changed =
false;
565 selector.segmentHover = selector.segment.contains(
m_sampleMouseX);
568 selector.selectionHover = selector.selection.contains(
m_sampleMouseX) && inLowerZone;
571 if (selector.segmentHover.getVal())
576 selector.leftHover = abs(selector.selection.getStart() -
m_sampleMouseX) < tolerance;
578 selector.rightHover = abs(selector.selection.getEnd() -
m_sampleMouseX) < tolerance;
582 selector.leftHover =
false;
583 selector.rightHover =
false;
587 m_changed |= selector.segmentHover.hasChanged();
588 m_changed |= selector.selectionHover.hasChanged();
589 m_changed |= selector.leftHover.hasChanged();
590 m_changed |= selector.rightHover.hasChanged();
592 if (selector.segmentHover.getVal())
626 selector.segmentHover =
false;
627 selector.selectionHover =
false;
628 selector.leftHover =
false;
629 selector.rightHover =
false;
664 for (
auto filepath : filelist)
672 if (invalidFiles == 0)
678 invalidFiles == 1 ?
m_waveformView->setDropText(
"Sample Failed to Import")
679 :
m_waveformView->setDropText(String(invalidFiles) +
" Samples Failed to Import");
685 const int fileFlags = FileBrowserComponent::canSelectFiles | FileBrowserComponent::canSelectMultipleItems;
686 m_sampleChooser->launchAsync(fileFlags, [
this](
const FileChooser& fileChooser) {
687 if (fileChooser.getResults().isEmpty() ==
false)
689 StringArray filePaths;
690 for (
auto file : fileChooser.getResults())
692 filePaths.add(file.getFullPathName());
694 if (!filePaths.isEmpty())
739 Range<int>(segment.segmentStartPosition, segment.segmentStartPosition + segment.segmentLength));
Definition GrainDisplay.h:6
Definition OscillatorUtils.h:39
Definition KrotosSynthesiserSound.h:19
SampleEngine * getSampleEngine() override
Definition KrotosSynthesiserSound.h:44
int getAudioSegmentLengthInSamples(int segmentIndex)
Returns the length of an audio segment.
Definition SampleEngine.cpp:269
int getAudioSelectionStartPosition(int segmentIndex)
Returns the start of the selected section of an audio segment.
Definition SampleEngine.cpp:243
void setAudioSelectionStartPositionAbsolute(int segmentIndex, int startPosition)
Sets the absolute start of an audio segment selection relative to the audio buffer start.
Definition SampleEngine.cpp:200
void setAudioSelectionLength(int segmentIndex, int length)
Sets the length of an audio segment selection.
Definition SampleEngine.cpp:206
const Array< AudioSegment > & getAudioSegments() const
Returns the audio segment array loaded in the sample engine.(read-only)
Definition SampleEngine.h:172
int getAudioSelectionLengthInSamples(int segmentIndex)
Returns the length of the selected section of an audio segment.
Definition SampleEngine.cpp:249
int getNumAudioSegments()
Definition SampleEngine.h:161
std::vector< Range< int > > getSelectionRanges()
Returns an array of segment selection ranges.
Definition SampleEngine.cpp:96
int getAudioSegmentStartPosition(int segmentIndex)
Returns the start of an audio segment.
Definition SampleEngine.cpp:263
void drawNormalisedZoomedRect(Graphics &g, const Rectangle< float > &rect) const
Definition ZoomableComponent.cpp:14
void drawNormalisedZoomedLine(Graphics &g, Line< float > line, float thickness) const
Definition ZoomableComponent.cpp:35
void setHorizontalZoomFromRange(const Range< float > xr)
Definition ZoomableComponent.cpp:116
Definition AirAbsorptionFilter.cpp:2
A structure to hold info on a selected area.
Definition HelperClasses.h:30
Range< int > segment
Definition HelperClasses.h:32
Range< int > selection
Definition HelperClasses.h:34