Skip to content

CMD-R causes note F4 to play - can lead to stuck notes when controlling MIDI #47

Description

@abulka

A little known feature of the keyboard control is that you can play it with the computer QWERTY keyboard e.g.

Q  C4
W  D4
E  E4
R  F4
etc.

however the state of ctrl/shift/meta is not checked, meaning that e.g. both R and SHIFT-R will play F4.

Unfortunately CMD-R will also play F4 - which is leading to stuck notes when I refresh my midi app web page! You see, I use the standard CMD-R to reload the browser page (to load the latest code), and just before the reload, a F4 noteon is send to my midi device - because of the R in CMD-R. A subsequent noteoff is never send because the browser app has now just reloaded and is in a starting state, with no knowledge of what happened before.

Here is the webaudio-controls.js code which I think should be changed to check for the state of ctrl/shift/meta and only send keyboard events when no modifier key is pressed.

  keydown(e){
      let m=Math.floor((this.min+11)/12)*12;
      let k=this.keycodes1.indexOf(e.keyCode);
      if(k<0) {
        k=this.keycodes2.indexOf(e.keyCode);
        if(k>=0) k+=12;
      }
      if(k>=0){
        k+=m;
        if(this.currentKey!=k){
          this.currentKey=k;
          this.sendEventFromKey(1,k);
          this.setNote(1,k);
        }
      }
    }

Also, arguably this "playing via keyboard" feature should be documented and an attribute added to control whether the developer wants this feature on, as it could interfere in other ways with a web app.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions