Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

使用麦克风录音

Godot支持Windows, macOS, Linux, Android和iOS的游戏内音频录制.

一定要查看Viewport演示! 可以下载演示档案中的Viewport文件夹, 或: https://github.com/godotengine/godot-demo-projects/tree/master/audio/mic_record.

You will need to enable audio input in the project settings Project Settings -> Audio -> Driver -> Enable Input, or you'll just get empty audio files.

根节点的结构

该演示由单一场景组成, 这个场景包括两个主要部分:GUI和音频.

我们将重点介绍音频部分. 在本演示中, 创建了一个名为 Record 的总线, 效果为 Record, 用于处理音频录制. 用一个名为 AudioStreamPlayerAudioStreamRecord 进行录音.

../../_images/record_bus.png ../../_images/record_stream_player.png
var effect
var recording


func _ready():
    # We get the index of the "Record" bus.
    var idx = AudioServer.get_bus_index("Record")
    # And use it to retrieve its first effect, which has been defined
    # as an "AudioEffectRecord" resource.
    effect = AudioServer.get_bus_effect(idx, 0)