Browse Source

Merge pull request #99604 from LaneSBarnes/patch-1

Fix example code snippets in AudioStreamGenerator.xml
Rémi Verschelde 8 months ago
parent
commit
0a7471c2a2
1 changed files with 2 additions and 2 deletions
  1. 2 2
      doc/classes/AudioStreamGenerator.xml

+ 2 - 2
doc/classes/AudioStreamGenerator.xml

@@ -11,6 +11,7 @@
 		var playback # Will hold the AudioStreamGeneratorPlayback.
 		@onready var sample_hz = $AudioStreamPlayer.stream.mix_rate
 		var pulse_hz = 440.0 # The frequency of the sound wave.
+		var phase = 0.0
 
 		func _ready():
 		    $AudioStreamPlayer.play()
@@ -18,7 +19,6 @@
 		    fill_buffer()
 
 		func fill_buffer():
-		    var phase = 0.0
 		    var increment = pulse_hz / sample_hz
 		    var frames_available = playback.get_frames_available()
 
@@ -32,6 +32,7 @@
 		private AudioStreamGeneratorPlayback _playback; // Will hold the AudioStreamGeneratorPlayback.
 		private float _sampleHz;
 		private float _pulseHz = 440.0f; // The frequency of the sound wave.
+		private double phase = 0.0;
 
 		public override void _Ready()
 		{
@@ -46,7 +47,6 @@
 
 		public void FillBuffer()
 		{
-		    double phase = 0.0;
 		    float increment = _pulseHz / _sampleHz;
 		    int framesAvailable = _playback.GetFramesAvailable();