Merge branch 'sliders'

This commit is contained in:
Alex Birch 2019-07-01 21:15:46 +01:00
commit 758dda40a9
No known key found for this signature in database
GPG Key ID: 305EB1F98D44ACBA
5 changed files with 39 additions and 11 deletions

View File

@ -284,6 +284,7 @@
2C62C3F0621604CDB65B55A6 /* Pills.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Pills.cpp; path = ../../Source/Pills.cpp; sourceTree = SOURCE_ROOT; };
2C66D01D1DD9006E77E2E260 /* include_juce_data_structures.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = include_juce_data_structures.mm; path = ../../JuceLibraryCode/include_juce_data_structures.mm; sourceTree = SOURCE_ROOT; };
307CB49DF900DE4A612FF98E /* FluidSynthModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FluidSynthModel.h; path = ../../Source/FluidSynthModel.h; sourceTree = SOURCE_ROOT; };
35099D9022CA8EF500CD4523 /* Util.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Util.h; path = ../../Source/Util.h; sourceTree = "<group>"; };
35880F58CB540AD30D1B0ED3 /* TablesComponent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TablesComponent.h; path = ../../Source/TablesComponent.h; sourceTree = SOURCE_ROOT; };
358E45B422BEE53A0087ED8D /* libpcre.1.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libpcre.1.dylib; sourceTree = "<group>"; };
358E45B522BEE53A0087ED8D /* libvorbisenc.2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libvorbisenc.2.dylib; sourceTree = "<group>"; };
@ -552,6 +553,7 @@
358E45F422BFC00C0087ED8D /* MidiConstants.h */,
358E45F922C80DCA0087ED8D /* SlidersComponent.cpp */,
358E45FA22C80DCA0087ED8D /* SlidersComponent.h */,
35099D9022CA8EF500CD4523 /* Util.h */,
);
name = Source;
sourceTree = "<group>";

View File

