Created
September 13, 2025 13:45
-
-
Save elderica/25f654970c475b34d75cffdd2b0c54de to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import numpy | |
import pedalboard.io | |
wav_hz = 44100 | |
musictime = wav_hz * 5 | |
root = 1/(2**(1/2)) | |
frq1 = 1./440. | |
frq2 = 440. * root * root | |
def main(): | |
rawframes = [] | |
for t in range(musictime): | |
osc = 0.0 | |
for k in range(1, 9, 2): | |
osc += 1. / k / k * math.sin(math.pi * k / 2.) * math.sin(2. * math.pi * frq1 * t / wav_hz) | |
d1 = float(osc) | |
d2 = float(math.sin(2. * math.pi * frq2 * t / wav_hz)) | |
r = 12767. * (d1 + d2 / 2.0) | |
rawframes.append(r) | |
devname = pedalboard.io.AudioStream.output_device_names[0] | |
with pedalboard.io.AudioStream(output_device_name=devname) as stream: | |
audio = numpy.array(rawframes, dtype=numpy.float32) | |
stream.write(audio, wav_hz) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment