-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathOscillator2.cpp
More file actions
72 lines (53 loc) · 2.22 KB
/
Oscillator2.cpp
File metadata and controls
72 lines (53 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
==============================================================================
Oscillator2.cpp
Created: 16 Nov 2018 7:28:32pm
Author: Dianne Campbell
==============================================================================
*/
#include "../JuceLibraryCode/JuceHeader.h"
#include "Oscillator2.h"
//==============================================================================
Oscillator2::Oscillator2(JuceSynthFrameworkAudioProcessor& p) :
processor(p)
{
setSize(200, 200);
osc2Menu.addItem("Saw", 1);
osc2Menu.addItem("Square", 2);
osc2Menu.addItem("Sine", 3);
osc2Menu.setJustificationType(Justification::centred);
addAndMakeVisible(&osc2Menu);
waveSelection2 = new AudioProcessorValueTreeState::ComboBoxAttachment (processor.tree, "wavetype2", osc2Menu);
//slider initialization values
Blendslider.setSliderStyle(Slider::SliderStyle::LinearVertical);
Blendslider.setRange(0.0f, 1.0f);
Blendslider.setValue(1.0f);
Blendslider.setTextBoxStyle(Slider::NoTextBox, true, 0, 0);
addAndMakeVisible(&Blendslider);
//sends value of the sliders to the tree state in the processor
blendVal = new AudioProcessorValueTreeState::SliderAttachment (processor.tree, "blend", Blendslider);
}
Oscillator2::~Oscillator2()
{
}
void Oscillator2::paint (Graphics& g)
{
//background stuff
juce::Rectangle<int> titleArea (0, 10, getWidth(), 20);
g.fillAll (Colours::black);
g.setColour(Colours::white);
g.drawText("Oscillator Two", titleArea, Justification::centredTop);
juce::Rectangle <float> area (25, 25, 150, 150);
g.setColour(Colours::yellow);
g.drawRoundedRectangle(area, 20.0f, 2.0f);
}
void Oscillator2::resized()
{
juce::Rectangle<int> area = getLocalBounds().reduced(40);
osc2Menu.setBounds(area.removeFromTop(20));
//draws the sliders...we use a rectangle object to dynamically size the UI (if we want to resize for IPad etc without needing to change ALL settings
int sliderWidth = 25;
int sliderHeight = 175;
//draw sliders by reducing area from rectangle above
Blendslider.setBounds (area.removeFromLeft(sliderWidth).removeFromTop(sliderHeight).withTrimmedTop(10));
}