Created
April 9, 2020 13:19
-
-
Save connordavenport/9752b494ac5c2076de1fec6ef465c87f to your computer and use it in GitHub Desktop.
plot a .wav in drawbot
This file contains 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
from scipy.io import wavfile | |
fs, data = wavfile.read("Untitled2.wav") | |
# for this case I only needed the left waveform | |
left = [a[0] for a in data.tolist()] | |
seconds = data.shape[0]/fs | |
fps = fs | |
duration = 1 / fps | |
totalFrames = round(seconds * fps) | |
# I was too lazy to scale anything so I made a massive image file:) | |
w, h = totalFrames+200, max(left)+abs(min(left))+100 | |
newPage(w, h) | |
fill(1, 0, 0) | |
# translate to the center of the page | |
translate(100, h / 2) | |
a = 1 | |
for p,r in enumerate(left): | |
rect(1*p,0,3,r) | |
a += 1 | |
saveImage("./myWaveforms.pdf") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment