Skip to content

MIDI file generated by MidiFileGenerator is unusable #943

@kyledecot

Description

@kyledecot

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Screen Shot 2022-08-20 at 12 01 58 PM

Attempting to load the .mid file generated by code similar that found at Generating Midi Files via MidiFileGenerator into a 3rd party synthesizer yields an error.

For example, attempting to load the midi file into FluidSynth yields fluidsynth: error: Unrecognized MIDI event:

Screen Shot 2022-08-20 at 11 35 44 AM

Attempting to load the midi file into Online Sequencer yields Could not parse MIDI file: Invalid event: first byte must be greater than or equal to 0x80:

Screen Shot 2022-08-20 at 11 18 07 AM

Finally, attempting to load the midi file into Guitar Pro will load the file however the notes are incorrect and the instrument has changed from Guitar to Piano.

Screen Shot 2022-08-20 at 11 47 21 AM

Expected Behavior

Generated .mid file should play in 3rd party synthesizers without issue.

Steps To Reproduce


# NodeJS Application

export class MidiService implements IMidiService {
  async generate(buffer: Buffer): Promise<Uint8Array> {
    const settings = await this.createSettings();
    const score = await this.createScore(buffer, settings);
    const midiFile = await this.createMidiFile();
    const handler = await this.createMidiFileHandler(midiFile);
    const generator = await this.createMidiGenerator(score, null, handler);

    generator.generate();

    return midiFile.toBinary();
  }

const midiService = new MidiService();
const response = await fetch(URL);
const arrayBuffer = await response.arrayBuffer();
const buffer = Buffer.from(arrayBuffer);
const generatedMidi = await this.midiService.generate(buffer);

writeFileSync(PATH, generatedMidi);

Link to jsFiddle, CodePen, Project

No response

Found in Version

1.3-alpha

Platform

Node.js

Environment

- **OS**: MacOS 12.5
- **Browser**: Chrome
- **.net Version**: N/A

Anything else?

sample.zip

Metadata

Metadata

Assignees

Labels

area-playerRelated to the audio playback engine.platform-allAffects all platformsstate-acceptedThis is a valid topic to work on.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions