fix pitch wheel. make logging debug-only.
This commit is contained in:
@ -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);
|
||||
|
@ -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));
|
||||
|
@ -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
11
Source/Util.h
Normal 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
|
Reference in New Issue
Block a user