fix pitch wheel. make logging debug-only.
This commit is contained in:
		@ -284,6 +284,7 @@
 | 
				
			|||||||
		2C62C3F0621604CDB65B55A6 /* Pills.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Pills.cpp; path = ../../Source/Pills.cpp; sourceTree = SOURCE_ROOT; };
 | 
							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; };
 | 
							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; };
 | 
							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; };
 | 
							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>"; };
 | 
							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>"; };
 | 
							358E45B522BEE53A0087ED8D /* libvorbisenc.2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libvorbisenc.2.dylib; sourceTree = "<group>"; };
 | 
				
			||||||
@ -552,6 +553,7 @@
 | 
				
			|||||||
				358E45F422BFC00C0087ED8D /* MidiConstants.h */,
 | 
									358E45F422BFC00C0087ED8D /* MidiConstants.h */,
 | 
				
			||||||
				358E45F922C80DCA0087ED8D /* SlidersComponent.cpp */,
 | 
									358E45F922C80DCA0087ED8D /* SlidersComponent.cpp */,
 | 
				
			||||||
				358E45FA22C80DCA0087ED8D /* SlidersComponent.h */,
 | 
									358E45FA22C80DCA0087ED8D /* SlidersComponent.h */,
 | 
				
			||||||
 | 
									35099D9022CA8EF500CD4523 /* Util.h */,
 | 
				
			||||||
			);
 | 
								);
 | 
				
			||||||
			name = Source;
 | 
								name = Source;
 | 
				
			||||||
			sourceTree = "<group>";
 | 
								sourceTree = "<group>";
 | 
				
			||||||
 | 
				
			|||||||
@ -44,7 +44,9 @@ void FluidSynthModel::initialise() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    settings = new_fluid_settings();
 | 
					    settings = new_fluid_settings();
 | 
				
			||||||
    // https://sourceforge.net/p/fluidsynth/wiki/FluidSettings/
 | 
					    // https://sourceforge.net/p/fluidsynth/wiki/FluidSettings/
 | 
				
			||||||
 | 
					#if JUCE_DEBUG
 | 
				
			||||||
    fluid_settings_setint(settings, "synth.verbose", 1);
 | 
					    fluid_settings_setint(settings, "synth.verbose", 1);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    synth = new_fluid_synth(settings);
 | 
					    synth = new_fluid_synth(settings);
 | 
				
			||||||
    fluid_synth_set_sample_rate(synth, currentSampleRate);
 | 
					    fluid_synth_set_sample_rate(synth, currentSampleRate);
 | 
				
			||||||
 | 
				
			|||||||
@ -14,6 +14,7 @@
 | 
				
			|||||||
#include "SoundfontSynthSound.h"
 | 
					#include "SoundfontSynthSound.h"
 | 
				
			||||||
#include "ExposesComponents.h"
 | 
					#include "ExposesComponents.h"
 | 
				
			||||||
#include "MidiConstants.h"
 | 
					#include "MidiConstants.h"
 | 
				
			||||||
 | 
					#include "Util.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
AudioProcessor* JUCE_CALLTYPE createPluginFilter();
 | 
					AudioProcessor* JUCE_CALLTYPE createPluginFilter();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -161,7 +162,7 @@ void JuicySFAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer
 | 
				
			|||||||
    
 | 
					    
 | 
				
			||||||
    // TODO: factor into a MidiCollector
 | 
					    // TODO: factor into a MidiCollector
 | 
				
			||||||
    for (MidiBuffer::Iterator i (midiMessages); i.getNextEvent (m, time);) {
 | 
					    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)
 | 
					        // explicitly not handling note_on/off, or pitch_bend, because these are (for better or worse)
 | 
				
			||||||
        // responsibilities of SoundfontSynthVoice.
 | 
					        // responsibilities of SoundfontSynthVoice.
 | 
				
			||||||
