Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a1eac01

Browse files
Tweak sound synthesis to use equal temperament
1 parent b3c27c6 commit a1eac01

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎views/array_sound.gd‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ class_name ArraySound
22
extends Node
33

44
const SAMPLE_HZ = 44100
5-
const MIN_HZ = 110
6-
const MAX_HZ = 440
5+
const MIN_HZ = 110 # A2
76

87
var frac: float
98
var player = AudioStreamPlayer.new()
@@ -17,7 +16,8 @@ func _fill_buffer(pulse_hz):
1716
_phase = fmod(_phase + increment, 1.0)
1817

1918
func _process(delta):
20-
_fill_buffer(MIN_HZ + (MAX_HZ - MIN_HZ) * frac)
19+
# Each step of an already sorted array of size 32 <-> one semitone
20+
_fill_buffer(MIN_HZ * pow(pow(2, 1.0 / 12), frac * 32))
2121

2222
func _init():
2323
add_child(player)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /