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

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

Open
abulka opened this issue Apr 1, 2022 · 0 comments

Comments

@abulka
Copy link
Contributor

abulka commented Apr 1, 2022

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.

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

1 participant