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

Send and receive note and pedal events to/from connected devices via WebMIDI #112

Merged
merged 35 commits into from
Jan 25, 2022

Commits on Jan 14, 2022

  1. Allow for multiple concurrent notifications

    There might be a rough edge or two here to be smoothed out later, but this is a solid first pass.
    simonwiles committed Jan 14, 2022
    Configuration menu
    Copy the full SHA
    679a145 View commit details
    Browse the repository at this point in the history
  2. Add some vertical space

    simonwiles committed Jan 14, 2022
    Configuration menu
    Copy the full SHA
    dcb8164 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    39e4b6a View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    5923acf View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    12e3510 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    ae66c4d View commit details
    Browse the repository at this point in the history
  7. Do not send simultaneous pedal events to external MIDI devices.

    It turns out that hardware MIDI devices are even less happy about this than the stock ToneJS Piano code, and will enter an endless loop of pedal up/down actions if sent consecutive alternative pedal up/down events without any time between them -- as is done in the SamplePlayer to silence all held/sustained notes immediately upon Pause or Rewind. Fortunately the MIDI devices I've tested sound fine on Pause or Rewind when the pedal up/down trick is not used -- in this respect as in many others, they are better performers than the ToneJS Piano.
    broadwell authored and simonwiles committed Jan 14, 2022
    Configuration menu
    Copy the full SHA
    12f7f63 View commit details
    Browse the repository at this point in the history
  8. Don't clear notifications on first roll load.

    This allows notifications about the availability of external MIDI connections (or lack thereof), the majority of which are generated just as the app is initialized, to remain on screen long enough to be read. Presumably the purpose of the `clearNotification()` call in `resetApp()` is to clear any lingering error messages from previous rolls, so it's OK not to do it when the app first runs. Note that there's still a potential problem whereby the MIDI status notifications can pile up all at once so that it's still difficult to read any of them before they disappear, but this can be handled in a subsequent update.
    broadwell authored and simonwiles committed Jan 14, 2022
    Configuration menu
    Copy the full SHA
    aff5b1c View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    b3ce94b View commit details
    Browse the repository at this point in the history
  10. Simplify pedal loop-avoidance logic

    broadwell authored and simonwiles committed Jan 14, 2022
    Configuration menu
    Copy the full SHA
    cf7fcf7 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    915b4e5 View commit details
    Browse the repository at this point in the history
  12. Add persistent config option to enable/disable Web MIDI functionality.

    There may be more elegant ways to do some of this. Destroying the <WebMidi/> component when it's not in use seems clean, although there is the minor issue of the `midi.onstatechange` handler sticking around. In any case, the checkbox renders some of the previous notifications unnecessary, and it kind of makes sense not to show the checkbox at all if Web MIDI isn't supported in the browser -- though I kind of liked the "too bad your browser can't do this" popup in the previous commits.
    broadwell authored and simonwiles committed Jan 14, 2022
    Configuration menu
    Copy the full SHA
    40a2b10 View commit details
    Browse the repository at this point in the history
  13. <SamplePlayer/> shouldn't generate and <WebMidi/> shouldn't send out-…

    …of-bounds note_on velocities
    broadwell authored and simonwiles committed Jan 14, 2022
    Configuration menu
    Copy the full SHA
    986c503 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    c3eb54e View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    9ca6f69 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    24d5f25 View commit details
    Browse the repository at this point in the history
  17. Revert "Add persistent config option to enable/disable Web MIDI funct…

    …ionality."
    
    This reverts commit 02653fa.
    simonwiles committed Jan 14, 2022
    Configuration menu
    Copy the full SHA
    4ea5fe5 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    1de25d0 View commit details
    Browse the repository at this point in the history
  19. Remove unneeded exports

    simonwiles committed Jan 14, 2022
    Configuration menu
    Copy the full SHA
    9ea4845 View commit details
    Browse the repository at this point in the history
  20. Remove checks for $userSettings.midiMessageSeen

    This exposes the **actual** issue with the `<Notification/>` component, which is that it's a singleton and is being clobbered.  Will fix in due course.
    simonwiles committed Jan 14, 2022
    Configuration menu
    Copy the full SHA
    f9a8512 View commit details
    Browse the repository at this point in the history
  21. Simple "Enable/Disable WebMIDI" button

    This isn't what it should look like, where it should go, or even how it should behave (entirely).  Other than that, it's a good commit... :)
    simonwiles committed Jan 14, 2022
    Configuration menu
    Copy the full SHA
    e31eaa6 View commit details
    Browse the repository at this point in the history
  22. Handle $activeNotes in startNote and stopNote functions

    It shouldn't be the job of the `<WebMidi/>` component to manage this.
    
    However, this does affect the way the `<Keyboard/>` component (the other client for these functions) works a little -- clicking the keys now removes the `depressed` class if it was previously applied (i.e. if the roll player state is in the middle of (a) note(s)).  This is in line with the behaviour when using the keys on a WebMIDI-connected device.
    
    If this is considered undesirable (and I think I'd lean that way, if not perhaps all that hard), then both the on-screen keyboard and WebMIDI-connected devices could could be decoupled from `$activeNotes`, but I'd rather do that with a argument to the `startNote()` and `stopNote()` functions (similar to the `fromMidi` argument).
    simonwiles committed Jan 14, 2022
    Configuration menu
    Copy the full SHA
    73a6e8a View commit details
    Browse the repository at this point in the history
  23. Refactoring

    This is some opinionated stylistic refactoring.  The main changes introduce more destructuring and switch statements (which are technically faster, but the point here is more about readability).  I think I can make the case that all of these changes are in line with modern best practices, but I'm happy to entertain counter arguments :)
    simonwiles committed Jan 14, 2022
    Configuration menu
    Copy the full SHA
    3465406 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    fb47ff1 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    511400a View commit details
    Browse the repository at this point in the history
  26. Add a MIDI settings panel

    simonwiles committed Jan 14, 2022
    Configuration menu
    Copy the full SHA
    8330419 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    39c480d View commit details
    Browse the repository at this point in the history
  28. Drop unused import

    simonwiles committed Jan 14, 2022
    Configuration menu
    Copy the full SHA
    92ad48c View commit details
    Browse the repository at this point in the history

Commits on Jan 18, 2022

  1. Avoid destruction/re-mounting of components on roll-change

    Destroying and re-mounting the right sidebar (in particular) when the roll is changed can cause problems if child components aren't destroyed properly due to outro transitions (see sveltejs/svelte#5268).  This has caused a number of bugs with the `<RollViewer/>` component not being recreated properly.
    
    One option is to eschew all outro transitions in other parts of the app; but I think a better solution in this specific case is to avoid destroying and recreating this part of the component tree unless absolutely necessary.
    simonwiles committed Jan 18, 2022
    Configuration menu
    Copy the full SHA
    666e087 View commit details
    Browse the repository at this point in the history

Commits on Jan 20, 2022

  1. Configuration menu
    Copy the full SHA
    a35c450 View commit details
    Browse the repository at this point in the history

Commits on Jan 24, 2022

  1. Configuration menu
    Copy the full SHA
    8b635d1 View commit details
    Browse the repository at this point in the history
  2. Remove unused CSS selector

    simonwiles committed Jan 24, 2022
    Configuration menu
    Copy the full SHA
    57c1273 View commit details
    Browse the repository at this point in the history

Commits on Jan 25, 2022

  1. Fade headings in/out

    This is a little nicer when enabling/disabling WebMIDI.
    simonwiles committed Jan 25, 2022
    Configuration menu
    Copy the full SHA
    954bc82 View commit details
    Browse the repository at this point in the history
  2. Prevent feedback loops from external MIDI pedal devices

    Pedal events send to external MIDI devices can be re-emitted back to the app (under at least some circumstances), causing feedback loops.  With this commit, external pedal events are ignored unless explicitly enabled, in which case "app-side" pedal events are disabled instead.
    broadwell authored and simonwiles committed Jan 25, 2022
    Configuration menu
    Copy the full SHA
    c3872be View commit details
    Browse the repository at this point in the history
  3. Styling update

    simonwiles committed Jan 25, 2022
    Configuration menu
    Copy the full SHA
    cf6a22b View commit details
    Browse the repository at this point in the history