Comments (4)
Just a note: if you want to make changes to event.data
then you also need to update the length
property, otherwise it gets truncated to the old length:
if (event.subtype === 1) {
event.data = "updated text here!".split("").map(ch => ch.charCodeAt(0));
event.length = event.data.length;
}
from midifile.
I actually didn't document the MIDIFile write functions since i think it is still experimental. Feel free to document it, i'll accept any PR doing so.
from midifile.
Here's an example of transforming a MIDI file, simplified from midiflip:
var MIDIFile = require("midifile");
var MIDIEvents = require("midievents");
var midiFile = new MIDIFile(inputArrayBuffer);
for(var track_index = 0; track_index < midiFile.tracks.length; track_index++){
var events = midiFile.getTrackEvents(track_index);
for(var i=0; i<events.length; i++){
var event = events[i];
if(event.type === MIDIEvents.EVENT_MIDI){
if(event.subtype === MIDIEvents.EVENT_MIDI_NOTE_OFF || event.subtype === MIDIEvents.EVENT_MIDI_NOTE_ON){
event.param1 = 127 - event.param1;
}
}
}
midiFile.setTrackEvents(track_index, events);
}
var outputArrayBuffer = midiFile.getContent();
There should be documentation for individual methods though.
from midifile.
@1j01 i like midiflip, a very good use of midifile ;). I'll try it soon.
On documentation, i know, shame on me but i do not ever use midifile, just wrote it cause i wanted to know if i could.
But the good news is that i merge PRs or even add rights to people wanted to get involved on it ;).
That said, the MIDI standards aren't changing that often and except documentation/tests/refactoring i don't think there is that much work.
I'll probably make an ES6 refactoring sometime and add JSDocs but can't tell when.
from midifile.
Related Issues (20)
- Running status not allowed HOT 8
- Fix browser support badge/build HOT 1
- Incorrect path to webMIDIAPIShim in tests/index.html. Incorrect handling of midiOutput HOT 1
- Uncaught (in promise) TypeError: createParser is not a function HOT 1
- stream.end is not a function running example code HOT 3
- Fix dist build. HOT 8
- Reading MIDI track labels as String HOT 2
- Uncaught ReferenceError: MIDIFileHeader is not defined HOT 3
- Getting events for large midi's (black midis) takes FOREVER HOT 5
- Add Audio engine to play notes HOT 19
- Add more musical instruments
- midi file unsupported (apparently) HOT 6
- How to read a midi file to get the ArrayBuffer? HOT 2
- Please provide single-file version to use in browser (.js and .min.js) HOT 1
- Is the playTime of the lyrics in milliseconds? HOT 1
- Use correct pitch-bend range HOT 4
- Merge improvements (pitch bend, `parseSong()`, ...) from `webaudiofont` HOT 10
- Argument missing HOT 1
- variable declared twice HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from midifile.