Accept byte stream instead of file as input

Issue #52 closed
Benjamin McLean created an issue

Godot Midi Player should not assume that the MIDI data will be coming from the file system or even that the app has access to the file system because in some situations like on mobile and web, the app may not have this access. Godot Midi Player should take in a byte stream of the MIDI data as input. It would then be up to outside code to decide whether that byte stream comes from a file or a byte array in RAM or a web api or wherever else it might come from.

In the case of my own project https://github.com/BenMcLean/WOLF3D-Godot the MIDI data I need to play is embedded inside the id software AudioT format in the 1996 game Super 3D Noah’s Ark. I’ve got code that can extract the MIDI data but I don’t want to put it on the file system: I want to play it from a byte array.

Comments (5)

  1. きのもと結衣 repo owner

    Already implemented since first version. You can play raw SMF data as following code:

    const SMF = preload( "res://addons/midi/SMF.gd" )
    
    var smf_reader = SMF.new( )
    var data:PoolByteArray = your_extracted_midi_data
    $MidiPlayer.smf_data = smf_reader.read_data( data )
    $MidiPlayer.play( )
    

  2. Log in to comment