Skip to content

Commit fd9f706

Browse files
committed
Round to integers in plot_input and spectrogram examples
See #21.
1 parent 5408733 commit fd9f706

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

examples/plot_input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def update_plot(frame):
8686
device_info = sd.query_devices(args.device, 'input')
8787
args.samplerate = device_info['default_samplerate']
8888

89-
length = np.ceil(args.window * args.samplerate / (1000 * args.downsample))
89+
length = int(args.window * args.samplerate / (1000 * args.downsample))
9090
plotdata = np.zeros((length, len(args.channels)))
9191

9292
fig, ax = plt.subplots()

examples/spectrogram.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""Show a text-mode spectrogram using live microphone data."""
33
import argparse
44
import logging
5+
import math
56
import numpy as np
67
import shutil
78

@@ -63,8 +64,8 @@ def int_or_str(text):
6364
samplerate = sd.query_devices(args.device, 'input')['default_samplerate']
6465

6566
delta_f = (high - low) / (args.columns - 1)
66-
fftsize = np.ceil(samplerate / delta_f).astype(int)
67-
low_bin = np.floor(low / delta_f)
67+
fftsize = math.ceil(samplerate / delta_f)
68+
low_bin = math.floor(low / delta_f)
6869

6970
cumulated_status = sd.CallbackFlags()
7071

0 commit comments

Comments
 (0)