Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Note {
- public enum Lengths {
- DOUBLE_WHOLE_NOTE(0.5f),
- ...
- SIXTYFOURTH_NOTE(64);
- private float length;
- Lengths(float length) {
- this.length = length;
- }
- public float getLength() {
- return length;
- }
- private static final Map<Float, Lengths> lookup = new HashMap<Float, Lengths>();
- static {
- for (Lengths length : Lengths.values())
- lookup.put(length.getLength(), length);
- }
- public static Lengths get(float length) {
- return lookup.get(length);
- }
- }
- public enum Names {
- C(0),
- ...
- REST(-1);
- private final int number;
- Names(int number) {
- this.number = number;
- }
- public int getValue() {
- return number;
- }
- private static final Map<Integer, Names> lookup = new HashMap<Integer, Names>();
- static {
- for (Names name : Names.values())
- lookup.put(name.getValue(), name);
- }
- public static Names get(Integer value) {
- return lookup.get(value);
- }
- }
- private int pitch;
- private float length;
- public int getPitch() {
- return pitch;
- }
- public void setPitch(int pitch) {
- this.pitch = pitch;
- }
- public float getLength() {
- return length;
- }
- public void setLength(float length) {
- this.length = length;
- }
- private Note(int pitch, float length) {
- this.length = length;
- this.pitch = pitch;
- }
- public int getOctave() {
- return (pitch / 12) - 5;
- }
- public Note.Names getNameOfNote() {
- return Names.get(this.getPitch() % 12);
- }
- public Note.Lengths getLengthOfNote() {
- return Lengths.get(this.getLength());
- }
- }
- Cars audi = new Cars();
- Car bmw = new Car();
- public float getLength() {
- return length;
- }
- public float getDuration() {
- return duration;
- }
- public Note.Names getNameOfNote() {
- return Names.get(this.getPitch() % 12);
- }
- public int getPitchClass() {
- return (this.getPitch() % 12 + 12) % 12;
- }
- public Note.Names getScientificPitchClassName() {
- return Names.get(this.getPitchClass());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement