Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
142 lines (119 loc) · 4.1 KB
/
Copy pathmain.cpp
File metadata and controls
142 lines (119 loc) · 4.1 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#include <JuceHeader.h>
#include "BinaryData.h"
#include "lee_juce_json_file.h"
struct HelloWorldProcessor : juce::AudioProcessor
{
LeeJuceJSONFile jsonFile {};
HelloWorldProcessor(): AudioProcessor (BusesProperties ()
#if ! JucePlugin_IsMidiEffect
#if ! JucePlugin_IsSynth
.withInput ("Input", juce::AudioChannelSet::stereo (), true)
#endif
.withOutput ("Output", juce::AudioChannelSet::stereo (), true)
#endif
){}
~HelloWorldProcessor() override {}
void prepareToPlay (double, int) override {}
void releaseResources() override {}
bool isBusesLayoutSupported (const BusesLayout& layouts) const override
{
#if JucePlugin_IsMidiEffect
juce::ignoreUnused (layouts);
return true;
#else
if (layouts.getMainOutputChannelSet () != juce::AudioChannelSet::mono ()
&& layouts.getMainOutputChannelSet () != juce::AudioChannelSet::stereo ())
return false;
#if ! JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet () != layouts.getMainInputChannelSet ())
return false;
#endif
return true;
#endif
}
void processBlock (juce::AudioBuffer<float>& audio, juce::MidiBuffer&) override
{
audio.clear ();
}
juce::AudioProcessorEditor* createEditor() override;
bool hasEditor() const override { return true; }
const juce::String getName() const override { return "HelloWorld"; }
bool acceptsMidi () const override
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}
bool producesMidi () const override
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}
bool isMidiEffect () const override
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}
double getTailLengthSeconds() const override { return 0.0; }
int getNumPrograms() override { return 1; }
int getCurrentProgram() override { return 0; }
void setCurrentProgram (int) override {}
const juce::String getProgramName (int) override { return {}; }
void changeProgramName (int, const juce::String&) override {}
void getStateInformation (juce::MemoryBlock&) override {}
void setStateInformation (const void*, int) override {}
};
struct HelloWorldEditor : juce::AudioProcessorEditor
{
HelloWorldProcessor& processor;
juce::WebBrowserComponent browser
{
juce::WebBrowserComponent::Options {}
.withBackend (juce::WebBrowserComponent::Options::Backend::webview2)
.withWinWebView2Options (WebBrowserComponent::Options::WinWebView2{}.withUserDataFolder (File::getSpecialLocation (File::SpecialLocationType::tempDirectory)))
.withResourceProvider ([this](const juce::String&)
{
const auto* start = reinterpret_cast<const std::byte*>(BinaryData::index_html);
const auto* end = start + BinaryData::index_htmlSize;
return juce::WebBrowserComponent::Resource { { start, end }, "text/html" };
})
};
HelloWorldEditor (HelloWorldProcessor& p)
: AudioProcessorEditor (p), processor (p)
{
// addAndMakeVisible (browser);
// browser.goToURL (juce::WebBrowserComponent::getResourceProviderRoot ());
setSize (500, 500);
}
void paint (juce::Graphics& g) override
{
g.fillAll (juce::Colours::black);
g.setColour (juce::Colours::white);
g.setFont (20.0f);
g.drawText ("Hello World", getLocalBounds(), juce::Justification::centred, true);
}
void mouseDown (const juce::MouseEvent&) override
{
processor.jsonFile.test ();
}
void resized () override
{
browser.setBounds (getLocalBounds ());
}
};
juce::AudioProcessorEditor* HelloWorldProcessor::createEditor()
{
return new HelloWorldEditor (*this);
}
juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new HelloWorldProcessor();
}