I've been building a music notation application in Flask. On the backend I'm using Midiutil to generate midi files and Midi.js on the front end to play the files.
I recorded and built my soundfont using Polyphone and converted from sf2 to JS with soundfont_builder.rb.
The problem I am now facing is that the soundfont_builder is causing prolonged decay to the notes which I don't want.
def generate_midi(program, note_value, file)
include MIDI
seq = Sequence.new()
track = Track.new(seq)
seq.tracks << track
track.events << ProgramChange.new(0, Integer(program))
track.events << NoteOn.new(0, note_value, VELOCITY, 0) # channel, note, velocity, delta
track.events << NoteOff.new(0, note_value, VELOCITY, DURATION)
Is there a way to navigate this so that my notes will play no longer or shorter than the length defined by the midi file?
I've tested my midi files with FluidSynth locally and they play normally as I want.
if you are using your sf online say:
yoursoundfont.stop(youraudioontext.currentTime + 0.0);
When you stop the note say 0.0 to end instantly