Skip to content

Commit

Permalink
last nail in coffin of nota
Browse files Browse the repository at this point in the history
  • Loading branch information
klesun committed Oct 18, 2015
1 parent 08291bc commit 4229938
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/org/klesun_model/IModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ default IModel reconstructFromJson(JSONObject jsObject) throws JSONException
field.setValueFromJsObject(jsObject);
} else if (field.isFinal) {
Logger.fatal("Source does not have final field [" + field.getName() + "] for class {" + getClass().getSimpleName() + "}");
}
} else {
// TODO: DIE HORRIBLY. it was bad idea to omit default values. at least it should be list of fields that can be omitted, no allowing omit anything!
}
}
return this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/org/shmidusic/sheet_music/staff/chord/Chord.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Chord extends AbstractModel
{
private Field<Boolean> isDiminendo = new Field<>("isDiminendo", false, this).setPaintingLambda(ChordPainter::diminendoPainting);
public Field<String> slog = new Field<>("slog", "", this).setPaintingLambda(ChordPainter::slogPainting).setOmitDefaultFromJson(true);
public Arr<Note> noteList = new Arr<>("notaList", new TreeSet<>(), this, Note.class);
public Arr<Note> noteList = new Arr<>("noteList", new TreeSet<>(), this, Note.class);

// getters/setters

Expand Down
10 changes: 7 additions & 3 deletions src/org/shmidusic/sheet_music/staff/chord/note/Note.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ public class Note extends AbstractModel implements INote
// TODO: normalization rules maybe ???
final public Field<Integer> tune = new Field<>("tune", Integer.class, true, this, n -> limit(n, 0, 127));
final protected Field<Integer> channel = new Field<>("channel", Integer.class, true, this, n -> limit(n, 0, 15));

final public Field<Fraction> length = new Field<>("length", new Fraction(1, 4), this, INote::legnthNorm);
final public Field<Boolean> isTriplet = new Field<>("isTriplet", false, this);
final public Field<Boolean> isSharp = new Field<>("isSharp", false, this);

/** @TODO: forbid more than two dots and move tripletness into length */
final public Field<Boolean> isTriplet = new Field<>("isTriplet", false, this);
/** @unused */
final public Field<Boolean> isSharp = new Field<>("isSharp", false, this);
/** @unused */
final private Field<Boolean> isMuted = new Field<>("isMuted", false, this);
/** @broken */
final private Field<Boolean> isLinkedToNext = new Field<>("isLinkedToNext", false, this);

final private static int MAX_DOT_COUNT = 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.shmidusic.sheet_music.staff.Staff;

import java.util.*;
import java.util.stream.Collectors;

import org.apache.commons.math3.fraction.Fraction;

Expand Down Expand Up @@ -87,14 +88,20 @@ public StaffConfig reconstructFromJson(JSONObject jsObject) throws JSONException
// cuz i wanna overwrite old key
}

// legacy, i used to believe that they are numbered 1..16 (but they are 0..15 in fact)
resultChannelSet.stream()
.filter(c -> c.channelNumber.get() > 15)
.collect(Collectors.toList())
.forEach(resultChannelSet::remove);

this.channelList.set(resultChannelSet);

syncSyntChannels();
return this;
}

public void syncSyntChannels() {
for (int i = 0; i < getChannelList().size(); ++i) {
for (int i = 0; i < Channel.CHANNEL_COUNT; ++i) {
DeviceEbun.setInstrument(i, channelList.get(i).getInstrument());
DeviceEbun.setVolume(i, channelList.get(i).getVolume());
}
Expand Down

0 comments on commit 4229938

Please sign in to comment.