Skip to content

Commit

Permalink
use float32 dtype in online mode to be able to apply a positive gain
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Böck committed Dec 5, 2016
1 parent 566d86a commit a7cb9d3
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions madmom/audio/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,7 @@ class Stream(object):
QUEUE_SIZE = 1

def __init__(self, sample_rate=SAMPLE_RATE, num_channels=NUM_CHANNELS,
dtype=DTYPE, frame_size=FRAME_SIZE, hop_size=HOP_SIZE,
dtype=np.float32, frame_size=FRAME_SIZE, hop_size=HOP_SIZE,
fps=FPS, queue_size=QUEUE_SIZE, **kwargs):
# import PyAudio here and not at the module level
import pyaudio
Expand Down Expand Up @@ -1512,10 +1512,9 @@ def __init__(self, sample_rate=SAMPLE_RATE, num_channels=NUM_CHANNELS,
# init PyAudio for recording
self.pa = pyaudio.PyAudio()

# TODO: make the dtype configurable; see callback()
self.stream = self.pa.open(rate=self.sample_rate,
channels=self.num_channels,
format=pyaudio.paInt16, input=True,
format=pyaudio.paFloat32, input=True,
frames_per_buffer=self.hop_size,
stream_callback=self.callback, start=True)

Expand Down Expand Up @@ -1554,8 +1553,7 @@ def callback(self, data, *args):
"""
# get the data from the stream
# TODO: make the dtype configurable; see __init__()
data = np.fromstring(data, 'int16').astype(self.dtype)
data = np.fromstring(data, 'float32').astype(self.dtype, copy=False)
# buffer the data
data = self.buffer(data)
# wrap it as a Signal (including the start position)
Expand Down

0 comments on commit a7cb9d3

Please sign in to comment.