Skip to content
This repository has been archived by the owner on Dec 13, 2024. It is now read-only.

Dev midi parser #9

Merged
merged 22 commits into from
Oct 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions OmgParser/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
root = true

[*]
indent_style = space
indent_size = 2
30 changes: 30 additions & 0 deletions OmgParser/.github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm test
137 changes: 137 additions & 0 deletions OmgParser/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
npm-debug.log
node_modules
build

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# mac config
.DS_Store
2 changes: 2 additions & 0 deletions OmgParser/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docs
src
1 change: 1 addition & 0 deletions OmgParser/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.13.2
3 changes: 3 additions & 0 deletions OmgParser/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- "10"
19 changes: 19 additions & 0 deletions OmgParser/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"type": "node",
"request": "launch",
"name": "Run Mocha",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"stopOnEntry": true,
"args": [
"test/test.js"
]
}
]
}
15 changes: 15 additions & 0 deletions OmgParser/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "gulp",
"task": "default",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
60 changes: 60 additions & 0 deletions OmgParser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# ♬ OmgParser

**OmgParser** is a JavaScript applet which reads standard MIDI files and emits JSON events in real time.

This player does not generate any audio, but by attaching a handler to the event emitter you can trigger any code you like which could play audio, control visualizations, feed into a MIDI interface, etc.

## Demos

To be updated... 👀

## Getting Started

Using MidiWriterJS is pretty simple. Create a new player by instantiating `MidiPlayer.Player` with an event handler to be called for every MIDI event. Then you can load and play a MIDI file.

```js
const MidiPlayer = require('midi-player-js');

// Initialize player and register event handler
const Player = new MidiPlayer.Player(function(event) {
console.log(event);
});

// Load a MIDI file
Player.loadFile('./test.mid');
Player.play();
```

## Player Events

There are a handful of events on the `Player` object which you can subscribe to using the `Player.on()` method. Some events pass data as the first argument of the callback as described below:

```js
Player.on('fileLoaded', function() {
// Do something when file is loaded
});

Player.on('playing', function(currentTick) {
// Do something while player is playing
// (this is repeatedly triggered within the play loop)
});

Player.on('midiEvent', function(event) {
// Do something when a MIDI event is fired.
// (this is the same as passing a function to MidiPlayer.Player() when instantiating.
});

Player.on('endOfFile', function() {
// Do something when end of the file has been reached.
});
```

Note that because of a common practice called "running status" many MIDI files may use `Note on` events with `0` velocity in place of `Note off` events.

## Full Documentation

[**Doc on my lark**](https://cao8drqmwu.feishu.cn/docx/AMq0djEQSoxPWNxjWM4cL6uBnOf "文档链接")

[Some test midi files](https://www.midishow.com/en/midi/5506.html "免费midi")

To be updated... 👀
Loading