playsound/sound engine pitch algorithm isn't working properly
When using the /playsound command to replicate musical notes, it is important that the notes are tuned correctly. However this does not appear to be the case, as sometimes notes are slightly sharp or flat when they shouldn't be.
To Reproduce:
1. Create a test world
2. Place a repeating command block, set to "always active", with the following command:
/playsound block.note.harp master @p ~ ~ ~ 1 1 1
A note should begin playing.
3. Change the command to
/playsound block.note.harp master @p ~ ~ ~ 1 1.05946309436 1
A new note will begin playing. It should be exactly 1 semitone higher, however it is off by more than 20 cents. If you actually wanted to play the note 20 cents lower, you should type
/playsound block.note.harp master @p ~ ~ ~ 1 1.04729412282 1
You may need an equal-tempered tuner to properly conduct the measurements.
Environment
Mac OS X 10.11
MacBook Pro Late 2011 Edition
Linked Issues
- Fixed
Ely G
[Mojang] Grum (Erik Broes)- 8
- 7
- Plausible
15w40b - 1.9.4
15w40b 15w41b 15w43a 15w44a 15w44b 15w45a 15w46a 15w47a 15w47b 15w47c 15w49a 15w49b 15w50a 15w51a 15w51b 16w02a 16w03a 16w04a 16w05a 16w05b 16w06a 16w07a 16w07b 1.9-pre1 1.9-pre2 1.9-pre3 1.9-pre4 1.9 1.9.1-pre1 1.9.1-pre2 1.9.1-pre3 1.9.1 1.9.2 16w14a 16w15a 16w15b 1.9.3-pre1 1.9.3-pre2 1.9.3-pre3 1.9.3 1.9.4- 16w20a
Created Issue:
/playsound pitch algorithm isn't working properly
When using the /playsound command to replicate musical notes, it is important that the notes are tuned correctly. However this does not appear to be the case, as sometimes notes are slightly sharp or flat when they shouldn't be.
To Reproduce:
1. Create a test world
2. Place a repeating command block, set to "always active", with the following command:/playsound note.harp @p ~ ~ ~ 1 1 1A note should begin playing.
3. Change the command to
/playsound note.harp @p ~ ~ ~ 1 1.05946309436 1A new note will begin playing. It should be exactly 1 semitone higher, however it is off by more than 20 cents.
You may need an equal-tempered tuner to properly conduct the measurements.
Environment
Mac OS X 10.11
MacBook Pro Late 2011 Edition
When using the /playsound command to replicate musical notes, it is important that the notes are tuned correctly. However this does not appear to be the case, as sometimes notes are slightly sharp or flat when they shouldn't be.
To Reproduce:
1. Create a test world
2. Place a repeating command block, set to "always active", with the following command:/playsound note.harp @p ~ ~ ~ 1 1 1A note should begin playing.
3. Change the command to
/playsound note.harp @p ~ ~ ~ 1 1.05946309436 1A new note will begin playing. It should be exactly 1 semitone higher, however it is off by more than 20 cents.
You may need an equal-tempered tuner to properly conduct the measurements.
When using the /playsound command to replicate musical notes, it is important that the notes are tuned correctly. However this does not appear to be the case, as sometimes notes are slightly sharp or flat when they shouldn't be.
To Reproduce:
1. Create a test world
2. Place a repeating command block, set to "always active", with the following command:/playsound note.harp @p ~ ~ ~ 1 1 1A note should begin playing.
3. Change the command to
/playsound note.harp @p ~ ~ ~ 1 1.05946309436 1A new note will begin playing. It should be exactly 1 semitone higher, however it is off by more than 20 cents. If you actually wanted to play the note 20 cents lower, you should type
/playsound note.harp @p ~ ~ ~ 1 1.04729412282 1You may need an equal-tempered tuner to properly conduct the measurements.
When using the /playsound command to replicate musical notes, it is important that the notes are tuned correctly. However this does not appear to be the case, as sometimes notes are slightly sharp or flat when they shouldn't be.
To Reproduce:
1. Create a test world
2. Place a repeating command block, set to "always active", with the following command:/playsound block.note.harp @p ~ ~ ~ 1 1 1A note should begin playing.
3. Change the command to
/playsound block.note.harp @p ~ ~ ~ 1 1.05946309436 1A new note will begin playing. It should be exactly 1 semitone higher, however it is off by more than 20 cents. If you actually wanted to play the note 20 cents lower, you should type
/playsound block.note.harp @p ~ ~ ~ 1 1.04729412282 1You may need an equal-tempered tuner to properly conduct the measurements.
/playsound pitch algorithm isn't working properlyplaysound/sound engine pitch algorithm isn't working properly
relates to
When using the /playsound command to replicate musical notes, it is important that the notes are tuned correctly. However this does not appear to be the case, as sometimes notes are slightly sharp or flat when they shouldn't be.
To Reproduce:
1. Create a test world
2. Place a repeating command block, set to "always active", with the following command:/playsound block.note.harp master @p ~ ~ ~ 1 1 1A note should begin playing.
3. Change the command to
/playsound block.note.harp master @p ~ ~ ~ 1 1.05946309436 1A new note will begin playing. It should be exactly 1 semitone higher, however it is off by more than 20 cents. If you actually wanted to play the note 20 cents lower, you should type
/playsound block.note.harp master @p ~ ~ ~ 1 1.04729412282 1You may need an equal-tempered tuner to properly conduct the measurements.
eu adoro jogar minecraft mais esta muito cara 100,00 rewais isso é um robo um jogo por 100,00 reais deveria ser uns 12,00 reais estorando iria render muito mais aqui no brasil porque todas amam jogar esse jogo mais no computador é um absurdo tente abaixar o presso de renda de 5 messes a baixa porque não temos condisão de pagar 100,00 reais no jogo minecraft se esfosse e tenha um bom coração
Does MC-89848 describe your issue?
I'm not sure what to make of this in all honesty
Is the difference a linear thing? Can this be solved by simply multiplying by a fixed ratio?
I'm not sure. Seems random. Here is the world I was testing the tunings with, though it uses custom sounds tuned exactly C, and still is off. Perhaps it's a system issue?
I've done a bit more testing, and I've found significant differences between 1.8 and the snapshots, leading me to believe that this is a software issue. It doesn't only apply to pitches in /playsound, though; regular note blocks are also affected. Observing for the piano instrument, I noticed that in 1.8.8 the B was more in tune while in 15w44a the B♭ and C♯ were the most in tune. The F♯ was pretty good in both versions and the G,A♭,A, and E♭ were poorly tuned in both. Here is the world I was using for testing, and Here is the tuning app I was using.
Also: Here is the log file during one session of the testworld:
Now the event name isn't note.harp anymore, it's block.note.harp (check
MC-91102); might be good to change the description.Done.
Unless someone gives a code-solution for this one I do not think we're going to be able to debug this.
What are the results of your testing?
I do not know what to test. I do not know why you say that 1.05946309436 is supposed to be one semitone higher. What is that number based on?
I have no sound background of any sort, I wouldn't know what to test, how to verify or how to decide what should be the 'solution'. (and no I do not have an ios device to use your app on).
This is why I suggested that a code solution would be best, I have no idea where to start.
1 semitone is a musical interval. It is what you get when you play the middle C on a piano and then play a C#. If a note has a frequency f, then the note 1 semitone higher will have a frequency of f*2^(1/12). The problem I'm getting is that when I use that double value, which is very close to 2^(1/12), as my pitch parameter, I get a note that is slightly less than 1 semitone higher; rather I get a note that is about 80 cents (a cent is 1/100 of a semitone) higher than the original frequency, or if the initial frequency is f, the resultant frequency I am getting is closer to f*2^(80/1200).
There are plenty of tuner apps for android, by the way.
So actually found what is going on.
When we send the pitch over the wire we multiply it by a constant and then when it gets off the wire, we divide again. This all so it fits in a single byte but in process this destroys accuracy on a linear scale.
The broken version:
float PITCH_ACCURACY = Byte.MAX_VALUE / 2f;
The 'working version':
float PITCH_ACCURACY = Byte.MAX_VALUE / 2;
For 1.10 I'll remove this completely and just send the raw float we have over the wire, that is far more accurate especially since pitch is not a linear scale.
Thanks! I'll be sure to test this when 1.9.3 comes out and report back.
So I tested it in 1.9.3 and it's definitely better than it was before. Some of the notes were still off when testing with noteblocks. When testing with a command block I found that
was still giving me a note that was about 20 cents flat. I suspect that keeping full float precision will fix this, so I'd mark it as fixed for 1.10. When it comes I'll be sure to do more testing.
yes! Tested in 1.10 and it's finally fixed! I'm curious; now that pitch is sent as floating point, are we still limited to just 1 octave? Or will that limit be lifted?