Oscilloscope 0.5.0
A simple oscilloscope VST
Loading...
Searching...
No Matches
GuiTransformer.cpp
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 GuiTransformer.cpp
5 Created: 9 Mar 2023 9:40:25pm
6 Author: covariant
7
8 ==============================================================================
9*/
10
11#include "GuiTransformer.h"
12
15 float transitionDuration,
16 std::function<void()> expandLambdaFunction,
17 std::function<void()> contractLambdaFunction,
18 std::function<void()> expandStartedLambdaFunction,
19 std::function<void()> contractStartedLambdaFunction,
20 std::function<void()> expandEndedLambdaFunction,
21 std::function<void()> contractEndedLambdaFunction)
22{
23 // save variables
24 this->transitionDuration = transitionDuration;
25 isProfessional = aProcessor.getTreeState()->getParameterAsValue("isProfessional").getValue();
26 aProcessor.getTreeState()->addParameterListener("isProfessional", this);
27 framesRemaining = float(EDITOR_INITIAL_RATE()) * transitionDuration;
28
29 // save lambdas
30 expandLambda = expandLambdaFunction;
31 expandStartedLambda = expandStartedLambdaFunction;
32 expandEndedLambda = expandEndedLambdaFunction;
33 contractLambda = contractLambdaFunction;
34 contractStartedLambda = contractStartedLambdaFunction;
35 contractEndedLambda = contractEndedLambdaFunction;
36}
37
39{
40}
41
42void GuiTransformer::timerCallback()
43{
44 // if animation not ended expand/contract
45 if (framesRemaining-- > 0)
46 {
47 if (isProfessional)
48 {
49 expandLambda();
50 }
51 else
52 {
53 contractLambda();
54 }
55 }
56 // else trigger end lambda and stop
57 else
58 {
59 if (isProfessional)
60 {
61 expandEndedLambda();
62 }
63 else
64 {
65 contractEndedLambda();
66 }
67 framesRemaining = float(EDITOR_INITIAL_RATE()) * transitionDuration;
68 stopTimer();
69 }
70}
71
72void GuiTransformer::parameterChanged(const juce::String &parameterID, float newValue)
73{
74 // save new value
75 isProfessional = bool(newValue);
76
77 // trigger appropriate start lambda
78 if (isProfessional)
79 {
80
81 expandStartedLambda();
82 }
83 else
84 {
85
86 contractStartedLambda();
87 }
88
89 // start timer
90 startTimerHz(EDITOR_INITIAL_RATE());
91}
GuiTransformer(OscilloscopeAudioProcessor &aProcessor, float transitionDuration, std::function< void()> expandLambdaFunction, std::function< void()> contractLambdaFunction, std::function< void()> expandStartedLambdaFunction, std::function< void()> contractStartedLambdaFunction, std::function< void()> expandEndedLambdaFunction, std::function< void()> contractEndedLambdaFunction)
Oscilloscope audio processor.
juce::AudioProcessorValueTreeState * getTreeState()