Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pitch bending in webaudio #247

Open
algorithmixx opened this issue Feb 3, 2019 · 2 comments
Open

pitch bending in webaudio #247

algorithmixx opened this issue Feb 3, 2019 · 2 comments

Comments

@algorithmixx
Copy link

Currently plugin.webaudio.js plays samples from the soundfont buffers always at their original pitch because the playbackRate is set to a constant value of 1. This means that pitch bend commands do not have any effect.

I added a bend parameter to the midi.noteOn() function and used its value to set the source.playbackRate.value. Thus one can shift the pitch of a note by some amount (typically less than a semitone). My implementation does not create a glissando effect - it simply changes the pitch of the note by some cents.

My intention was to use the new bend parameter to achieve just intonation, so all my pitch bend corrections are within a range of +/- 20 cents.

As you cannot expect a midi file to contain all the tiny bend changes which are necessary to produce just intonation (or other scale systems like "Werckmeister") I added a user definable callback function
to player.js in function startAudio() to the case statement for noteOn, noteOff. The callback function calculates bend changes based on just intonation (for a certain key) and returns its result to startAudio(). There the new bend parameter gets added to the schedule and will later be applied when the noteOn function of plugin.webaudio.js is called. In standard MIDI pitch bends apply to all notes of a track. My implementation does not have this restriction because it manipulates single noteOn events.

By the way: the same callback could also perform other manipulations like muting a track, applying transpositions, changing dynamics etc.

I suggest to add these two features (pitch bends and a user definable callback during the schedule creation phase) to MIDI.js.

@shivrajsa
Copy link

Please check this pull request which detune notes by cents
#207

@algorithmixx
Copy link
Author

Thanks! Algorithmixx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants