Closed davidbau closed 10 years ago
OK, I've incorporated James Synge's first batch of comments (so far he has reviewed the Piano sprite code but not yet the audio support).
In _doPoll, James suggests accumulating all callbacks into an array and then calling them all at once.
James also suggests that, if there is an array of callbacks, _doPoll could sort events by the relevant time.
Suggestion: make _doPoll's relationship with "now()" more robust.
Comment from James:
Add a comment on the structure of a note (decorations - accidentals - pitch - duration - ties)
Make header comment reflect the presence of "V:" header properly
Consider renaming stem[j].note ->stems[j].notes
Consider, instead of ugly id-switching handling, just cleanup empty voices at the end of parseABC
Key signature "extras" logic doesn't work. Consider removing.
if (parsed !== null) in "Process a parsed stem" isn't needed.
OK, I've incorporated code review comments from James (thanks James for reading the code together over several breakfasts!) I'm merging and pushing.
Congratulations! That is a really nice new feature.
Jamrs On May 30, 2014 10:46 PM, "David Bau" notifications@github.com wrote:
Merged #67 https://github.com/PencilCode/jquery-turtle/pull/67.
— Reply to this email directly or view it on GitHub https://github.com/PencilCode/jquery-turtle/pull/67#event-126672852.
This pull request is a significant improvement for music support in the library:
(1) The "Piano" object is now built-in to the library instead of requiring a separate import.
(2) Each turtle has a "turtleTimbre" property that lets you set 9 numbers (and an oscillator waveform) to determine the quality of the sound of an instrument. The timbre can also be set for a specific song or a specific voice of a song. For example, a piano timbre corresponds to this css call:
wave: sawtooth (vs square, triangle, sine - from the Web Audio standard) Then the ADSR envelope: attack: seconds to ramp up from zero when starting a note decay: seconds to decay (exponentially, by a factor of e) after the attack. sustain: the asymptotic volume that you decay to after a while. release: seconds to go to zero after a note is released. Then some things for the quality of the note: cutoff: cutoff frequency for a low-pass filter. cutfollow: for notes with a principal frequency higher than the cutoff, how much to raise cutoff (as a factor of the frequency difference). resonance: the Q value for the low-pass filter, which boosts the principal frequency. detune: frequency for a second (detuned) oscillator, relative to the primary.
(3) In addition to "play" there is a lower-level "tone" method that kids can use to just play a tone immediately without sequencing. It takes either an ABC pitch string or a numeric Hertz value. tone('C') to play a C, then tone('C', 0) to turn it off again.
(4) And there are "noteon" and "noteoff" callbacks: the Instrument base class of Piano sets these up, and you can override them to do various effects when a note is played. The callback is passed an object with a midi number for the note that is turning on or off.