ComputerCraft

ComputerCraft

21M Downloads

Change speaker playNote to take rightclick ticks instead of pitch

Cruor opened this issue ยท 2 comments

commented

Using pitch for the playNote function is not intuitive unless you know music theory or by googling a chart. Counting the amount of times you have right clicked the block however is trivial, and is way more intuitive to use without having to look up details online.

For example, if you want to play the note currently you would do pitch = 2^(n / 12) where n is the amount of steps relative to the base tune value (F#4). For example G#4 is pitch = 2^(2 / 12). Even with knowledge about music theory, this isn't completely foolproof, as the base tune value would be expected to be A4 and not F#4.

Here is a snippet in Lua to convert the amount of "ticks" on the note block to the correct pitch, however i believe this should be the default behavior of the function. 2^((tick % 25 - 12) / 12) where % is the modulo operator.

commented

I'd be happy to merge this change. I suggest whoever makes it looks at the code inside BlockNoteBlock and tries to reproduce it.

commented

This is apparently the current behavior of the playNote function. I was going by the examples posted in the PR so my bad on that one. Going to PR a help file atleast.