Git Product home page Git Product logo

Comments (4)

mrspeaker avatar mrspeaker commented on July 19, 2024 1

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.

nfroidure avatar nfroidure commented on July 19, 2024

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.

1j01 avatar 1j01 commented on July 19, 2024

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.

nfroidure avatar nfroidure commented on July 19, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.