Render audio data immediately instead of playing it

Issue #57 invalid
Rui Curado created an issue

Hi. First, thank you for this add-on. It’s great!

I want to use GMP to create music, and therefore I want to save the resulting audio to a file. To do this, I’ve modified MidiPlayer.gd to include a Audio Record effect:

func _ready()
...
    audioRecordEffect = AudioEffectRecord.new()
    AudioServer.add_bus_effect(midi_master_bus_idx, audioRecordEffect)

And added a save() function:

func save():
    var recording = audioRecordEffect.get_recording()
    recording.save_to_wav("recording")

(FYI, There are more changes than these shown)

However, this only works in realtime!! I mean, if I want to output a 5 minute song, I’ll have to wait 5 minutes to get the resulting audio!

Can you develop a way to render the resulting audio at once, and get it as a PoolByteArray or something like that?

Thanks!

Comments (2)

  1. 1234ab

    I was looking to get raw audio (wav, ogg, mp3) imported into gdscript as raw samples, but I don’t think Godot can do something like that. I solved it with moving some parts to GDNative and using an external library. I don’t think you can do it (easily) in GDscript and it maybe won’t be that much faster either (compared to real time), gdscript is very slow when looping through 10 000 000 size arrays.

  2. きのもと結衣 repo owner

    Godot MIDI Player is player not renderer.

    if you want to audio rendering with MIDI, use MIDI libraries like a TiMidity with GDNative. and I think it is too slow when only implemented by GDScript.

  3. Log in to comment