2

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.

4

1 回答 1

0

如果你在网上使用你的 SF 说:

yoursoundfont.stop(youraudioontext.currentTime + 0.0);

当您停止音符时说 0.0 立即结束

于 2021-06-03T09:16:37.837 回答