Documentation request for "procedural generate music and play" wiki page

Issue #19 closed
follower created an issue

On the project wiki home page there is a link labeled "procedural generate music and play" but the linked page https://bitbucket.org/arlez80/godot-midi-player/wiki/how_to_use/procedural does not exist.

Has this page been written and the problem is just a broken link? Or does the page content still need to be written?

I'm wanting to add audio generation to my Godot MIDI input demo project for which initially I'd like to play a note directly but eventually could also be used to create a MIDI sequence.

I've looked through the godot-midi-player code a bit to try to figure out how to trigger a SoundFont instrument to play directly but haven't tracked down all the details yet.

If documentation could be added on how to play a SoundFont instrument directly and how to generate a MIDI sequence dynamically it would be helpful.

Thanks!

Comments (6)

  1. follower reporter

    Quick note as I've managed to get something to work. :)

    With a correctly configured MidiPlayer node using (res://data/test.mid & res://data/TimGM6mb.sf2) and a button in your scene and with the following scripts attached pressing the button should result in drum sounds:

    ## Main.gd
    
    extends Node
    
    func _ready():
        print($"MidiPlayer".file)
        print($"MidiPlayer".soundfont)
    
        # play()/stop() sequence ensures everything is initialised
        $"MidiPlayer".play()
        $"MidiPlayer".stop()
    
    # Button.gd
    
    extends Button
    
    var bnk
    
    func _on_Button_pressed():
    
        bnk = $"../../MidiPlayer".bank
    
        print($"../../MidiPlayer".bank)
    #   print($"../../MidiPlayer".bank.presets[0]) ## Note: printing anything .presets causes a crash.
    
        # Play a random drum sound on each button press       
        var channel = $"../../MidiPlayer".channel_status[9]
        var event = {
                        "type": $"../../MidiPlayer".SMF.MIDIEventType.note_on,
                        "note": 38 + (randi() % 10), #48, #42,
                        "velocity": 100,
                    } # via SMF.gd
    
    
        $"../../MidiPlayer"._process_track_event_note_on(channel, event)
    

    Edit: Additionally:

        var channel = $"../../MidiPlayer".channel_status[4] # A piano.
    
        var channel = $"../../MidiPlayer".channel_status[(randi() % 10)] # Random piano/drum avant-garde procedurally generated idle clicker game button generator. :D
    
  2. Log in to comment