Skip to content

Instantly share code, notes, and snippets.

@dgnsrekt
Last active October 20, 2019 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgnsrekt/c6c9c48068a523df5700849f579c81d3 to your computer and use it in GitHub Desktop.
Save dgnsrekt/c6c9c48068a523df5700849f579c81d3 to your computer and use it in GitHub Desktop.
from subprocess import Popen, PIPE, STDOUT, run
from pathlib import Path
from shlex import split
from random import randint
import sys
frequency = 400
seconds = 5
channels = 2
sequence_length = 100
command = Path("/usr/bin/alsabat")
assert command.exists()
for _ in range(sequence_length):
if randint(0, 2):
continue
print(frequency, seconds)
cmd = f"{str(command)} -F {frequency} -n {seconds * 1000} -P plughw"
cmd = split(cmd)
process = run(cmd, shell=False, capture_output=True)
if randint(0, 1):
if frequency < 800:
frequency = frequency + 50
elif randint(0, 1):
frequency += 200
else:
if frequency > 300:
frequency -= 100
else:
frequency = 200
s = randint(0, 2)
if s:
if seconds < 8:
seconds += 2
else:
if seconds > 4:
seconds -= 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment