diff options
| author | Matthias Geier <Matthias.Geier@gmail.com> | 2016-08-05 10:01:06 +0200 |
|---|---|---|
| committer | Matthias Geier <Matthias.Geier@gmail.com> | 2016-08-05 10:01:06 +0200 |
| commit | fd9f706b90d5c64d9c7a6903e62724c251da012f (patch) | |
| tree | 15f5363cfe018b4e0cba49d1d2f623b9d3b9b682 | |
| parent | 5408733e7f7b3ed1f350bbae8d74e758a00f0be7 (diff) | |
Round to integers in plot_input and spectrogram examples
See #21.
| -rwxr-xr-x | examples/plot_input.py | 2 | ||||
| -rwxr-xr-x | examples/spectrogram.py | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/examples/plot_input.py b/examples/plot_input.py index 26212e5..1210ba3 100755 --- a/examples/plot_input.py +++ b/examples/plot_input.py @@ -86,7 +86,7 @@ try: device_info = sd.query_devices(args.device, 'input') args.samplerate = device_info['default_samplerate'] - length = np.ceil(args.window * args.samplerate / (1000 * args.downsample)) + length = int(args.window * args.samplerate / (1000 * args.downsample)) plotdata = np.zeros((length, len(args.channels))) fig, ax = plt.subplots() diff --git a/examples/spectrogram.py b/examples/spectrogram.py index d0d5026..3c378f3 100755 --- a/examples/spectrogram.py +++ b/examples/spectrogram.py @@ -2,6 +2,7 @@ """Show a text-mode spectrogram using live microphone data.""" import argparse import logging +import math import numpy as np import shutil @@ -63,8 +64,8 @@ try: samplerate = sd.query_devices(args.device, 'input')['default_samplerate'] delta_f = (high - low) / (args.columns - 1) - fftsize = np.ceil(samplerate / delta_f).astype(int) - low_bin = np.floor(low / delta_f) + fftsize = math.ceil(samplerate / delta_f) + low_bin = math.floor(low / delta_f) cumulated_status = sd.CallbackFlags() |
