@@ -257,9 +257,9 @@ void GuiComponent::changeSampleChannel(const int &channel)
257
257
if (midiChannel > 0 ) sampleMidiChannel.setText (juce::String (midiChannel).paddedLeft (' 0' , 2 ), juce::NotificationType::dontSendNotification);
258
258
else sampleMidiChannel.setText (" ALL" , juce::NotificationType::dontSendNotification);
259
259
260
- midiRootNote.setText (notes[ audioProcessor.getRootNote (currentSample)] , juce::NotificationType::dontSendNotification);
261
- midiLowNote.setText (notes[ audioProcessor.getLowNote (currentSample)] , juce::NotificationType::dontSendNotification);
262
- midiHiNote.setText (notes[ audioProcessor.getHighNote (currentSample)] , juce::NotificationType::dontSendNotification);
260
+ midiRootNote.setText (notes. operator []( audioProcessor.getRootNote (currentSample)) , juce::NotificationType::dontSendNotification);
261
+ midiLowNote.setText (notes. operator []( audioProcessor.getLowNote (currentSample)) , juce::NotificationType::dontSendNotification);
262
+ midiHiNote.setText (notes. operator []( audioProcessor.getHighNote (currentSample)) , juce::NotificationType::dontSendNotification);
263
263
264
264
if (audioProcessor.getPingPongLoop (currentSample))
265
265
{
@@ -409,19 +409,19 @@ void GuiComponent::parameterChanged(const juce::String ¶meterID, float newVa
409
409
if (parameterID.contains (" SAMPLE ROOT NOTE" + juce::String (currentSample)))
410
410
{
411
411
const int midiNote = newValue < 0 ? 0 : newValue > 127 ? 127 : (int ) newValue;
412
- midiRootNote.setText (notes[midiNote] , juce::NotificationType::dontSendNotification);
412
+ midiRootNote.setText (notes. operator [](midiNote) , juce::NotificationType::dontSendNotification);
413
413
}
414
414
415
415
if (parameterID.contains (" SAMPLE LOW NOTE" + juce::String (currentSample)))
416
416
{
417
417
const int midiNote = newValue < 0 ? 0 : newValue > 127 ? 127 : (int ) newValue;
418
- midiHiNote .setText (notes[midiNote] , juce::NotificationType::dontSendNotification);
418
+ midiLowNote .setText (notes. operator [](midiNote) , juce::NotificationType::dontSendNotification);
419
419
}
420
420
421
421
if (parameterID.contains (" SAMPLE HIGH NOTE" + juce::String (currentSample)))
422
422
{
423
423
const int midiNote = newValue < 0 ? 0 : newValue > 127 ? 127 : (int ) newValue;
424
- midiRootNote .setText (notes[midiNote] , juce::NotificationType::dontSendNotification);
424
+ midiHiNote .setText (notes. operator [](midiNote) , juce::NotificationType::dontSendNotification);
425
425
}
426
426
}
427
427
@@ -545,50 +545,57 @@ void GuiComponent::changeRateText(juce::Label *l)
545
545
546
546
void GuiComponent::changeMidiNoteText (juce::Label *l, const int type)
547
547
{
548
+ bool success = true ;
548
549
juce::String txt;
549
- int note = 0 ;
550
+ int note = - 1 ;
550
551
551
552
jassert (l != nullptr );
552
553
553
554
txt = l->getText ().toUpperCase ();
554
555
555
- if (txt.isEmpty ()) return ;
556
+ if (txt.isEmpty ()) success = false ;
556
557
557
- if (txt.containsOnly (" 0123456789" ))
558
+ else if (!textInHex && txt.containsOnly (" 0123456789" ))
558
559
{
559
560
note = txt.getIntValue ();
560
561
}
561
562
else if (txt.containsOnly (" 0123456789ABCDEFG-#" ))
562
563
{
563
- for (int i = 0 ; i < 128 ; i++)
564
- {
565
- if (notes[i].compare (txt) == 0 )
566
- {
567
- note = i;
568
- break ;
569
- }
570
- }
564
+ // notes will always have letter or - as first character, hex value of note will always have letter as second character
565
+ if (std::isalpha (txt.operator [](0 )) || txt.operator [](0 ) == ' -' )
566
+ note = notes.indexOf (txt);
567
+ else
568
+ note = txt.getHexValue32 ();
569
+ }
570
+ else
571
+ {
572
+ success = false ;
571
573
}
572
574
573
- if (note < 0 || note > 127 ) return ;
575
+ if (note < 0 || note > 127 ) success = false ;
574
576
575
577
switch (type)
576
578
{
577
579
case 0 :
578
580
579
- audioProcessor.setRootNote (currentSample, note);
581
+ if (success) audioProcessor.setRootNote (currentSample, note);
582
+ else note = audioProcessor.getRootNote (currentSample);
580
583
break ;
581
584
582
585
case 1 :
583
586
584
- audioProcessor.setLowNote (currentSample, note);
587
+ if (success) audioProcessor.setLowNote (currentSample, note);
588
+ else note = audioProcessor.getLowNote (currentSample);
585
589
break ;
586
590
587
591
case 2 :
588
592
589
- audioProcessor.setHighNote (currentSample, note);
593
+ if (success) audioProcessor.setHighNote (currentSample, note);
594
+ note = audioProcessor.getHighNote (currentSample);
590
595
break ;
591
596
}
597
+
598
+ l->setText (notes.operator [](note), juce::NotificationType::dontSendNotification);
592
599
}
593
600
594
601
void GuiComponent::initAllLabels ()
0 commit comments