Skip to content

Commit

Permalink
Velocity 0 == note off; CLAP features
Browse files Browse the repository at this point in the history
1. Velocity 0 == Note Off was not working in the CLAP_NOTE_EVENT
   stream. Correct and defensively correct in the juce stream also
   (although I think juce will have pre-converted for me)
2. Add "synthesizer" as a CLAP feature to surge xt, since surge xt
   is, in fact, a synthesizer :)

Closes surge-synthesizer#6621
  • Loading branch information
baconpaul committed Sep 23, 2022
1 parent b78a4d8 commit 4bbbc17
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/surge-xt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ juce_add_plugin(${PROJECT_NAME}
if(SURGE_BUILD_CLAP)
clap_juce_extensions_plugin(TARGET surge-xt
CLAP_ID "org.surge-synth-team.surge-xt"
CLAP_FEATURES "instrument" "hybrid" "free and open source")
CLAP_FEATURES "instrument" "synthesizer" "hybrid" "free and open source")
target_sources(${PROJECT_NAME}_CLAP PRIVATE plugin_type_extensions/SurgeSynthClapExtensions.cpp)
endif()

Expand Down
11 changes: 9 additions & 2 deletions src/surge-xt/SurgeSynthProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,11 @@ void SurgeSynthProcessor::process_clap_event(const clap_event_header_t *evt)
case CLAP_EVENT_NOTE_ON:
{
auto nevt = reinterpret_cast<const clap_event_note *>(evt);
surge->playNote(nevt->channel, nevt->key, 127 * nevt->velocity, 0, nevt->note_id);

if (nevt->velocity != 0)
surge->playNote(nevt->channel, nevt->key, 127 * nevt->velocity, 0, nevt->note_id);
else
surge->releaseNote(nevt->channel, nevt->key, 127 * nevt->velocity, nevt->note_id);
}
break;
case CLAP_EVENT_NOTE_CHOKE:
Expand Down Expand Up @@ -705,7 +709,10 @@ void SurgeSynthProcessor::applyMidi(const juce::MidiMessageMetadata &it)
if (m.isNoteOn())
{
// no note ids coming from juce- or ui- land
surge->playNote(ch, m.getNoteNumber(), m.getVelocity(), 0, -1);
if (m.getVelocity() != 0)
surge->playNote(ch, m.getNoteNumber(), m.getVelocity(), 0, -1);
else
surge->releaseNote(ch, m.getNoteNumber(), m.getVelocity(), -1);
}
else if (m.isNoteOff())
{
Expand Down

0 comments on commit 4bbbc17

Please sign in to comment.