mirror of
https://github.com/brmlab/ledbar.git
synced 2025-08-01 22:53:35 +02:00
equalizer: Fix high CPU usage by waiting a tiny bit in case of no data fetched from soundcard
This commit is contained in:
parent
987e4c8182
commit
f83be37812
1 changed files with 4 additions and 1 deletions
|
@ -88,6 +88,7 @@ else:
|
||||||
SAMPLE_SIZE = CHUNK_SIZE*HISTORY_SIZE
|
SAMPLE_SIZE = CHUNK_SIZE*HISTORY_SIZE
|
||||||
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/EPIXELS)
|
PIXEL_FREQ_RANGE = math.pow(float(MAX_FREQ) / MIN_FREQ, 1.0/EPIXELS)
|
||||||
|
CHUNK_PERIOD = 1.0 / (RATE / CHUNK_SIZE)
|
||||||
|
|
||||||
def with_stream( fnc ):
|
def with_stream( fnc ):
|
||||||
|
|
||||||
|
@ -141,7 +142,9 @@ def loop( stream ):
|
||||||
|
|
||||||
while work:
|
while work:
|
||||||
try: data = stream.read(CHUNK_SIZE)
|
try: data = stream.read(CHUNK_SIZE)
|
||||||
except IOError: continue
|
except IOError:
|
||||||
|
time.sleep(CHUNK_PERIOD)
|
||||||
|
continue
|
||||||
nowtrig = datetime.now().microsecond / 50000
|
nowtrig = datetime.now().microsecond / 50000
|
||||||
if (nowtrig == nexttrig):
|
if (nowtrig == nexttrig):
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue