Get MIDI working, and MASSIVELY speed up calculating arc length

pull/170/head
James Ball 2023-09-05 22:57:29 +01:00
rodzic 81bea16c91
commit 8c8ccb2a02
5 zmienionych plików z 12 dodań i 13 usunięć

2
.gitignore vendored
Wyświetl plik

@ -3,6 +3,8 @@
## ##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
.DS_Store
# ignore JUCE # ignore JUCE
**/Builds **/Builds
**/JuceLibraryCode **/JuceLibraryCode

Wyświetl plik

@ -139,6 +139,8 @@ OscirenderAudioProcessor::OscirenderAudioProcessor()
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
synth.addVoice(new ShapeVoice(*this)); synth.addVoice(new ShapeVoice(*this));
} }
synth.addSound(defaultSound);
} }
OscirenderAudioProcessor::~OscirenderAudioProcessor() {} OscirenderAudioProcessor::~OscirenderAudioProcessor() {}
@ -373,13 +375,13 @@ void OscirenderAudioProcessor::openFile(int index) {
// TODO: This should change whatever the ShapeSound is to the new index // TODO: This should change whatever the ShapeSound is to the new index
void OscirenderAudioProcessor::changeCurrentFile(int index) { void OscirenderAudioProcessor::changeCurrentFile(int index) {
synth.clearSounds();
if (index == -1) { if (index == -1) {
currentFile = -1; currentFile = -1;
} }
if (index < 0 || index >= fileBlocks.size()) { if (index < 0 || index >= fileBlocks.size()) {
return; return;
} }
synth.clearSounds();
synth.addSound(sounds[index]); synth.addSound(sounds[index]);
currentFile = index; currentFile = index;
updateLuaValues(); updateLuaValues();
@ -416,14 +418,8 @@ void OscirenderAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, ju
auto totalNumOutputChannels = getTotalNumOutputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels();
buffer.clear(); buffer.clear();
midiMessages.clear();
// TODO: Make this less hacky and more permanent
if (!playedNote) {
playedNote = true;
midiMessages.addEvent(juce::MidiMessage::noteOn(1, 60, 1.0f), 0);
}
synth.renderNextBlock(buffer, midiMessages, 0, buffer.getNumSamples()); synth.renderNextBlock(buffer, midiMessages, 0, buffer.getNumSamples());
midiMessages.clear();
auto* channelData = buffer.getArrayOfWritePointers(); auto* channelData = buffer.getArrayOfWritePointers();

Wyświetl plik

@ -218,7 +218,7 @@ private:
std::vector<std::shared_ptr<Effect>> allEffects; std::vector<std::shared_ptr<Effect>> allEffects;
std::vector<std::shared_ptr<Effect>> permanentEffects; std::vector<std::shared_ptr<Effect>> permanentEffects;
bool playedNote = false; ShapeSound::Ptr defaultSound = new ShapeSound(std::make_shared<FileParser>());
juce::Synthesiser synth; juce::Synthesiser synth;
juce::SpinLock consumerLock; juce::SpinLock consumerLock;

Wyświetl plik

@ -37,4 +37,4 @@ private:
std::shared_ptr<SvgParser> svg; std::shared_ptr<SvgParser> svg;
std::shared_ptr<TextParser> text; std::shared_ptr<TextParser> text;
std::shared_ptr<LuaParser> lua; std::shared_ptr<LuaParser> lua;
}; };

Wyświetl plik

@ -56,9 +56,10 @@ void CircleArc::translate(double x, double y) {
double CircleArc::length() { double CircleArc::length() {
if (len < 0) { if (len < 0) {
len = 0; len = 0;
for (int i = 0; i < 500; i++) { int segments = 5;
Vector2 v1 = nextVector(i / 500.0); for (int i = 0; i < segments; i++) {
Vector2 v2 = nextVector((i + 1) / 500.0); Vector2 v1 = nextVector(i / (double) segments);
Vector2 v2 = nextVector((i + 1) / (double) segments);
len += Line(v1.x, v1.y, v2.x, v2.y).length(); len += Line(v1.x, v1.y, v2.x, v2.y).length();
} }
} }