|
Krotos Modules 3
|
A CustomParameterTree for managing a list of samples, with parameters for mute, solo, path and name. Defines the Types and Properties used within their respective structs as well as methods for getting/setting/serialising data. More...
#include <SampleDataTree.h>
Classes | |
| struct | Property |
| class | Sample |
| A wrapper around an individual sample in the tree, with parameters for mute, solo, path and name. You can set these values directly and their value in the tree will be updated, and listeners will be called. More... | |
| struct | Type |
Public Member Functions | |
| SamplesTree () | |
| Creates a SamplesTree with a predefined type of Type::Samples. | |
| SamplesTree (const Identifier &type) | |
| Creates a SamplesTree of a given type. | |
| SamplesTree (const SamplesTree &other) | |
| Copy constructor, creates a copy of a SamplesTree and populates Samples object array. | |
| SamplesTree (const ValueTree &other) | |
| Creates a SamplesTree from a ValueTree. Expects the input tree to have a child tree of type Type::Samples. | |
| SamplesTree & | operator= (const SamplesTree &other) |
| Copy assignment operator. | |
| void | updateSample (const String &name, const String &path) |
| Updates a sample in the tree with a new name and path. If the sample exists, it's name and path will be updated. If it does not, it is added. | |
| void | addSample (const String &name, const String &path, bool isMuted) |
| Add a new sample into the tree. | |
| Sample | getSample (const String &name) |
| Returns a Sample object from the tree by name. This is a wrapper around the ValueTree object with type safe variables you can use to get/set the sample's properties. | |
| void | removeSample (const String &name) |
| Removes a sample from the tree by name. | |
| void | removeSample (int index) |
| const OwnedArray< Sample > & | getSamples () const |
| const int | getNumSamples () const |
| Returns the number of samples in the samples tree. | |
| const StringArray | getFiles () const |
| Compatibility method for KrotosSampleOscillatorSound which requires samples to be loaded all at once as a StringArray of paths. | |
| void | setSampleSelection (int index, const Range< int > selection) |
| Set the selection range for a sample by index. | |
| Range< int > | getSampleSelection (int index) const |
| Get the selection range for a sample by index. | |
| std::vector< Range< int > > | getSampleSelections () const |
| Get the selection ranges for all samples in the tree. The index of the selection range in the vector corresponds to the index of the sample in the tree. | |
| void | setSampleSelections (const std::vector< Range< int > > &selections) |
| Set the selection ranges for all samples in the tree. The index of the selection range in the vector corresponds to the index of the sample in the tree. | |
| OwnedArray< SampleBrowser::Sample > | getSampleDataAsBrowserSamples () |
| Helper function to return an array of SampleBrowser::Sample objects populated from the SamplesTree. Assigns the Value object references so these will update and listen to the tree values. | |
| void | setSampleIndex (int index) |
| Set the current index of the sample playback queue. | |
Public Member Functions inherited from krotos::CustomParameterTree | |
| CustomParameterTree (const Identifier &type, UndoManager *undoManager=nullptr) | |
| CustomParameterTree (ValueTree customTree, UndoManager *undoManager=nullptr) | |
| CustomParameterTree (const CustomParameterTree &other) | |
| ~CustomParameterTree () override | |
| CustomParameterTree & | operator= (const CustomParameterTree &other) |
| bool | operator== (const CustomParameterTree &other) const |
| bool | isValid () const |
| void | setUndoManager (UndoManager *um) |
| UndoManager * | getUndoManager () const |
| const ValueTree & | getParameterTree () const |
| const Identifier | getType () const |
| void | addChild (const ValueTree &child, int index=-1) |
| ValueTree | getChild (int index) const |
| ValueTree | getChildWithName (const Identifier &type) const |
| void | removeChild (const ValueTree &child) |
| void | removeAllChildren () |
| Removes all children from the tree. | |
Static Public Member Functions | |
| static String | rangeToString (const Range< int > &range) |
| Converts a range to a string in the format "start:end:length". Convert it back using stringToRange. | |
| static Range< int > | stringToRange (const String &rangeString) |
| Converts a string to a range. The expected string is one generated from rangeToString. Convert it back using rangeToString. | |
| static Result | rewriteSamplePaths (ValueTree &engineKwidgetTree, File newAbsolutePath) |
| Rewrite relative SamplePath path values created by the PresetBundler into absolute ones of a given path. It also clears the legacy SamplePaths parameter value, as it doesn't need to be re-written and will cause problems if left. | |
Public Attributes | |
| std::function< void(Sample &newSample)> | sampleAdded {nullptr} |
| Assign this to do something when a sample has been added to the tree. | |
| std::function< void(ValueTree &childWhichHasBeenRemoved, int indexFromWhichChildWasRemoved)> | sampleRemoved |
| Assign this to do something when a sample has been removed from the tree. | |
| std::function< void()> | dropCompleted |
| Assign this to do something once a "drop" action has been completed. This is called internally by the ValueTree listener when the parent tree is changed, i.e. During state recall. You may call it yourself to notify that a batch of samples has been changed. | |
| std::function< void(int sampleIndex)> | sampleIndexChanged |
| Assign a lambda to this callback to do something when the sample_index property has been changed. | |
| std::function< void(int sampleIndex)> | selectedSampleChanged |
| Assign a lambda to this callback to do something when the selected_sample property has been changed. | |
| CachedValue< int > | sampleIndexValue |
| Get the current index of the sample playback queue. | |
| CachedValue< int > | selectedSampleValue |
| The index of the last sample to be selected by the user. | |
Public Attributes inherited from krotos::CustomParameterTree | |
| std::function< void(ValueTree &treeWhosePropertyHasChanged, const Identifier &property)> | propertyChanged |
| std::function< void(ValueTree &parentTree, ValueTree &childWhichHasBeenAdded)> | childAdded |
| std::function< void(ValueTree &parentTree, ValueTree &childWhichHasBeenRemoved, int indexFromWhichChildWasRemoved)> | childRemoved |
Private Member Functions | |
| void | valueTreeChildAdded (ValueTree &parentTree, ValueTree &childWhichHasBeenAdded) override |
| void | valueTreeParentChanged (ValueTree &treeWhoseParentHasChanged) override |
| void | valueTreeChildRemoved (ValueTree &parentTree, ValueTree &childWhichHasBeenRemoved, int indexFromWhichChildWasRemoved) override |
| void | valueTreePropertyChanged (ValueTree &treeWhosePropertyHasChanged, const Identifier &property) override |
Private Attributes | |
| OwnedArray< Sample > | m_samples |
Static Private Attributes | |
| static constexpr const char * | m_rangeDelimiter {":"} |
Additional Inherited Members | |
Protected Attributes inherited from krotos::CustomParameterTree | |
| ValueTree | m_parameterTree |
A CustomParameterTree for managing a list of samples, with parameters for mute, solo, path and name. Defines the Types and Properties used within their respective structs as well as methods for getting/setting/serialising data.
| krotos::SamplesTree::SamplesTree | ( | ) |
Creates a SamplesTree with a predefined type of Type::Samples.
| krotos::SamplesTree::SamplesTree | ( | const Identifier & | type | ) |
Creates a SamplesTree of a given type.
| type | The type of the tree. |
| krotos::SamplesTree::SamplesTree | ( | const SamplesTree & | other | ) |
Copy constructor, creates a copy of a SamplesTree and populates Samples object array.
| krotos::SamplesTree::SamplesTree | ( | const ValueTree & | other | ) |
Creates a SamplesTree from a ValueTree. Expects the input tree to have a child tree of type Type::Samples.
| other | The ValueTree to create the SamplesTree from. |
| void krotos::SamplesTree::addSample | ( | const String & | name, |
| const String & | path, | ||
| bool | isMuted ) |
Add a new sample into the tree.
| name | The name of the sample. |
| path | The path of the sample. |
| isMuted | Should the sample be muted on addition? |
| const StringArray krotos::SamplesTree::getFiles | ( | ) | const |
Compatibility method for KrotosSampleOscillatorSound which requires samples to be loaded all at once as a StringArray of paths.
|
inline |
Returns the number of samples in the samples tree.
| Sample krotos::SamplesTree::getSample | ( | const String & | name | ) |
Returns a Sample object from the tree by name. This is a wrapper around the ValueTree object with type safe variables you can use to get/set the sample's properties.
| OwnedArray< SampleBrowser::Sample > krotos::SamplesTree::getSampleDataAsBrowserSamples | ( | ) |
Helper function to return an array of SampleBrowser::Sample objects populated from the SamplesTree. Assigns the Value object references so these will update and listen to the tree values.
|
inline |
| Range< int > krotos::SamplesTree::getSampleSelection | ( | int | index | ) | const |
Get the selection range for a sample by index.
| index | The index of the sample in the tree. |
| std::vector< Range< int > > krotos::SamplesTree::getSampleSelections | ( | ) | const |
Get the selection ranges for all samples in the tree. The index of the selection range in the vector corresponds to the index of the sample in the tree.
| SamplesTree & krotos::SamplesTree::operator= | ( | const SamplesTree & | other | ) |
Copy assignment operator.
|
static |
Converts a range to a string in the format "start:end:length". Convert it back using stringToRange.
| range | The range to convert. |
| void krotos::SamplesTree::removeSample | ( | const String & | name | ) |
Removes a sample from the tree by name.
| void krotos::SamplesTree::removeSample | ( | int | index | ) |
|
static |
Rewrite relative SamplePath path values created by the PresetBundler into absolute ones of a given path. It also clears the legacy SamplePaths parameter value, as it doesn't need to be re-written and will cause problems if left.
| engineKwidgetTree | The ValueTree of the engine kwidget. This kwidget should have a SamplesTree as a child of it's CustomParameter tree. |
| newAbsolutePath | The new absolute filepath to re-write the paths from. |
| void krotos::SamplesTree::setSampleIndex | ( | int | index | ) |
Set the current index of the sample playback queue.
| void krotos::SamplesTree::setSampleSelection | ( | int | index, |
| const Range< int > | selection ) |
Set the selection range for a sample by index.
| index | The index of the sample in the tree. |
| selection | The range of the selection. |
| void krotos::SamplesTree::setSampleSelections | ( | const std::vector< Range< int > > & | selections | ) |
Set the selection ranges for all samples in the tree. The index of the selection range in the vector corresponds to the index of the sample in the tree.
| selections | A vector of selection ranges. |
|
static |
Converts a string to a range. The expected string is one generated from rangeToString. Convert it back using rangeToString.
| rangeString | The range string to convert, in the format "start:end:length". |
| void krotos::SamplesTree::updateSample | ( | const String & | name, |
| const String & | path ) |
Updates a sample in the tree with a new name and path. If the sample exists, it's name and path will be updated. If it does not, it is added.
| name | The name of the sample. |
| path | The path of the sample/ |
|
overrideprivatevirtual |
Reimplemented from krotos::CustomParameterTree.
|
overrideprivatevirtual |
Reimplemented from krotos::CustomParameterTree.
|
overrideprivate |
|
overrideprivatevirtual |
Reimplemented from krotos::CustomParameterTree.
| std::function<void()> krotos::SamplesTree::dropCompleted |
Assign this to do something once a "drop" action has been completed. This is called internally by the ValueTree listener when the parent tree is changed, i.e. During state recall. You may call it yourself to notify that a batch of samples has been changed.
Note that when copying a SamplesTree, the lambda will be copied as well.
This exists in order to support the current mechanism for sample loading into the KrotosSynthesiser which requires an array of sample paths to be passed via a single call, to load them all at once.
Call this after a batch of files has been added to the tree, and use getFiles() to retrieve the file path list as a string array
Todo: Deprecate once KrotosSampleOscillatorSound has been updated to allow efficient sequential sample loading
|
staticconstexprprivate |
|
private |
| std::function<void(Sample& newSample)> krotos::SamplesTree::sampleAdded {nullptr} |
Assign this to do something when a sample has been added to the tree.
| std::function<void(int sampleIndex)> krotos::SamplesTree::sampleIndexChanged |
Assign a lambda to this callback to do something when the sample_index property has been changed.
| index | The current sample index. |
| CachedValue<int> krotos::SamplesTree::sampleIndexValue |
Get the current index of the sample playback queue.
| std::function<void(ValueTree& childWhichHasBeenRemoved, int indexFromWhichChildWasRemoved)> krotos::SamplesTree::sampleRemoved |
Assign this to do something when a sample has been removed from the tree.
| std::function<void(int sampleIndex)> krotos::SamplesTree::selectedSampleChanged |
Assign a lambda to this callback to do something when the selected_sample property has been changed.
| index | The selected sample index. |
| CachedValue<int> krotos::SamplesTree::selectedSampleValue |
The index of the last sample to be selected by the user.