@@ -118,6 +118,14 @@ public class Note {
|
||||
}
|
||||
}
|
||||
|
||||
private static final float[] pitchArray = new float[25];
|
||||
static {
|
||||
for (int i = 0; i <= 24; i++) {
|
||||
// See https://minecraft.wiki/w/Note_Block#Notes
|
||||
pitchArray[i] = (float) Math.pow(2, (i - 12) / 12f);
|
||||
}
|
||||
}
|
||||
|
||||
private final byte note;
|
||||
|
||||
/**
|
||||
@@ -254,6 +262,16 @@ public class Note {
|
||||
return Tone.getById(note).isSharped(note);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pitch of this note. This is the value used with
|
||||
* {@link World#playSound} or the /playsound command.
|
||||
*
|
||||
* @return the pitch
|
||||
*/
|
||||
public float getPitch() {
|
||||
return pitchArray[this.note];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
||||
Reference in New Issue
Block a user