Skip to content

Commit

Permalink
Fix internalAddNoteOn note number limit (#599)
Browse files Browse the repository at this point in the history
* Fix internalAddNoteOn note number limit

* Fix note and CC limits to 0-127 range everywhere
  • Loading branch information
ustk authored Jan 19, 2025
1 parent 720b50f commit 3579b81
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion hi_backend/backend/BackendEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@ void MainTopBar::QuickPlayComponent::mouseDown(const MouseEvent& e)

int NoteOffset = 900;

for(int i = 0; i < 127; i++)
for(int i = 0; i < 128; i++)
{
String n;
n << MidiMessage::getMidiNoteName(i, true, true, 3);
Expand Down
2 changes: 1 addition & 1 deletion hi_backend/backend/BackendProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ void BackendProcessor::pushToAnalyserBuffer(AnalyserInfo::Ptr info, bool post, c
{
if(!post)
{
for(int i = 0; i < 127; i++)
for(int i = 0; i < 128; i++)
{
if(getKeyboardState().isNoteOn(1, i))
{
Expand Down
2 changes: 1 addition & 1 deletion hi_core/hi_core/HiseEventBufferUnitTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ class HiseEventUnitTest : public UnitTest

b.clear();

for (uint8 i = 0; i < 127; i++)
for (uint8 i = 0; i < 128; i++)
{

HiseEvent e(HiseEvent::Type::NoteOn, i, 50, 1);
Expand Down
2 changes: 1 addition & 1 deletion hi_core/hi_core/MacroControlledComponents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void MacroControlledObject::enableMidiLearnWithPopup()
{
auto value = handler->getMidiControllerNumber(processor, parameterToUse);

for (int i = 1; i < 127; i++)
for (int i = 0; i < 128; i++)
{
if (handler->shouldAddControllerToPopup(i))
mToUse.addItem(i + MidiOffset, handler->getControllerName(i), handler->isMappable(i), i == value);
Expand Down
4 changes: 2 additions & 2 deletions hi_core/hi_core/UtilityClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ CustomKeyboardState::CustomKeyboardState():
MidiKeyboardState(),
lowestKey(40)
{
for (int i = 0; i < 127; i++)
for (int i = 0; i < 128; i++)
{
setColourForSingleKey(i, Colours::transparentBlack);
}
Expand All @@ -512,7 +512,7 @@ bool CustomKeyboardState::isColourDefinedForKey(int noteNumber) const

void CustomKeyboardState::setColourForSingleKey(int noteNumber, Colour colour)
{
if (noteNumber >= 0 && noteNumber < 127)
if (noteNumber >= 0 && noteNumber <= 127)
{
noteColours[noteNumber] = colour;
}
Expand Down
2 changes: 1 addition & 1 deletion hi_core/hi_sampler/sampler/ModulatorSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ syncVoiceHandler(false)
sampleStartChain->setColour(JUCE_LIVE_CONSTANT_OFF(Colour(0xff5e8127)));
crossFadeChain->setColour(JUCE_LIVE_CONSTANT_OFF(Colour(0xff884b29)));

for (int i = 0; i < 127; i++)
for (int i = 0; i < 128; i++)
samplerDisplayValues.currentNotes[i] = 0;

setVoiceAmount(numVoices);
Expand Down
2 changes: 1 addition & 1 deletion hi_core/hi_sampler/sampler/SampleImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ XmlElement *SampleImporter::createXmlDescriptionForFile(const File &f, int index

int root = -1;

for(int i = 0; i < 127; i++)
for(int i = 0; i < 128; i++)
{
if(properties[Root] == MidiMessage::getMidiNoteName(i, true, true, 3))
{
Expand Down
2 changes: 1 addition & 1 deletion hi_core/hi_sampler/sampler/SfzImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ int getNoteNumberFromNameOrNumber(const String &data)
{
const String noteName = data.toUpperCase();

for(int i = 0; i < 127; i++)
for(int i = 0; i < 128; i++)
{
if(noteName.contains(MidiMessage::getMidiNoteName(i, true, true, 3)))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class FileNamePartComponent : public Component,
String cleanedToken = token.toUpperCase().removeCharacters(" ");


for(int i = 0; i < 127; i++)
for(int i = 0; i < 128; i++)
if(MidiMessage::getMidiNoteName(i, true, true, 3) == cleanedToken)
return i;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ void SampleEditHandler::updateMainSound(SampleEditHandler& s, ModulatorSamplerSo

bool SampleEditHandler::newKeysPressed(const uint8 *currentNotes)
{
for (int i = 0; i < 127; i++)
for (int i = 0; i < 128; i++)
{
if (currentNotes[i] != 0) return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ void SamplerSoundMap::paintOverChildren(Graphics &g)
g.fillPath(p);
}

for (int i = 0; i < 127; i++)
for (int i = 0; i < 128; i++)
{
if (pressedKeys[i] != 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ void ValueSettingComponent::labelTextChanged (Label* labelThatHasChanged)

if(valueLabel->getText().containsAnyOf("CDEFGAB#"))
{
for(int i = 0; i < 127; i++)
for(int i = 0; i < 128; i++)
{
if(MidiMessage::getMidiNoteName(i, true, true, 3) == valueLabel->getText())
{
Expand Down
2 changes: 1 addition & 1 deletion hi_scripting/scripting/HardcodedScriptProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ class CCToNoteProcessor : public HardcodedScriptProcessor
ccSelector = Content.addComboBox("ccSelector", 309, 15);


for (int i = 1; i < 127; i++)
for (int i = 0; i < 128; i++)
{
ccSelector->addItem("CC " + String(i));
}
Expand Down
6 changes: 3 additions & 3 deletions hi_scripting/scripting/api/ScriptingApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2382,7 +2382,7 @@ void ScriptingApi::Engine::setLatencySamples(int latency)

int ScriptingApi::Engine::getMidiNoteFromName(String midiNoteName) const
{
for (int i = 0; i < 127; i++)
for (int i = 0; i < 128; i++)
{
if (getMidiNoteName(i) == midiNoteName)
return i;
Expand Down Expand Up @@ -6194,7 +6194,7 @@ int ScriptingApi::Synth::internalAddNoteOn(int channel, int noteNumber, int velo
{
if (channel > 0 && channel <= 16)
{
if (noteNumber >= 0 && noteNumber < 127)
if (noteNumber >= 0 && noteNumber <= 127)
{
if (velocity >= 0 && velocity <= 127)
{
Expand Down Expand Up @@ -6265,7 +6265,7 @@ void ScriptingApi::Synth::addNoteOff(int channel, int noteNumber, int timeStampS
{
if (channel > 0 && channel <= 16)
{
if (noteNumber >= 0 && noteNumber < 127)
if (noteNumber >= 0 && noteNumber <= 127)
{
if (timeStampSamples >= 0)
{
Expand Down
2 changes: 1 addition & 1 deletion tools/scripts/RangeLimiter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
lowerLimit = Content.addComboBox("lowerLimit", 0, 0);
upperLimit = Content.addComboBox("upperLimit", 150, 0);

for(i = 0; i < 127; i++)
for(i = 0; i < 128; i++)
{
lowerLimit.addItem(Engine.getMidiNoteName(i));
upperLimit.addItem(Engine.getMidiNoteName(i));
Expand Down
2 changes: 1 addition & 1 deletion tools/scripts/TrueLegatoIntervalScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ VelocityCC = Content.addComboBox("VelocityCC", 10, 10);

VelocityCC.addItem("Velocity");

for(i = 0; i < 127; i++)
for(i = 0; i < 128; i++)
{
VelocityCC.addItem("CC " + (i+1));
}
Expand Down

0 comments on commit 3579b81

Please sign in to comment.