Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Apr 1, 2021
1 parent 7abb019 commit 05075ee
Show file tree
Hide file tree
Showing 73 changed files with 68,255 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"presets": [
[
"@babel/preset-env",
{
"modules": "umd"
}
]
]
}
65 changes: 65 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
module.exports = {
"parser": '@typescript-eslint/parser',
"plugins": [
'@typescript-eslint',
],
"extends": ["plugin:@typescript-eslint/recommended"],
"rules": {
"dot-location" : [ "error", "property" ],
"linebreak-style": [ "error", "unix" ],
"eqeqeq" : [ "error" ],
"curly" : [ "error", "all" ],
"dot-notation" : [ "error" ],
"no-throw-literal" : [ "error" ],
"no-useless-call" : [ "error" ],
"no-unmodified-loop-condition": [ "error" ],
"quote-props" : [ "error", "as-needed" ],
"quotes": [ "error","double" ],
"no-shadow" : "error",
"no-console": ["error", { "allow": ["warn"] }],
"@typescript-eslint/no-object-literal-type-assertion" : "off",
"@typescript-eslint/no-unused-vars": "off",
"sort-imports": ["error", {
"ignoreCase": true,
"ignoreDeclarationSort": true,
"ignoreMemberSort": false,
"memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
}],
"no-lonely-if" : [ "error" ],
"semi": [ "error", "always" ],
"no-cond-assign" : ["error", "always"],
"indent": "off",
"no-var": "error",
"prefer-arrow-callback": "error",
"@typescript-eslint/indent": [ "error", "tab", { "SwitchCase": 1 } ],
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/explicit-function-return-type" : "off",
"no-multi-spaces" : [ "error" ],
"array-bracket-spacing" : [ "error" , "never" ],
"block-spacing": [ "error", "always" ],
"func-call-spacing" : [ "error", "never" ],
"key-spacing" : [ "error", {"beforeColon" : false, "afterColon" : true} ],
"brace-style": [ "error", "1tbs" ],
"space-in-parens": [ "error", "never" ],
"eol-last": [ "error", "always" ],
"@typescript-eslint/no-explicit-any" : "off",
"@typescript-eslint/no-use-before-define" : "off",
"@typescript-eslint/array-type" : "off",
"spaced-comment": [ "error", "always", {
"line": { "exceptions": ["-"] },
"block" : { "balanced" : true },
}],
"lines-between-class-members": "off",
"no-multiple-empty-lines": [ "error", { "max": 1, "maxEOF": 1, "maxBOF": 0} ],
"no-unneeded-ternary": [ "error" ],
"object-curly-spacing": [ "error" , "always" ],
"space-unary-ops": [ "error" , { "words" : true, "nonwords" : false } ],
"block-spacing" : ["error", "always"],
"keyword-spacing" : ["error", { "before": true }],
"space-before-function-paren": ["error", {"anonymous": "never", "named": "never", "asyncArrow": "always"}],
"comma-spacing": ["error", { "before": false, "after": true }],
"arrow-spacing": ["error", { "before": true, "after": true }],
"space-before-blocks": ["error", { "functions": "always", "keywords": "always", "classes": "always" }]
}
};

17 changes: 17 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: wontfix
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
node_modules

test/index.js
coverage/**
.nyc_output/**

TODO.txt
**.js.map
.DS_Store
build
dist
coverage.lcov
index.d.ts
out/
.vscode
docs
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
sudo: false
dist: trusty
language: node_js
node_js: "10"
script:
- npm test
- npm run lint
after_success:
- npm run codecov
before_deploy:
- npm run increment
- npm run build
deploy:
- provider: npm
skip_cleanup: true
email: [email protected]
api_key: $NPM_TOKEN
on:
repo: Tonejs/Midi
# don't publish on cron or PRs
condition: $TRAVIS_EVENT_TYPE != cron && $TRAVIS_EVENT_TYPE != pull_request
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[The MIT License](http://opensource.org/licenses/MIT)

Copyright © 2016 Yotam Mann

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Binary file added examples/bach_846.mid
Binary file not shown.
66 changes: 66 additions & 0 deletions examples/load.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<!DOCTYPE html>
<html>
<head>
<title>Tonejs Midi</title>
<script type="text/javascript" src="https://unpkg.com/@tonejs/midi"></script>
<script type="text/javascript" src="https://unpkg.com/[email protected]"></script>
<script type="text/javascript" src="https://unpkg.com/@tonejs/[email protected]"></script>
</head>
<body>
<style>
#Status {
color: gray;
height: 40px;
}
</style>
<tone-top-bar></tone-top-bar>

<tone-content>
<div id="Description">Load and play Bach's <i>Prelude in C</i></div>
<div id="Status">Loading...</div>
<tone-play-toggle disabled>Loading...</tone-play-toggle>
</tone-content>

<script type="text/javascript">

Midi.fromUrl("./bach_846.mid").then(midi => {

document.querySelector('tone-play-toggle').removeAttribute('disabled')
document.querySelector('#Status').textContent = ''

//synth playback
const synths = []
document.querySelector('tone-play-toggle').addEventListener('play', (e) => {
const playing = e.detail
if (playing) {
const now = Tone.now() + 0.5
midi.tracks.forEach(track => {
//create a synth for each track
const synth = new Tone.PolySynth(10, Tone.Synth, {
envelope: {
attack: 0.02,
decay: 0.1,
sustain: 0.3,
release: 1
}
}).toMaster()
synths.push(synth)
//schedule all of the events
track.notes.forEach(note => {
synth.triggerAttackRelease(note.name, note.duration, note.time + now, note.velocity)
})
})
} else {
//dispose the synth and make a new one
while (synths.length) {
const synth = synths.shift()
synth.dispose()
}
}
})
})

</script>

</body>
</html>
Loading

0 comments on commit 05075ee

Please sign in to comment.