mirror of
https://codeberg.org/armin/wavetable.git
synced 2026-09-01 05:50:46 +02:00
More UI
This commit is contained in:
parent
a1934673f9
commit
c8a79d4693
5 changed files with 51 additions and 6 deletions
|
|
@ -1 +1 @@
|
||||||
Subproject commit 4f3247283ed2288c9e33edd9bbf37d3f4f16bdc9
|
Subproject commit 8ee85cdbf9b749ef03ca31ba50ff2ad7706e5bf6
|
||||||
|
|
@ -39,6 +39,7 @@ public:
|
||||||
wt = new gin::WavetableComponent();
|
wt = new gin::WavetableComponent();
|
||||||
wt->setName ("wt");
|
wt->setName ("wt");
|
||||||
wt->setWavetables (idx == 0 ? &proc.osc1Tables : &proc.osc2Tables);
|
wt->setWavetables (idx == 0 ? &proc.osc1Tables : &proc.osc2Tables);
|
||||||
|
wt->onFileDrop = [this] (const juce::File& f) { proc.loadUserWavetable (idx, f); };
|
||||||
addControl (wt, 5, 0, 3, 2);
|
addControl (wt, 5, 0, 3, 2);
|
||||||
|
|
||||||
timer.startTimerHz (60);
|
timer.startTimerHz (60);
|
||||||
|
|
|
||||||
|
|
@ -49,4 +49,5 @@ void WavetableAudioProcessorEditor::resized()
|
||||||
rc.removeFromTop (40);
|
rc.removeFromTop (40);
|
||||||
|
|
||||||
editor.setBounds (rc);
|
editor.setBounds (rc);
|
||||||
|
patchBrowser.setBounds (rc);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -336,17 +336,22 @@ void WavetableAudioProcessor::ReverbParams::setup (WavetableAudioProcessor& p)
|
||||||
mix = p.addExtParam ("rvbMix", "Mix", "", "", {0.0f, 1.0f, 0.0f, 1.0f}, 0.0f, 0.0f);
|
mix = p.addExtParam ("rvbMix", "Mix", "", "", {0.0f, 1.0f, 0.0f, 1.0f}, 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loadWaveTable (juce::OwnedArray<gin::BandLimitedLookupTable>& table, double sr, const juce::MemoryBlock& wav)
|
static bool loadWaveTable (juce::OwnedArray<gin::BandLimitedLookupTable>& table, double sr, const juce::MemoryBlock& wav)
|
||||||
{
|
{
|
||||||
auto is = new juce::MemoryInputStream (wav, false);
|
auto is = new juce::MemoryInputStream (wav, false);
|
||||||
if (auto reader = std::unique_ptr<juce::AudioFormatReader> (juce::WavAudioFormat().createReaderFor (is, true)))
|
if (auto reader = std::unique_ptr<juce::AudioFormatReader> (juce::WavAudioFormat().createReaderFor (is, true)))
|
||||||
|
{
|
||||||
|
if (auto sz = gin::getWavetableSize (wav); sz > 0)
|
||||||
{
|
{
|
||||||
juce::AudioSampleBuffer buf (1, int (reader->lengthInSamples));
|
juce::AudioSampleBuffer buf (1, int (reader->lengthInSamples));
|
||||||
reader->read (&buf, 0, int (reader->lengthInSamples), 0, true, false);
|
reader->read (&buf, 0, int (reader->lengthInSamples), 0, true, false);
|
||||||
|
|
||||||
loadWavetables (table, sr, buf, reader->sampleRate, gin::getWavetableSize (wav));
|
loadWavetables (table, sr, buf, reader->sampleRate, sz);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
WavetableAudioProcessor::WavetableAudioProcessor()
|
WavetableAudioProcessor::WavetableAudioProcessor()
|
||||||
|
|
@ -430,14 +435,28 @@ void WavetableAudioProcessor::reloadWavetables()
|
||||||
if (sr == 0)
|
if (sr == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (auto mb = loadMemory (osc1Table.toString()); mb.getSize() > 0)
|
if (userTable1.getSize() > 0)
|
||||||
|
{
|
||||||
|
if (shouldLoad (0, osc1Table.toString(), sr))
|
||||||
|
loadWaveTable (osc1Tables, sr, userTable1);
|
||||||
|
}
|
||||||
|
else if (auto mb = loadMemory (osc1Table.toString()); mb.getSize() > 0)
|
||||||
|
{
|
||||||
if (shouldLoad (0, osc1Table.toString(), sr))
|
if (shouldLoad (0, osc1Table.toString(), sr))
|
||||||
loadWaveTable (osc1Tables, sr, mb);
|
loadWaveTable (osc1Tables, sr, mb);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userTable2.getSize() > 0)
|
||||||
|
{
|
||||||
|
if (shouldLoad (0, osc2Table.toString(), sr))
|
||||||
|
loadWaveTable (osc2Tables, sr, userTable2);
|
||||||
|
}
|
||||||
if (auto mb = loadMemory (osc2Table.toString()); mb.getSize() > 0)
|
if (auto mb = loadMemory (osc2Table.toString()); mb.getSize() > 0)
|
||||||
|
{
|
||||||
if (shouldLoad (1, osc2Table.toString(), sr))
|
if (shouldLoad (1, osc2Table.toString(), sr))
|
||||||
loadWaveTable (osc2Tables, sr, mb);
|
loadWaveTable (osc2Tables, sr, mb);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WavetableAudioProcessor::incWavetable (int osc, int delta)
|
void WavetableAudioProcessor::incWavetable (int osc, int delta)
|
||||||
{
|
{
|
||||||
|
|
@ -461,6 +480,22 @@ void WavetableAudioProcessor::incWavetable (int osc, int delta)
|
||||||
reloadWavetables();
|
reloadWavetables();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WavetableAudioProcessor::loadUserWavetable (int osc, const juce::File f)
|
||||||
|
{
|
||||||
|
auto& table = osc == 0 ? osc1Tables : osc2Tables;
|
||||||
|
auto& mb = osc == 0 ? userTable1 : userTable2;
|
||||||
|
auto& name = osc == 0 ? osc1Table : osc2Table;
|
||||||
|
|
||||||
|
juce::MemoryBlock raw;
|
||||||
|
f.loadFileAsData (raw);
|
||||||
|
|
||||||
|
if (loadWaveTable (table, gin::Processor::getSampleRate(), raw))
|
||||||
|
{
|
||||||
|
mb = raw;
|
||||||
|
name = f.getFileNameWithoutExtension();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
void WavetableAudioProcessor::stateUpdated()
|
void WavetableAudioProcessor::stateUpdated()
|
||||||
{
|
{
|
||||||
|
|
@ -469,6 +504,9 @@ void WavetableAudioProcessor::stateUpdated()
|
||||||
osc1Table = state.getProperty ("wt1");
|
osc1Table = state.getProperty ("wt1");
|
||||||
osc2Table = state.getProperty ("wt2");
|
osc2Table = state.getProperty ("wt2");
|
||||||
|
|
||||||
|
userTable1.fromBase64Encoding (state.getProperty ("wt1Data").toString());
|
||||||
|
userTable2.fromBase64Encoding (state.getProperty ("wt2Data").toString());
|
||||||
|
|
||||||
reloadWavetables();
|
reloadWavetables();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -478,6 +516,9 @@ void WavetableAudioProcessor::updateState()
|
||||||
|
|
||||||
state.setProperty ("wt1", osc1Table, nullptr);
|
state.setProperty ("wt1", osc1Table, nullptr);
|
||||||
state.setProperty ("wt2", osc2Table, nullptr);
|
state.setProperty ("wt2", osc2Table, nullptr);
|
||||||
|
|
||||||
|
state.setProperty ("wt1Data", userTable1.toBase64Encoding(), nullptr);
|
||||||
|
state.setProperty ("wt2Data", userTable2.toBase64Encoding(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ public:
|
||||||
|
|
||||||
void reloadWavetables();
|
void reloadWavetables();
|
||||||
void incWavetable (int osc, int delta);
|
void incWavetable (int osc, int delta);
|
||||||
|
void loadUserWavetable (int osc, const juce::File f);
|
||||||
|
|
||||||
void applyEffects (juce::AudioSampleBuffer& buffer);
|
void applyEffects (juce::AudioSampleBuffer& buffer);
|
||||||
|
|
||||||
|
|
@ -256,6 +257,7 @@ public:
|
||||||
gin::BandLimitedLookupTables analogTables;
|
gin::BandLimitedLookupTables analogTables;
|
||||||
|
|
||||||
juce::Value osc1Table, osc2Table;
|
juce::Value osc1Table, osc2Table;
|
||||||
|
juce::MemoryBlock userTable1, userTable2;
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
gin::ModMatrix modMatrix;
|
gin::ModMatrix modMatrix;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue