mirror of
https://codeberg.org/armin/wavetable.git
synced 2026-09-01 05:50:46 +02:00
Fix wavetable menu
This commit is contained in:
parent
8c45136be6
commit
e4f7246f45
3 changed files with 42 additions and 15 deletions
|
|
@ -143,16 +143,16 @@ public:
|
|||
}
|
||||
else if (e.originalComponent == &h && e.mouseWasClicked() && e.x >= prevButton.getRight() && e.x <= nextButton.getX())
|
||||
{
|
||||
auto tables = proc.getWavetableNames();
|
||||
auto files = proc.getWavetableFiles();
|
||||
|
||||
std::map<juce::String, juce::PopupMenu> menus;
|
||||
|
||||
for (auto t : tables)
|
||||
for (auto& f : files)
|
||||
{
|
||||
auto prefix = t.upToFirstOccurrenceOf (" ", false, false);
|
||||
auto suffix = t.fromFirstOccurrenceOf (" ", false, false);
|
||||
auto t = f.getFileNameWithoutExtension();
|
||||
auto category = f.getParentDirectory().getFileName();
|
||||
|
||||
menus[prefix].addItem (t, [this, t]
|
||||
menus[category].addItem (t, [this, t]
|
||||
{
|
||||
if (idx == 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -643,12 +643,15 @@ void WavetableAudioProcessor::reloadWavetables()
|
|||
{
|
||||
auto loadMemory = [&] (const juce::String& name) -> juce::MemoryBlock
|
||||
{
|
||||
auto file = systemResourceRoot().getChildFile ("Wavetables").getChildFile (name + ".wt2048");
|
||||
if (file.existsAsFile())
|
||||
auto wtDir = systemResourceRoot().getChildFile ("Wavetables");
|
||||
if (wtDir.isDirectory())
|
||||
{
|
||||
juce::MemoryBlock mb;
|
||||
if (file.loadFileAsData (mb))
|
||||
return mb;
|
||||
for (auto& file : wtDir.findChildFiles (juce::File::findFiles, true, name + ".wt2048"))
|
||||
{
|
||||
juce::MemoryBlock mb;
|
||||
if (file.loadFileAsData (mb))
|
||||
return mb;
|
||||
}
|
||||
}
|
||||
return {};
|
||||
};
|
||||
|
|
@ -788,15 +791,38 @@ juce::Array<juce::File> WavetableAudioProcessor::getFactoryProgramDirectories()
|
|||
juce::StringArray WavetableAudioProcessor::getWavetableNames() const
|
||||
{
|
||||
juce::StringArray tables;
|
||||
auto wtDir = systemResourceRoot().getChildFile ("Wavetables");
|
||||
if (wtDir.isDirectory())
|
||||
for (auto f : wtDir.findChildFiles (juce::File::findFiles, false, "*.wt2048"))
|
||||
tables.add (f.getFileNameWithoutExtension());
|
||||
for (auto& f : getWavetableFiles())
|
||||
tables.add (f.getFileNameWithoutExtension());
|
||||
|
||||
tables.sortNatural();
|
||||
return tables;
|
||||
}
|
||||
|
||||
juce::Array<juce::File> WavetableAudioProcessor::getWavetableFiles() const
|
||||
{
|
||||
juce::Array<juce::File> files;
|
||||
auto wtDir = systemResourceRoot().getChildFile ("Wavetables");
|
||||
if (wtDir.isDirectory())
|
||||
files = wtDir.findChildFiles (juce::File::findFiles, true, "*.wt2048");
|
||||
|
||||
struct Sorter
|
||||
{
|
||||
static int compareElements (const juce::File& a, const juce::File& b)
|
||||
{
|
||||
auto categoryCmp = a.getParentDirectory().getFileName()
|
||||
.compareNatural (b.getParentDirectory().getFileName());
|
||||
if (categoryCmp != 0)
|
||||
return categoryCmp;
|
||||
return a.getFileNameWithoutExtension()
|
||||
.compareNatural (b.getFileNameWithoutExtension());
|
||||
}
|
||||
};
|
||||
Sorter sorter;
|
||||
files.sort (sorter);
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void WavetableAudioProcessor::setupModMatrix()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ public:
|
|||
void incWavetable (int osc, int delta);
|
||||
bool loadUserWavetable (int osc, const juce::File& f, int sz);
|
||||
juce::StringArray getWavetableNames() const;
|
||||
juce::Array<juce::File> getWavetableFiles() const;
|
||||
|
||||
void applyEffects (juce::AudioSampleBuffer& buffer);
|
||||
void applyEffect (juce::AudioSampleBuffer& buffer, int fxId);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue