@k-l-lambda/music-widgets
v1.0.4
Published
A package contains some music utility modules.
Readme
Music Widgets
A package contains some music utility modules.
Modules
- MIDI
- MusicNotation
- MidiPlayer
- MidiAudio
Usage
Install (via GitHub Packages registry):
- Authenticate npm to GitHub registry (once per machine):
// ~/.npmrc
@k-l-lambda:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${NPM_TOKEN}
always-auth=true
# Alternatively (npm >= 6)
# npm login --registry=https://npm.pkg.github.com --scope=@k-l-lambda- Install the package:
yarn add @k-l-lambda/music-widgets
# or
npm install @k-l-lambda/music-widgetsIn Node:
import { MIDI, MusicNotation, MidiPlayer, MidiUtils } from "@k-l-lambda/music-widgets";
// Parse a MIDI ArrayBuffer
const midi = MIDI.parseMidiData(arrayBuffer);
const notation = MusicNotation.Notation.parseMidi(midi);
const player = new MidiPlayer(midi, {
onMidi: (event, when) => {/* route to synth */},
});
player.play();In Browser (UMD):
<script src="/dist/musicWidgetsBrowser.umd.js"></script>
<script>
const { MIDI, MusicNotation, MidiPlayer, MidiAudio } = window.musicWidgetsBrowser;
// ...
</script>Vue component (piano roll):
import { MidiRoll } from "@k-l-lambda/music-widgets";
export default { components: { MidiRoll } };Development
Prerequisites:
- Node.js (LTS)
- Yarn
Install deps:
yarnBuild library and browser bundle:
yarn buildWatch mode (TS + bundle):
yarn watchTest app (midi-visualizer):
cd tests/midi-visualizer
yarn
yarn serve
# optional: in another terminal, sync parent outputs into node_modules
yarn watchPublish to GitHub Packages
The package publishes to the GitHub Packages registry at https://npm.pkg.github.com.
- Ensure you are authenticated (create a Personal Access Token with
read:packages,write:packages(anddelete:packagesif needed)):
// ~/.npmrc
@k-l-lambda:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${NPM_TOKEN}
always-auth=trueUpdate version in
package.json.Build the package (includes TS compile, lib sync, UMD bundle):
yarn build- Publish:
npm publish
# or (yarn classic delegates to npm publish)
yarn publish --new-version <semver>Notes:
- The build will emit
lib/(compiled TS + MidiAudio) anddist/(UMD bundle). - Ensure
.npmrcpoints the@k-l-lambdascope to the GitHub registry andalways-auth=true. - Package name must be scoped to the owner (
@k-l-lambda/music-widgets) and you must have permission in that org/owner. - In CI, prefer
NODE_AUTH_TOKEN/NPM_TOKENenv var matching the_authTokenused in.npmrc.
