I am writing a simple synthesiser.
This is the totality of my code
turtles-own [f]
to setup
ca
file-close
file-open "tune.snd"
crt 1 [set f 100]
reset-ticks
end
to go
file-write mean [sin(2 * pi * f * ticks)] of turtles
tick
end
when I run
Repeat 44100 [go] file-close
and load the output into a sound editor at 44100 hertz I get one second of sound. All is good so far. Unfortunately, it is meant to be a 100 Hz tone but instead, it is one second of something quite a bit higher [over 16k Hz].
What am I doing wrong?
First off, this is awesome!
The problem's simple. sin
in NetLogo uses degrees, not radians.