Do the work. Instantiates a sounddevice.*Stream and calls for a threading.Thread if any Monitor is set up. Then turn on the monitorCheck Event, and starts the stream. Waits for it to finish, unset the event And terminates the process :return
(self, StreamType: Type, stream_callback: Callable, numchannels: Union[List[int], int])
| 276 | |
| 277 | |
| 278 | def runner(self, StreamType: Type, stream_callback: Callable, numchannels: Union[List[int], int]): |
| 279 | """ |
| 280 | Do the work. |
| 281 | |
| 282 | Instantiates a sounddevice.*Stream and calls for a threading.Thread |
| 283 | if any Monitor is set up. |
| 284 | Then turn on the monitorCheck Event, and starts the stream. |
| 285 | Waits for it to finish, unset the event |
| 286 | And terminates the process |
| 287 | |
| 288 | :return: |
| 289 | :rtype: |
| 290 | """ |
| 291 | self.isFinished.clear() |
| 292 | if self.hasMonitor.is_set(): |
| 293 | t = Thread(target=self._monitoring_thread_loop, |
| 294 | args=(self.monitor, self.isRunning, |
| 295 | self.queue, self.statuses)) |
| 296 | t.start() |
| 297 | with StreamType(samplerate=self.samplingRate, # frames per second |
| 298 | blocksize=self.blockSize, # frames per call |
| 299 | device=self.device, # I/O devices |
| 300 | channels=numchannels, # number of channels FIXME: mapping |
| 301 | dtype=self.dataType, # type of sample data |
| 302 | latency='low', # request lowest possible latency |
| 303 | dither_off=True, # disable PortAudio dithering |
| 304 | clip_off=True, # disable PortAudio clipping |
| 305 | callback=stream_callback, # callback for each type |
| 306 | finished_callback=self._end_of_stream): # called after Abort or Stop stream |
| 307 | self.isRunning.set() |
| 308 | self.isFinished.wait() |
| 309 | self.isRunning.clear() |
| 310 | if self.hasMonitor.is_set(): |
| 311 | t.join() |
| 312 | return |
| 313 | |
| 314 | def _register_input_data(self, cbInput, frames): |
| 315 | writesLeft = self.recData.shape[0] - self.dataCount - 1 |