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())
|
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;
|
std::map<juce::String, juce::PopupMenu> menus;
|
||||||
|
|
||||||
for (auto t : tables)
|
for (auto& f : files)
|
||||||
{
|
{
|
||||||
auto prefix = t.upToFirstOccurrenceOf (" ", false, false);
|
auto t = f.getFileNameWithoutExtension();
|
||||||
auto suffix = t.fromFirstOccurrenceOf (" ", false, false);
|
auto category = f.getParentDirectory().getFileName();
|
||||||
|
|
||||||
menus[prefix].addItem (t, [this, t]
|
menus[category].addItem (t, [this, t]
|
||||||
{
|
{
|
||||||
if (idx == 0)
|
if (idx == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -171,7 +171,7 @@ public:
|
||||||
|
|
||||||
juce::PopupMenu m;
|
juce::PopupMenu m;
|
||||||
m.setLookAndFeel (&getLookAndFeel());
|
m.setLookAndFeel (&getLookAndFeel());
|
||||||
|
|
||||||
for (auto itr : menus)
|
for (auto itr : menus)
|
||||||
m.addSubMenu (itr.first, itr.second);
|
m.addSubMenu (itr.first, itr.second);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -643,12 +643,15 @@ void WavetableAudioProcessor::reloadWavetables()
|
||||||
{
|
{
|
||||||
auto loadMemory = [&] (const juce::String& name) -> juce::MemoryBlock
|
auto loadMemory = [&] (const juce::String& name) -> juce::MemoryBlock
|
||||||
{
|
{
|
||||||
auto file = systemResourceRoot().getChildFile ("Wavetables").getChildFile (name + ".wt2048");
|
auto wtDir = systemResourceRoot().getChildFile ("Wavetables");
|
||||||
if (file.existsAsFile())
|
if (wtDir.isDirectory())
|
||||||
{
|
{
|
||||||
juce::MemoryBlock mb;
|
for (auto& file : wtDir.findChildFiles (juce::File::findFiles, true, name + ".wt2048"))
|
||||||
if (file.loadFileAsData (mb))
|
{
|
||||||
return mb;
|
juce::MemoryBlock mb;
|
||||||
|
if (file.loadFileAsData (mb))
|
||||||
|
return mb;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
};
|
};
|
||||||
|
|
@ -788,15 +791,38 @@ juce::Array<juce::File> WavetableAudioProcessor::getFactoryProgramDirectories()
|
||||||
juce::StringArray WavetableAudioProcessor::getWavetableNames() const
|
juce::StringArray WavetableAudioProcessor::getWavetableNames() const
|
||||||
{
|
{
|
||||||
juce::StringArray tables;
|
juce::StringArray tables;
|
||||||
auto wtDir = systemResourceRoot().getChildFile ("Wavetables");
|
for (auto& f : getWavetableFiles())
|
||||||
if (wtDir.isDirectory())
|
tables.add (f.getFileNameWithoutExtension());
|
||||||
for (auto f : wtDir.findChildFiles (juce::File::findFiles, false, "*.wt2048"))
|
|
||||||
tables.add (f.getFileNameWithoutExtension());
|
|
||||||
|
|
||||||
tables.sortNatural();
|
tables.sortNatural();
|
||||||
return tables;
|
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()
|
void WavetableAudioProcessor::setupModMatrix()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ public:
|
||||||
void incWavetable (int osc, int delta);
|
void incWavetable (int osc, int delta);
|
||||||
bool loadUserWavetable (int osc, const juce::File& f, int sz);
|
bool loadUserWavetable (int osc, const juce::File& f, int sz);
|
||||||
juce::StringArray getWavetableNames() const;
|
juce::StringArray getWavetableNames() const;
|
||||||
|
juce::Array<juce::File> getWavetableFiles() const;
|
||||||
|
|
||||||
void applyEffects (juce::AudioSampleBuffer& buffer);
|
void applyEffects (juce::AudioSampleBuffer& buffer);
|
||||||
void applyEffect (juce::AudioSampleBuffer& buffer, int fxId);
|
void applyEffect (juce::AudioSampleBuffer& buffer, int fxId);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue