Pyaudio Recorder

This module contains the class to record data from a soundcard. It uses PyAudio to do so. Please check the PyAudio Documentation for more information.

Typical example of using the module:
>>>import myRecorder as mR
>>>recorder = mR.Recorder()
Channels: 1
Rate: 44100
Chunk size: 1024
Number of chunks: 4
You are using pyAudio for recording
Device not found, reverting to default
Selected device: Line (3- U24XL with SPDIF I/O)
>>>recorder.stream_init()
stream already started
Input latency: 2.322e-02
Output latency: 0.000e+00
Read Available: -9977
Write Available: -9976
True
>>>recorder.record_init()
Recording function is ready! Use record_start() to start
True
>>>recorder.record_start()
stream already started
Recording Start!
True
>>>Recording Done! Please flush the data with flush_record_data().
data = recorder.flush_record_data()
>>>recorder.close()
class cued_datalogger.acquisition.myRecorder.Recorder(channels=1, rate=44100, chunk_size=1024, num_chunk=4, device_name=None)

Bases: cued_datalogger.acquisition.RecorderParent.RecorderParent

Sets up the recording stream through a SoundCard

Attributes

device_index: int Index of the device to be used for recording
device_name: str Name of the device to be used for recording
max_value: float Maximum value of recorded data

Methods

audiodata_to_array(data)

Re-implemented from RecorderParent

available_devices()

Searches for any available input devices

Returns:

names: List

Name of the devices

index: List

Index of the devices

close()

Re-implemented from RecorderParent, but terminate the PyAudio Object too.

current_device_info()

Display the current selected device info

open_recorder()

Re-implemented from RecorderParent. Prepare the PyAudio Object too.

set_device_by_name(name)

Set the recording audio device by name. Revert to default if no such device found

Parameters:

name: str

Name of the device

stream_audio_callback(in_data, frame_count, time_info, status)

Callback function for audio streaming. First, it writes data to the circular buffer, then record data if it is recording, finally check for any trigger.

Inputs and Outputs are part of the callback format. More info can be found in PyAudio documentation

stream_close()

Re-implemented from RecorderParent.

stream_init(playback=False)

Re-implemented from RecorderParent.

stream_start()

Re-implemented from RecorderParent.

stream_stop()

Re-implemented from RecorderParent.