Skip to content

pitch bending in webaudio #247

Open
Open

Description

@algorithmixx

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.

Activity

  1. shivrajsa commented on Apr 19, 2019

    @shivrajsa

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

  2. algorithmixx commented on Apr 22, 2019

    @algorithmixx
    Author

    Thanks! Algorithmixx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions