Skip to content

Commit 65951ef

Browse files
committed
refactor(MidiProcessor): now you can set multiple configurations for the same note
1 parent b2d3ca3 commit 65951ef

9 files changed

+55
-6
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,3 +349,6 @@ MigrationBackup/
349349

350350
# Ionide (cross platform F# VS Code tools) working folder
351351
.ionide/
352+
353+
# My specific files
354+
.DS_Store

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## v1.0.1
4+
5+
#### Added
6+
7+
* Now you can set multiple mappings to the same input note with different velocities break points. For example, you can set the input note `8` to be remapped to `9` with a velocity of `50` and to `10` with a velocity of `100`. This way you can have a more expressive control over the remapping and use different samples for different velocities.
8+
39
## v1.0.0
410

511
#### Added

JuceLibraryCode/JucePluginDefines.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
#define JucePlugin_ARAFactoryID "com.lesimoes_dev.NoteNumberReMapperByVelocity.factory"
156156
#endif
157157
#ifndef JucePlugin_ARADocumentArchiveID
158-
#define JucePlugin_ARADocumentArchiveID "com.lesimoes_dev.NoteNumberReMapperByVelocity.aradocumentarchive.0.1.0"
158+
#define JucePlugin_ARADocumentArchiveID "com.lesimoes_dev.NoteNumberReMapperByVelocity.aradocumentarchive.1.0.0"
159159
#endif
160160
#ifndef JucePlugin_ARACompatibleArchiveIDs
161161
#define JucePlugin_ARACompatibleArchiveIDs ""
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
3+
IMPORTANT! This file is auto-generated each time you save your
4+
project - if you alter its contents, your changes may be overwritten!
5+
6+
*/
7+
8+
#include <juce_audio_plugin_client/juce_audio_plugin_client_AAX_utils.cpp>

JuceLibraryCode/include_juce_audio_plugin_client_utils.cpp renamed to JuceLibraryCode/include_juce_audio_plugin_client_VST2.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
*/
77

8-
#include <juce_audio_plugin_client/juce_audio_plugin_client_utils.cpp>
8+
#include <juce_audio_plugin_client/juce_audio_plugin_client_VST2.mm>

JuceLibraryCode/include_juce_audio_plugin_client_VST_utils.mm renamed to JuceLibraryCode/include_juce_audio_plugin_client_VST3.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55

66
*/
77

8-
#include <juce_audio_plugin_client/juce_audio_plugin_client_VST_utils.mm>
8+
#include <juce_audio_plugin_client/juce_audio_plugin_client_VST3.mm>

NoteNumberRemaperByVelocity.jucer

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,26 @@
3939
<MODULEPATH id="juce_gui_extra" path="C:/JUCE/modules"/>
4040
</MODULEPATHS>
4141
</VS2022>
42+
<XCODE_MAC targetFolder="Builds/MacOSX">
43+
<CONFIGURATIONS>
44+
<CONFIGURATION isDebug="1" name="Debug"/>
45+
<CONFIGURATION isDebug="0" name="Release"/>
46+
</CONFIGURATIONS>
47+
<MODULEPATHS>
48+
<MODULEPATH id="juce_audio_basics" path="../../juce"/>
49+
<MODULEPATH id="juce_audio_devices" path="../../juce"/>
50+
<MODULEPATH id="juce_audio_formats" path="../../juce"/>
51+
<MODULEPATH id="juce_audio_plugin_client" path="../../juce"/>
52+
<MODULEPATH id="juce_audio_processors" path="../../juce"/>
53+
<MODULEPATH id="juce_audio_utils" path="../../juce"/>
54+
<MODULEPATH id="juce_core" path="../../juce"/>
55+
<MODULEPATH id="juce_data_structures" path="../../juce"/>
56+
<MODULEPATH id="juce_events" path="../../juce"/>
57+
<MODULEPATH id="juce_graphics" path="../../juce"/>
58+
<MODULEPATH id="juce_gui_basics" path="../../juce"/>
59+
<MODULEPATH id="juce_gui_extra" path="../../juce"/>
60+
</MODULEPATHS>
61+
</XCODE_MAC>
4262
</EXPORTFORMATS>
4363
<MODULES>
4464
<MODULE id="juce_audio_basics" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>

Source/MidiProcessor.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ class MidiProcessor {
2323
auto currentNotePlayed = currentMessage.getNoteNumber();
2424
auto currentVelocityPlayed = currentMessage.getVelocity();
2525

26+
// Keep track of the maximum velocity for the current note
27+
// This ensure to get the most appropriate note if there
28+
// are multiple notes set with the same note number but with different velocities
29+
float higherVelocityFound = 0.0f;
30+
31+
int finalNoteOut = -1;
32+
2633
for (int i = 0; i < 22; i++)
2734
{
2835
int currentNoteIn = (notesIn[i]->load() - 2);
@@ -32,10 +39,15 @@ class MidiProcessor {
3239

3340
float currentVelocity = roundFloatToInt(velocities[i]->load());
3441

35-
if (currentNoteIn == currentNotePlayed && currentVelocityPlayed >= currentVelocity)
36-
currentMessage.setNoteNumber(currentNoteOut);
42+
if (currentNoteIn == currentNotePlayed && currentVelocityPlayed >= currentVelocity && currentVelocity >= higherVelocityFound) {
43+
higherVelocityFound = currentVelocity;
44+
finalNoteOut = currentNoteOut;
45+
}
3746
}
3847

48+
if (finalNoteOut > -1)
49+
currentMessage.setNoteNumber(finalNoteOut);
50+
3951
processedBuffer.addEvent(currentMessage, samplePos);
4052
}
4153

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "notenumberremapperbyvelocityvtsplugin",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "[<img src=\"https://img.shields.io/badge/slack-@lesimoes/help-blue.svg?logo=slack\">](https://lesimoes.slack.com/messages/C04JV5CRGJH) [<img src=\"https://img.shields.io/badge/discord-@lesimoes/help-blue.svg?logo=discord\">](https://discord.gg/7xegRfQjPz)",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)