@ -181,6 +182,13 @@ void JuicySFAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer
 | 
				
			|||||||
            fluid_midi_event_set_program(midi_event, m.getProgramChangeNumber());
 | 
					            fluid_midi_event_set_program(midi_event, m.getProgramChangeNumber());
 | 
				
			||||||
            fluid_synth_handle_midi_event(fluidSynth, midi_event);
 | 
					            fluid_synth_handle_midi_event(fluidSynth, midi_event);
 | 
				
			||||||
            delete_fluid_midi_event(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()) {
 | 
					        } else if (m.isChannelPressure()) {
 | 
				
			||||||
            fluid_midi_event_t *midi_event(new_fluid_midi_event());
 | 
					            fluid_midi_event_t *midi_event(new_fluid_midi_event());
 | 
				
			||||||
            fluid_midi_event_set_type(midi_event, static_cast<int>(CHANNEL_PRESSURE));
 | 
					            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_midi_event_set_value(midi_event, m.getAfterTouchValue());
 | 
				
			||||||
            fluid_synth_handle_midi_event(fluidSynth, midi_event);
 | 
					            fluid_synth_handle_midi_event(fluidSynth, midi_event);
 | 
				
			||||||
            delete_fluid_midi_event(midi_event);
 | 
					            delete_fluid_midi_event(midi_event);
 | 
				
			||||||
        } else if (m.isMetaEvent()) {
 | 
					//        } else if (m.isMetaEvent()) {
 | 
				
			||||||
            fluid_midi_event_t *midi_event(new_fluid_midi_event());
 | 
					//            fluid_midi_event_t *midi_event(new_fluid_midi_event());
 | 
				
			||||||
            fluid_midi_event_set_type(midi_event, static_cast<int>(MIDI_SYSTEM_RESET));
 | 
					//            fluid_midi_event_set_type(midi_event, static_cast<int>(MIDI_SYSTEM_RESET));
 | 
				
			||||||
            fluid_synth_handle_midi_event(fluidSynth, midi_event);
 | 
					//            fluid_synth_handle_midi_event(fluidSynth, midi_event);
 | 
				
			||||||
            delete_fluid_midi_event(midi_event);
 | 
					//            delete_fluid_midi_event(midi_event);
 | 
				
			||||||
        } else if (m.isSysEx()) {
 | 
					        } else if (m.isSysEx()) {
 | 
				
			||||||
            fluid_midi_event_t *midi_event(new_fluid_midi_event());
 | 
					            fluid_midi_event_t *midi_event(new_fluid_midi_event());
 | 
				
			||||||
            fluid_midi_event_set_type(midi_event, static_cast<int>(MIDI_SYSEX));
 | 
					            fluid_midi_event_set_type(midi_event, static_cast<int>(MIDI_SYSEX));
 | 
				
			||||||
 | 
				
			|||||||
@ -4,6 +4,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "SoundfontSynthVoice.h"
 | 
					#include "SoundfontSynthVoice.h"
 | 
				
			||||||
#include "SoundfontSynthSound.h"
 | 
					#include "SoundfontSynthSound.h"
 | 
				
			||||||
 | 
					#include "Util.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SoundfontSynthVoice::SoundfontSynthVoice(fluid_synth_t* synth)
 | 
					SoundfontSynthVoice::SoundfontSynthVoice(fluid_synth_t* synth)
 | 
				
			||||||
: tailOff (0.0),
 | 
					: tailOff (0.0),
 | 
				
			||||||
@ -24,7 +25,7 @@ void SoundfontSynthVoice::startNote(
 | 
				
			|||||||
        SynthesiserSound* sound,
 | 
					        SynthesiserSound* sound,
 | 
				
			||||||
        int /*currentPitchWheelPosition*/) {
 | 
					        int /*currentPitchWheelPosition*/) {
 | 
				
			||||||
    this->midiNoteNumber = midiNoteNumber;
 | 
					    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));
 | 
					    fluid_synth_noteon(synth, 0, midiNoteNumber, static_cast<int>(velocity * 127));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//    currentAngle = 0.0;
 | 
					//    currentAngle = 0.0;
 | 
				
			||||||
@ -56,7 +57,7 @@ void SoundfontSynthVoice::stopNote (float /*velocity*/, bool allowTailOff) {
 | 
				
			|||||||
//        clearCurrentNote();
 | 
					//        clearCurrentNote();
 | 
				
			||||||
//        angleDelta = 0.0;
 | 
					//        angleDelta = 0.0;
 | 
				
			||||||
//    }
 | 
					//    }
 | 
				
			||||||
    Logger::outputDebugString ( juce::String("JUCE noteoff\n") );
 | 
					    DEBUG_PRINT ( juce::String("JUCE noteoff\n") );
 | 
				
			||||||
    clearCurrentNote();
 | 
					    clearCurrentNote();
 | 
				
			||||||
    fluid_synth_noteoff(synth, 0, this->midiNoteNumber);
 | 
					    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
 | 
					// receives input as MIDI 0 to 16383, with 8192 being center
 | 
				
			||||||
// this is also exactly the input fluidsynth requires
 | 
					// this is also exactly the input fluidsynth requires
 | 
				
			||||||
void SoundfontSynthVoice::pitchWheelMoved (int newValue) {
 | 
					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) {
 | 
					void SoundfontSynthVoice::controllerMoved (int controllerNumber, int newValue) {
 | 
				
			||||||
    // this seems to be "program change" event
 | 
					    // 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) {
 | 
					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