Skip to content

Commit 4e4218f

Browse files
committed
fixed a small bug causing soome playable chords not to be shown.
1 parent e6d9762 commit 4e4218f

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/FretBoard.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,9 @@ private ArrayList<Chord> makeChord(ArrayList<Integer> chordNotes, int start, Arr
712712
else {
713713
root=false;
714714
}
715+
715716
for (int count=0; count<strings; count++) {
717+
716718
ArrayList<Position> position=makePosition(count, start, chordNotes, up.get(count), tuning.get(count).getFrets(),tuning.get(count).getStartFret(), maxFretDistance ); // calculates the positions;
717719
notePlaces.add(position);
718720
}
@@ -814,9 +816,12 @@ private ArrayList<Chord> makeChord(ArrayList<Integer> chordNotes, int start, Arr
814816
previousNoteFret=noteFret;
815817
previousNoteNumber=noteNumber;
816818
}
817-
if (allChordNotes==chordNotes.size() && stringGap==false && sameNotes==false && rootNote==false && highestFret-lowestFret<=maxFretDistance-1) {
819+
if (allChordNotes==chordNotes.size() && stringGap==false && sameNotes==false && rootNote==false&& (highestFret-lowestFret<=maxFretDistance )) {// chord is playable add it to the array list for chords to display
818820
chords.add(new Chord(chordPositions, lowestFret, lowestFret, unhitStrings, modifer, bassNoteNumber));
821+
822+
819823
}
824+
820825
for(int counter2 =size-1; counter2>=0; counter2--) {
821826
if(counterArray[counter2] + 1 < sizes[counter2]) {
822827
counterArray[counter2]++;
@@ -836,8 +841,8 @@ private ArrayList<Position> makePosition(int string, int start, ArrayList<Intege
836841
out:
837842
if(up==1) {
838843
for (int count=start; count<maxFretDistance+start; count++) { // finds all positions that match the chord notes up the neck.
839-
if (count>=frets) {
840-
if (positions.size()==0) {
844+
if (count>=frets-1) {
845+
if (positions.size()==0) { // if not matching notes were found add unhit string position
841846
positions.add(new Position(string, -1, new Note (-1,-1, "X", -1, -1) ));
842847
}
843848
break out;
@@ -865,7 +870,7 @@ else if ( root==true){// add any note that matches the notes that make up the c
865870
}
866871
}
867872
else {//does the same thing as for loop number 1 but going down the neck instead.
868-
if(start>=frets) {
873+
if(start>=frets-1) {
869874
positions.add(new Position(string, -1, new Note (-1,-1, "X", -1, -1) ));
870875
return positions;
871876
}
@@ -923,7 +928,7 @@ public void setInstrument(Instrument instrument){ // sets new instrument and reg
923928
tuning.get(count).setStartFret(tuning.get(count).getStartFret()-minFrets+1);
924929
}
925930
}
926-
instrument.setFrets(maxFrets+1);
931+
instrument.setFrets(maxFrets+2);
927932
for (int count=0; count<strings; count++) {
928933
int note=tuning.get(count).getStringNote().getNoteNumber();
929934
int octave=tuning.get(count).getStringNote().getOctave();

0 commit comments

Comments
 (0)