mirror of
https://github.com/brmlab/ledbar.git
synced 2025-06-09 13:24:01 +02:00
equalizer.py: Parse commandline parameters (-n PIXELS, -h)
This commit is contained in:
parent
b809208b60
commit
45b17988c6
1 changed files with 31 additions and 0 deletions
|
@ -6,6 +6,8 @@ import struct
|
||||||
import math
|
import math
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import time
|
import time
|
||||||
|
import sys
|
||||||
|
import getopt
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import ledbar
|
import ledbar
|
||||||
|
@ -24,6 +26,35 @@ MAX_FREQ = 12000
|
||||||
FREQ_STEP = float(RATE) / (CHUNK_SIZE * HISTORY_SIZE)
|
FREQ_STEP = float(RATE) / (CHUNK_SIZE * HISTORY_SIZE)
|
||||||
PIXEL_FREQ_RANGE = math.pow(float(MAX_FREQ) / MIN_FREQ, 1.0/PIXELS)
|
PIXEL_FREQ_RANGE = math.pow(float(MAX_FREQ) / MIN_FREQ, 1.0/PIXELS)
|
||||||
|
|
||||||
|
|
||||||
|
def print_usage():
|
||||||
|
print '''\
|
||||||
|
USAGE:
|
||||||
|
%s [-n number] [-h]
|
||||||
|
OPTIONS:
|
||||||
|
-n number number of controlled boxes
|
||||||
|
-h --help show this help
|
||||||
|
''' % sys.argv[0]
|
||||||
|
|
||||||
|
try:
|
||||||
|
opts, args = getopt.getopt(sys.argv[1:], 'n:h', ['help'])
|
||||||
|
except getopt.GetOptError:
|
||||||
|
print_usage()
|
||||||
|
sys.exit(1)
|
||||||
|
if len(args):
|
||||||
|
print_usage()
|
||||||
|
sys.exit(1)
|
||||||
|
for k, v in opts:
|
||||||
|
if k == '-n':
|
||||||
|
if not v.isdigit():
|
||||||
|
print_usage()
|
||||||
|
sys.exit(1)
|
||||||
|
PIXELS = int(v)
|
||||||
|
elif k == '-h' or k == '--help':
|
||||||
|
print_usage()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
p = pyaudio.PyAudio()
|
p = pyaudio.PyAudio()
|
||||||
|
|
||||||
stream = p.open(format = FORMAT,
|
stream = p.open(format = FORMAT,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue