kopia lustrzana https://github.com/jameshball/osci-render
Add randomise button
rodzic
4554158155
commit
566ecc0968
|
@ -1 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5,3H19A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5A2,2 0 0,1 3,19V5A2,2 0 0,1 5,3M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5M17,15A2,2 0 0,0 15,17A2,2 0 0,0 17,19A2,2 0 0,0 19,17A2,2 0 0,0 17,15M17,5A2,2 0 0,0 15,7A2,2 0 0,0 17,9A2,2 0 0,0 19,7A2,2 0 0,0 17,5M12,10A2,2 0 0,0 10,12A2,2 0 0,0 12,14A2,2 0 0,0 14,12A2,2 0 0,0 12,10M7,15A2,2 0 0,0 5,17A2,2 0 0,0 7,19A2,2 0 0,0 9,17A2,2 0 0,0 7,15Z" /></svg>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5,3H19A2,2 0 0,1 21,5V19A2,2 0 0,1 19,21H5A2,2 0 0,1 3,19V5A2,2 0 0,1 5,3M12,10A2,2 0 0,0 10,12A2,2 0 0,0 12,14A2,2 0 0,0 14,12A2,2 0 0,0 12,10M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5M17,15A2,2 0 0,0 15,17A2,2 0 0,0 17,19A2,2 0 0,0 19,17A2,2 0 0,0 17,15Z" /></svg>
|
Przed Szerokość: | Wysokość: | Rozmiar: 484 B Po Szerokość: | Wysokość: | Rozmiar: 354 B |
|
@ -23,6 +23,13 @@ EffectsComponent::EffectsComponent(OscirenderAudioProcessor& p, OscirenderAudioP
|
|||
};
|
||||
addAndMakeVisible(addBtn);*/
|
||||
|
||||
addAndMakeVisible(randomiseButton);
|
||||
|
||||
randomiseButton.onClick = [this] {
|
||||
itemData.randomise();
|
||||
listBox.updateContent();
|
||||
};
|
||||
|
||||
{
|
||||
juce::MessageManagerLock lock;
|
||||
audioProcessor.broadcaster.addChangeListener(this);
|
||||
|
@ -38,7 +45,10 @@ EffectsComponent::~EffectsComponent() {
|
|||
}
|
||||
|
||||
void EffectsComponent::resized() {
|
||||
auto area = getLocalBounds().withTrimmedTop(20).reduced(20);
|
||||
auto area = getLocalBounds();
|
||||
auto titleBar = area.removeFromTop(20);
|
||||
randomiseButton.setBounds(titleBar.removeFromRight(20));
|
||||
area = area.reduced(20);
|
||||
frequency.setBounds(area.removeFromTop(30));
|
||||
|
||||
area.removeFromTop(6);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <JuceHeader.h>
|
||||
#include "LookAndFeel.h"
|
||||
#include "audio/BitCrushEffect.h"
|
||||
#include "PluginProcessor.h"
|
||||
#include "components/DraggableListBox.h"
|
||||
|
@ -20,6 +21,8 @@ private:
|
|||
|
||||
// juce::TextButton addBtn;
|
||||
|
||||
SvgButton randomiseButton{ "randomise", juce::String(BinaryData::random_svg), Colours::accentColor };
|
||||
|
||||
AudioEffectListBoxItemData itemData;
|
||||
EffectsListBoxModel listBoxModel;
|
||||
DraggableListBox listBox;
|
||||
|
|
|
@ -8,7 +8,7 @@ Point WobbleEffect::apply(int index, Point input, const std::vector<double>& val
|
|||
// TODO: this doesn't consider sample rate
|
||||
smoothedFrequency = smoothedFrequency * 0.99995 + pitchDetector.frequency * 0.00005;
|
||||
double theta = nextPhase(smoothedFrequency, sampleRate);
|
||||
double delta = values[0] * std::sin(theta);
|
||||
double delta = 0.5 * values[0] * std::sin(theta);
|
||||
|
||||
return input + delta;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "../audio/Effect.h"
|
||||
#include "EffectComponent.h"
|
||||
#include "ComponentList.h"
|
||||
#include <random>
|
||||
|
||||
// Application-specific data container
|
||||
class OscirenderAudioProcessorEditor;
|
||||
|
@ -18,6 +19,43 @@ struct AudioEffectListBoxItemData : public DraggableListBoxItemData
|
|||
resetData();
|
||||
}
|
||||
|
||||
void randomise() {
|
||||
juce::SpinLock::ScopedLockType lock(audioProcessor.effectsLock);
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
auto effect = data[i];
|
||||
auto id = effect->getId();
|
||||
|
||||
if (id.contains("scale") || id.contains("translate")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (auto& parameter : effect->parameters) {
|
||||
parameter->setValueNotifyingHost(juce::Random::getSystemRandom().nextFloat());
|
||||
if (parameter->lfo != nullptr) {
|
||||
parameter->lfo->setUnnormalisedValueNotifyingHost((int) LfoType::Static);
|
||||
parameter->lfoRate->setUnnormalisedValueNotifyingHost(1);
|
||||
|
||||
if (juce::Random::getSystemRandom().nextFloat() > 0.8) {
|
||||
parameter->lfo->setUnnormalisedValueNotifyingHost((int)(juce::Random::getSystemRandom().nextFloat() * (int)LfoType::Noise));
|
||||
parameter->lfoRate->setValueNotifyingHost(juce::Random::getSystemRandom().nextFloat() * 0.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
effect->enabled->setValueNotifyingHost(juce::Random::getSystemRandom().nextFloat() > 0.8);
|
||||
}
|
||||
|
||||
// shuffle precedence
|
||||
std::random_device rd;
|
||||
std::mt19937 g(rd());
|
||||
std::shuffle(data.begin(), data.end(), g);
|
||||
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
data[i]->setPrecedence(i);
|
||||
}
|
||||
|
||||
audioProcessor.updateEffectPrecedence();
|
||||
}
|
||||
|
||||
void resetData() {
|
||||
juce::SpinLock::ScopedLockType lock(audioProcessor.effectsLock);
|
||||
data.clear();
|
||||
|
|
Ładowanie…
Reference in New Issue