@ -44,7 +44,9 @@ void FluidSynthModel::initialise() {
settings = new_fluid_settings();
// https://sourceforge.net/p/fluidsynth/wiki/FluidSettings/
#if JUCE_DEBUG
fluid_settings_setint(settings, "synth.verbose", 1);
#endif
synth = new_fluid_synth(settings);
fluid_synth_set_sample_rate(synth, currentSampleRate);

View File

@ -14,6 +14,7 @@
#include "SoundfontSynthSound.h"
#include "ExposesComponents.h"
#include "MidiConstants.h"
#include "Util.h"
AudioProcessor* JUCE_CALLTYPE createPluginFilter();
@ -161,7 +162,7 @@ void JuicySFAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer
// TODO: factor into a MidiCollector
for (MidiBuffer::Iterator i (midiMessages); i.getNextEvent (m, time);) {
Logger::outputDebugString ( m.getDescription() );
DEBUG_PRINT ( m.getDescription() );
// explicitly not handling note_on/off, or pitch_bend, because these are (for better or worse)
// responsibilities of SoundfontSynthVoice.
@ -181,6 +182,13 @@ void JuicySFAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer
fluid_midi_event_set_program(midi_event, m.getProgramChangeNumber());
fluid_synth_handle_midi_event(fluidSynth, midi_event);
delete_fluid_midi_event(midi_event);
} else if (m.isPitchWheel()) {
fluid_midi_event_t *midi_event(new_fluid_midi_event());
fluid_midi_event_set_type(midi_event, static_cast<int>(PITCH_BEND));
fluid_midi_event_set_channel(midi_event, fluidSynthModel.getChannel());
fluid_midi_event_set_pitch(midi_event, m.getPitchWheelValue());
fluid_synth_handle_midi_event(fluidSynth, midi_event);
delete_fluid_midi_event(midi_event);
} else if (m.isChannelPressure()) {
fluid_midi_event_t *midi_event(new_fluid_midi_event());
fluid_midi_event_set_type(midi_event, static_cast<int>(CHANNEL_PRESSURE));
@ -196,11 +204,11 @@ void JuicySFAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer
fluid_midi_event_set_value(midi_event, m.getAfterTouchValue());
fluid_synth_handle_midi_event(fluidSynth, midi_event);
delete_fluid_midi_event(midi_event);
} else if (m.isMetaEvent()) {
fluid_midi_event_t *midi_event(new_fluid_midi_event());
fluid_midi_event_set_type(midi_event, static_cast<int>(MIDI_SYSTEM_RESET));
fluid_synth_handle_midi_event(fluidSynth, midi_event);
delete_fluid_midi_event(midi_event);
// } else if (m.isMetaEvent()) {
// fluid_midi_event_t *midi_event(new_fluid_midi_event());
// fluid_midi_event_set_type(midi_event, static_cast<int>(MIDI_SYSTEM_RESET));
// fluid_synth_handle_midi_event(fluidSynth, midi_event);
// delete_fluid_midi_event(midi_event);
} else if (m.isSysEx()) {
fluid_midi_event_t *midi_event(new_fluid_midi_event());
fluid_midi_event_set_type(midi_event, static_cast<int>(MIDI_SYSEX));

View File

@ -4,6 +4,7 @@
#include "SoundfontSynthVoice.h"
#include "SoundfontSynthSound.h"
#include "Util.h"
SoundfontSynthVoice::SoundfontSynthVoice(fluid_synth_t* synth)
: tailOff (0.0),
@ -24,7 +25,7 @@ void SoundfontSynthVoice::startNote(
SynthesiserSound* sound,
int /*currentPitchWheelPosition*/) {
this->midiNoteNumber = midiNoteNumber;
Logger::outputDebugString ( juce::String::formatted("JUCE noteon: %d, %d\n", midiNoteNumber, velocity) );
DEBUG_PRINT ( juce::String::formatted("JUCE noteon: %d, %d\n", midiNoteNumber, velocity) );
fluid_synth_noteon(synth, 0, midiNoteNumber, static_cast<int>(velocity * 127));
// currentAngle = 0.0;
@ -56,7 +57,7 @@ void SoundfontSynthVoice::stopNote (float /*velocity*/, bool allowTailOff) {
// clearCurrentNote();
// angleDelta = 0.0;
// }
Logger::outputDebugString ( juce::String("JUCE noteoff\n") );
DEBUG_PRINT ( juce::String("JUCE noteoff\n") );
clearCurrentNote();
fluid_synth_noteoff(synth, 0, this->midiNoteNumber);
}
@ -64,13 +65,17 @@ void SoundfontSynthVoice::stopNote (float /*velocity*/, bool allowTailOff) {
// receives input as MIDI 0 to 16383, with 8192 being center
// this is also exactly the input fluidsynth requires
void SoundfontSynthVoice::pitchWheelMoved (int newValue) {
Logger::outputDebugString ( juce::String::formatted("Pitch wheel: %d\n", newValue) );
fluid_synth_pitch_bend(synth, 0, newValue);
// fluid_synth_pitch_bend(synth, 0, newValue);
// int ppitch_bend;
// fluid_synth_get_pitch_bend(synth, 0, &ppitch_bend);
// int ppitch_bend_sens;
// fluid_synth_get_pitch_wheel_sens(synth, 0, &ppitch_bend_sens);
// Logger::outputDebugString ( juce::String::formatted("Pitch wheel: %d %d %d\n", newValue, ppitch_bend, ppitch_bend_sens) );
}
void SoundfontSynthVoice::controllerMoved (int controllerNumber, int newValue) {
// this seems to be "program change" event
Logger::outputDebugString ( juce::String::formatted("Controller moved: %d, %d\n", controllerNumber, newValue) );
DEBUG_PRINT ( juce::String::formatted("Controller moved: %d, %d\n", controllerNumber, newValue) );
}
void SoundfontSynthVoice::renderNextBlock (AudioBuffer<float>& outputBuffer, int startSample, int numSamples) {

11
Source/Util.h Normal file
View File

@ -0,0 +1,11 @@
#pragma once
#include "../JuceLibraryCode/JuceHeader.h"
#ifndef DEBUG_PRINT
#if JUCE_DEBUG
#define DEBUG_PRINT(str) Logger::outputDebugString(str)
#else
#define DEBUG_PRINT(str)
#endif
#endif