I am trying to make a plugin that uses notes in it. I am using this for playing the sound: Code:java public void playSound(int ins, int type, int tone, int octave){ plugin.logger.info("NUM: " + ins + " " + type +" "+ tone + " "+ octave); List<String> worlds = main.GetConfig.getStringList("worlds"); float pitch = getPitch(tone); for(Player p : plugin.getServer().getOnlinePlayers()){ if(worlds.contains(p.getWorld().getName())){ if(ins == 0){ p.playSound(p.getLocation(), Sound.NOTE_PIANO, octave, pitch); } if(ins == 1){ p.playSound(p.getLocation(), Sound.NOTE_BASS, octave, pitch); } if(ins == 2){ p.playSound(p.getLocation(), Sound.NOTE_BASS_DRUM, octave, pitch); } if(ins == 3){ p.playSound(p.getLocation(), Sound.NOTE_BASS_GUITAR, octave, pitch); } if(ins == 4){ p.playSound(p.getLocation(), Sound.NOTE_PLING, octave, pitch); } if(ins == 5){ p.playSound(p.getLocation(), Sound.NOTE_SNARE_DRUM, octave, pitch); } if(ins == 6){ p.playSound(p.getLocation(), Sound.NOTE_STICKS, octave, pitch); } } } } Now my problem is the pitches. I want to have A-G on different octaves and I also want flats and sharps. This is what I am using and I am petty sure that this is wrong: Code:java private static float getPitch(int id) { switch (id) { case 0: return 0.5F; case 1: return 0.53F; case 2: return 0.56F; case 3: return 0.6F; case 4: return 0.63F; case 5: return 0.67F; case 6: return 0.7F; case 7: return 0.76F; case 8: return 0.8F; case 9: return 0.84F; case 10: return 0.9F; case 11: return 0.94F; case 12: return 1.0F; case 13: return 1.06F; case 14: return 1.12F; case 15: return 1.18F; case 16: return 1.26F; case 17: return 1.34F; case 18: return 1.42F; case 19: return 1.5F; case 20: return 1.6F; case 21: return 1.68F; case 22: return 1.78F; case 23: return 1.88F; case 24: return 2.0F; default: return 0.0F; } } Does anyone know the correct pitches?
blablubbabc Well if they work I would like to know which ones are A, B, C, D, E, F, G and find out how to convert it to a flat or sharp.
Forseth11 http://minecraft.gamepedia.com/Note_Block especially: http://minecraft.gamepedia.com/File:Noteblock_reference.png
blablubbabc So it would be like this: Code:java private static float getPitch(int id) {switch (id) {case 0: return 0.5F; //F#case 1: return 0.53F;//Gcase 2: return 0.56F;//G#case 3: return 0.6F;//Acase 4: return 0.63F;//A#case 5: return 0.67F;//Bcase 6: return 0.7F;//Ccase 7: return 0.76F;//C#case 8: return 0.8F;//Dcase 9: return 0.84F;//D#case 10: return 0.9F;//Ecase 11: return 0.94F;//Fcase 12: return 1.0F;//F#case 13: return 1.06F;//Gcase 14: return 1.12F;//G#case 15: return 1.18F;//Acase 16: return 1.26F;//A#case 17: return 1.34F;//Bcase 18: return 1.42F;//Ccase 19: return 1.5F;//C#case 20: return 1.6F;//Dcase 21: return 1.68F;//D#case 22: return 1.78F;//Ecase 23: return 1.88F;//Fcase 24: return 2.0F;//F#default: return 0.0F;}} Edit: If it is that way how do I get flats? Do I just subtract a certain amount? If so what amount?
Forseth11 I have no clue about notes, but isn't for example C# the same as flat D (and so on)? At least on a keyboard they are played with the same button, no?