nlaha / godot-midi

MIDI file parsing and event playback in Godot 4.1+
MIT License
52 stars 5 forks source link

Notes played but no sound. #12

Closed neebooo closed 7 months ago

neebooo commented 7 months ago

Godot version: v4.1.2.stable.voidlinux OS: Voidlinux glibc Kernel: Linux-LTS 6.3.13_1 Sound: Pipewire (but I have pipewire-pulse installed too) Extension version: 0.1.0

When I try to play a midi file using this code (I followed the tutorial in the readme)

extends Node2D

@onready var midi_player = $"MidiPlayer"
func _ready():
    midi_player.note.connect(my_note_callback)
    midi_player.play()

func my_note_callback(event, track):
    print("[Track: " + str(track) + "] Note played: " + str(event['note']))

I see

[GodotMidi] Playing
[Track: 0] Note played: 36
...

But no sound at all is being played (Sorry if I wrote this issue incorrectly This is the first time I made one)

nlaha commented 7 months ago

This addon does not play back MIDI files as audio (yet). If you want to sync the midi file playback to an audio track, you'll have to convert the midi to something like a WAV or OGG file in an external music production program and add it to an AudioStreamPlayer.

Playing back audio directly from MIDI files in Godot would require implementing a General MIDI synthesizer, it's something I'm looking into but probably won't get around to for a while as I am busy with other projects. If you feel like implementing it yourself, feel free to submit a pull request.

Something like https://github.com/schellingb/TinySoundFont seems like it would work great.

neebooo commented 7 months ago

Oh. I'm so sorry for misinterpreting the projects abilities. Thank you so much for telling me how to play audio. (This project is really cool and it still helps me with the rhythm game I am trying to make :'D)