How can I adjust the velocity of notes?
Closed this issue · 2 comments
NinjaNas commented
Hi, I am trying to change the velocity of notes using JZZ.widget() but the notes are still being played at 127 when I click on the piano.
I have tried doing this:
import { JZZ } from 'jzz'
import { Tiny } from 'jzz-synth-tiny'
import { Kbd } from 'jzz-input-kbd'
Tiny(JZZ)
Kbd(JZZ)
const synth = JZZ.synth.Tiny()
const newVelocity = 60
const widget = JZZ.Widget({
_receive: function (msg: any) {
msg[2] = newVelocity
this._emit(msg)
}
})
JZZ.input.Kbd(...).connect(widget).connect(synth)
jazz-soft commented
Hi!
Function connect() does not chain.
Use widget.connect(synth);
Thank you!
NinjaNas commented
Okay, it is working now!
Also, in my earlier attempts, the main problem was I had was that I forgot to connect the piano to the widget instead of the synth.
// incorrect
widget.connect(synth);
piano.connect(synth);
// correct
piano.connect(widget);
widget.connect(synth);
The tip about how connect() doesn't chain is useful though.