Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on May 29, 2023. It is now read-only.
/midiPublic archive

An Observable based library for the use of Web MIDI API with Angular

License

NotificationsYou must be signed in to change notification settings

ng-web-apis/midi



Attention! This repository is archived and the library has been moved totinkoff/ng-web-apis monorepository



ng-web-apis logo Web MIDI API for Angular

Part ofWeb APIs for Angular

npm versionnpm bundle sizeTravis (.com)Coveralls githubangular-open-source-starter

This library contains abstractions and helpful utils to useWeb MIDI API idiomatically with Angular.

Install

If you do not have@ng-web-apis/common:

npm i @ng-web-apis/common

You would also need@types/webmidi package until it is included in TypeScript. Now install the package:

npm i @ng-web-apis/midi

Usage

To useWeb MIDI API with your Angular application you canuse tokens, RxJs operators and utils included with this package:

Tokens

  • MIDI_SUPPORTboolean value checking browser support
  • SYSEXboolean token responsible for system exclusive access,false by default
  • MIDI_ACCESS — aPromisewithMIDIAccess object,depends onSYSEX token for access level
  • MIDI_INPUT — aPromisewithMIDIInput. You would need toprovide it yourself see utility functions below
  • MIDI_OUTPUT — aPromisewithMIDIOutput. You would need toprovide it yourself see utility functions below
  • MIDI_MESSAGES — an Observable ofMIDIMessageEventfrom allMIDIInputs,use rxjs function below to narrow and process the stream

Utility functions

  • You can provideMIDI_INPUT andMIDI_OUTPUT tokens with following functions:

    inputById,inputByName,outputById,outputByName:

import{Component,Inject}from'@angular/core';import{inputById,MIDI_INPUT,MIDI_OUTPUT,outputByName}from'@ng-web-apis/midi';@Component({selector:'my-comp',template:'...',providers:[inputById('input-0'),outputByName('VirtualMIDISynth')],})exportclassMyComponent{constructor(        @Inject(MIDI_INPUT)input:Promise<MIDIInput>,        @Inject(MIDI_OUTPUT)output:Promise<MIDIOutput>,){}}
  • You can convert MIDI note to frequency and back usingtoFrequency andtoNote functions.They optionally accept second argument for tuning of middle A note using 440 as default value
  • You can usefrequency pipe fromFrequencyPipeModule to convert MIDI note to frequencydirectly in template

RxJs operators

Monotype operators

These are filtering operators which you can use onMIDI_MESSAGES stream to narrow it to your needs.All of them are applied like that:

messages$.pipe(filterByChannel(1),aftertouch(),);
  • filterByChannel only lets through messages from given channel(0 to 15)
  • filterById only lets through messages from particularMIDIInputidentifying it byid property
  • filterByName only lets through messages from particularMIDIInputidentifying it byname property
  • notes only lets through played notes messages,normalizing noteOff messages to noteOn with 0 velocity
  • aftertouch only lets through aftertouch messages, same logic goes fow all functions below
  • modulationWheel
  • pan
  • pitchBend
  • polyphonicAftertouch
  • programChange
  • sustainPedal

If you believe other operators could be helpful, pleasefile an issue explaining whatwould you like to be added and why.

Operators

These are used to convert message to something necessary for you, since it turnsMIDIMessageEventsto different objects, use itafter all monotype operations from the list abovehave been applied.

Keep in mind some messages might not contain third or even second byte so only use thoseextractions when you are sure (i.e. filtered the stream to compliant messages beforehand).

Demo

You cantry online demo here

See also

OtherWeb APIs for Angular by@ng-web-apis

Open-source

Do you also want to open-source something, but hate the collateral work?Check out thisAngular Open-source Library Starterwe’ve created for our projects. It got you covered on continuous integration,pre-commit checks, linting, versioning + changelog, code coverage and all that jazz.

About

An Observable based library for the use of Web MIDI API with Angular

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Sponsor this project

    Packages

    No packages published

    Contributors3

    •  
    •  
    •  

    [8]ページ先頭

    ©2009-2025 Movatter.jp