Mutex protect the envelope when manipulating the amount of nodes from the GUI. Should probably redesign this stuff a bit...Init envelope reset nodes.
This commit is contained in:
parent
195a630060
commit
51049e4ae1
@ -104,6 +104,7 @@ public:
|
||||
void setPreviewDry(bool b);
|
||||
bool isPreviewingDry() const;
|
||||
int m_param_change_count = 0;
|
||||
CriticalSection* getMutex() { return &m_cs; }
|
||||
private:
|
||||
CircularBuffer<float> m_stretchoutringbuf{ 1024 * 1024 };
|
||||
AudioBuffer<float> m_file_inbuf;
|
||||
|
@ -29,8 +29,8 @@ PaulstretchpluginAudioProcessorEditor::PaulstretchpluginAudioProcessorEditor(Pau
|
||||
: AudioProcessorEditor(&p),
|
||||
m_wavecomponent(p.m_afm,p.m_thumb.get()),
|
||||
processor(p), m_perfmeter(&p),
|
||||
m_wavefilter_tab(TabbedButtonBar::TabsAtTop)
|
||||
|
||||
m_wavefilter_tab(TabbedButtonBar::TabsAtTop),
|
||||
m_free_filter_component(p.getStretchSource()->getMutex())
|
||||
{
|
||||
//addAndMakeVisible(&m_free_filter_component);
|
||||
m_free_filter_component.set_envelope(processor.m_free_filter_envelope);
|
||||
|
@ -82,9 +82,9 @@ PaulstretchpluginAudioProcessor::PaulstretchpluginAudioProcessor()
|
||||
m_playposinfo.timeInSeconds = 0.0;
|
||||
|
||||
m_free_filter_envelope = std::make_shared<breakpoint_envelope>();
|
||||
m_free_filter_envelope->AddNode({ 0.0,0.5 });
|
||||
m_free_filter_envelope->AddNode({ 1.0,0.5 });
|
||||
|
||||
m_free_filter_envelope->AddNode({ 0.0,0.75 });
|
||||
m_free_filter_envelope->AddNode({ 1.0,0.75 });
|
||||
m_free_filter_envelope->set_reset_nodes(m_free_filter_envelope->get_all_nodes());
|
||||
m_recbuffer.setSize(2, 44100);
|
||||
m_recbuffer.clear();
|
||||
if (m_afm->getNumKnownFormats()==0)
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include "envelope_component.h"
|
||||
|
||||
EnvelopeComponent::EnvelopeComponent()
|
||||
EnvelopeComponent::EnvelopeComponent(CriticalSection* cs) : m_cs(cs)
|
||||
{
|
||||
OnEnvelopeEdited = [](breakpoint_envelope*) {};
|
||||
setWantsKeyboardFocus(true);
|
||||
@ -246,7 +246,9 @@ void EnvelopeComponent::mouseDown(const MouseEvent & ev)
|
||||
int r = menu.show();
|
||||
if (r == 1)
|
||||
{
|
||||
m_cs->enter();
|
||||
m_envelope->ResetEnvelope();
|
||||
m_cs->exit();
|
||||
}
|
||||
if (r == 2)
|
||||
{
|
||||
@ -274,7 +276,9 @@ void EnvelopeComponent::mouseDown(const MouseEvent & ev)
|
||||
m_bubble.showAt({ ev.x,ev.y, 0,0 }, AttributedString("Can't remove last node"), 3000, false, false);
|
||||
return;
|
||||
}
|
||||
m_cs->enter();
|
||||
m_envelope->DeleteNode(m_node_to_drag);
|
||||
m_cs->exit();
|
||||
m_node_to_drag = -1;
|
||||
OnEnvelopeEdited(m_envelope.get());
|
||||
repaint();
|
||||
@ -293,8 +297,10 @@ void EnvelopeComponent::mouseDown(const MouseEvent & ev)
|
||||
{
|
||||
double normx = jmap((double)ev.x, 0.0, (double)getWidth(), m_view_start_time, m_view_end_time);
|
||||
double normy = jmap((double)getHeight() - ev.y, 0.0, (double)getHeight(), m_view_start_value, m_view_end_value);
|
||||
m_cs->enter();
|
||||
m_envelope->AddNode ({ normx,normy, 0.5});
|
||||
m_envelope->SortNodes();
|
||||
m_cs->exit();
|
||||
m_mouse_down = false;
|
||||
OnEnvelopeEdited(m_envelope.get());
|
||||
repaint();
|
||||
|
@ -32,7 +32,7 @@ class EnvelopeComponent : public Component,
|
||||
//public TooltipClient
|
||||
{
|
||||
public:
|
||||
EnvelopeComponent();
|
||||
EnvelopeComponent(CriticalSection* cs);
|
||||
~EnvelopeComponent();
|
||||
void paint(Graphics& g) override;
|
||||
void set_envelope(std::shared_ptr<breakpoint_envelope> env, String name = String());
|
||||
@ -72,5 +72,6 @@ private:
|
||||
String m_last_tip;
|
||||
BubbleMessageComponent m_bubble;
|
||||
void show_bubble(int x, int y, const envelope_node &node);
|
||||
CriticalSection* m_cs = nullptr;
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(EnvelopeComponent)
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user