How to save audio output to a wav file?

loliaudiololiaudio Posts: 1Member
edited December 2018 in Audio

I've created a music game that the user creates a song combining audio loops.
I would like to implement a record audio feature so the user can save his song in a wav file.

Is it possible to do it using AudioEffectRecord and AudioStreamSample.save_to_wav() ???

Could not find any examples on how to do it.
Need help on this. Anyone?

Thanks!!!


Tags :

Answers

  • TwistedTwiglegTwistedTwigleg Posts: 2,677Admin

    To the best of my knowledge, there is no way to save audio files in Godot.

    You can make a feature request on the Godot Github repository and see if one of the developers there are interested in potentially adding the functionality into the Godot core.

    You may be able to make a way to save audio using GDNative, though I have no idea how hard that would be.

    Another potential way to get around the issue could be using C# and a C# audio library instead of Godot's audio system. Then in theory you could just trigger sounds when needed using the C# audio library and then, using the C# library, save the sounds to the a file. Once again, I have no idea how hard it would be.

    Hopefully this helps!

  • DrexlDrexl Posts: 1Member
    edited October 2019

    Old post but I struggled with this for a while so maybe this can help somebody. On 3.1 I was only able to save short .wav files. But in 3.2 alpha it seems to work fine. Just enable and disable AudioEffectRecord like this

    var recordingeffectmaster = AudioServer.get_bus_effect(0, 0) #0,0 is first effect on first audio bus
    
    recordingeffectmaster.set_recording_active(true)   #to start recording
    recordingeffectmaster.set_recording_active(false)  #to stop recording
    var final_recording = recordingeffectmaster.get_recording()  #to grab recording
    final_recording.save_to_wav(path_to_save)  #I would set the path with a filedialog 
    

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file