APU Note Mode (alternative version of #334) #706
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is another go at #333, but with a slightly different approach from #334.
Big thanks to @marler8997 for the detailed proposal and the other PR!
Has been tested working on both web and native.
Reasoning
Since frequencies sent to
tone
are integers, we lose quite a bit of precision when it comes to playing lower notes. This PR implements a variant of #333 to maketone
capable of playing MIDI notes. We have 16 bits per frequency, which is split up into 8 bits for the note, and 8 bits for optional pitch bend, as to not be limited to pure notes.It turns out the implementation for this is very simple (JS implementation required less than 15 lines!), and since the flag is new and optional it doesn't affect any prior carts. In my opinion this feature is overdue.
Usage
Instead of calling
tone
with frequencies, you supply it with notes. The list of MIDI notes is easily googlable and easier to use than frequencies: https://inspiredacoustics.com/en/MIDI_note_numbers_and_center_frequenciesOne could compare the pitch bends to cents between semitones in music, where 128 bend would be the equivalent to 50 cents.
Compared to #334 in short:
TONE_NOTE_MODE
flag fortone
rather than a system flag.tone(note | bend << 8, ...)
rather thantone(bend | note << 8, ...)
.)