/** * Returns if this tone id is the sharped id of the tone. * * @param id the id of the tone. * @return if the tone id is the sharped id of the tone. * @throws IllegalArgumentException if neither the tone nor the * semitone have the id. * @deprecated Magic value */ @Deprecated public boolean isSharped(byte id) { if (id == getId(false)) { return false; } else if (id == getId(true)) { return true; } else { // The id isn't matching to the tone! throw new IllegalArgumentException("The id isn't matching to the tone."); } }
/** * Creates a new note. * * @param octave The octave where the note is in. Has to be 0 - 2. * @param tone The tone within the octave. If the octave is 2 the note has * to be F#. * @param sharped Set if the tone is sharped (e.g. for F#). */ public Note(int octave, Tone tone, boolean sharped) { if (sharped && !tone.isSharpable()) { tone = Tone.values()[tone.ordinal() + 1]; sharped = false; } if (octave < 0 || octave > 2 || (octave == 2 && !(tone == Tone.F && sharped))) { throw new IllegalArgumentException("Tone and octave have to be between F#0 and F#2"); } this.note = (byte) (octave * Tone.TONES_COUNT + tone.getId(sharped)); }
/** * Returns if this tone id is the sharped id of the tone. * * @param id the id of the tone. * @return if the tone id is the sharped id of the tone. * @throws IllegalArgumentException if neither the tone nor the * semitone have the id. * @deprecated Magic value */ @Deprecated public boolean isSharped(byte id) { if (id == getId(false)) { return false; } else if (id == getId(true)) { return true; } else { // The id isn't matching to the tone! throw new IllegalArgumentException("The id isn't matching to the tone."); } }
/** * Creates a new note. * * @param octave The octave where the note is in. Has to be 0 - 2. * @param tone The tone within the octave. If the octave is 2 the note has * to be F#. * @param sharped Set if the tone is sharped (e.g. for F#). */ public Note(int octave, Tone tone, boolean sharped) { if (sharped && !tone.isSharpable()) { tone = Tone.values()[tone.ordinal() + 1]; sharped = false; } if (octave < 0 || octave > 2 || (octave == 2 && !(tone == Tone.F && sharped))) { throw new IllegalArgumentException("Tone and octave have to be between F#0 and F#2"); } this.note = (byte) (octave * Tone.TONES_COUNT + tone.getId(sharped)); }
@Override public MCTone getTone() { return MCTone.valueOf(n.getTone().toString()); }
public BukkitMCNote(int octave, MCTone tone, boolean sharp) throws IllegalArgumentException { n = new Note(octave, Note.Tone.valueOf(tone.name()), sharp); }
/** * Returns the not sharped id of this tone. * * @return the not sharped id of this tone. * @deprecated Magic value */ @Deprecated public byte getId() { return getId(false); }
/** * Returns the tone of this note. * * @return the tone of this note. */ public Tone getTone() { return Tone.getById(getToneByte()); }
@Override public String toString() { return "Note{" + getTone().toString() + (isSharped() ? "#" : "") + "}"; } }
/** * Creates a new note for a flat tone, such as A-flat. * * @param octave The octave where the note is in. Has to be 0 - 1. * @param tone The tone within the octave. * @return The new note. */ public static Note flat(int octave, Tone tone) { Validate.isTrue(octave != 2, "Octave cannot be 2 for flats"); tone = tone == Tone.G ? Tone.F : Tone.values()[tone.ordinal() - 1]; return new Note(octave, tone, tone.isSharpable()); }
@Override public String toString() { return "Note{" + getTone().toString() + (isSharped() ? "#" : "") + "}"; } }
/** * Returns the not sharped id of this tone. * * @return the not sharped id of this tone. * @deprecated Magic value */ @Deprecated public byte getId() { return getId(false); }
/** * Returns the tone of this note. * * @return the tone of this note. */ public Tone getTone() { return Tone.getById(getToneByte()); }
/** * Creates a new note for a flat tone, such as A-flat. * * @param octave The octave where the note is in. Has to be 0 - 1. * @param tone The tone within the octave. * @return The new note. */ public static Note flat(int octave, Tone tone) { Validate.isTrue(octave != 2, "Octave cannot be 2 for flats"); tone = tone == Tone.G ? Tone.F : Tone.values()[tone.ordinal() - 1]; return new Note(octave, tone, tone.isSharpable()); }