matchmaker.io
- class matchmaker.io.midi.MidiStream(processor: Processor | None = None, file_path: str | None = None, polling_period: float | None = 0.01, port: BaseInput | str | None = None, queue: RECVQueue = None, init_time: float | None = None, return_midi_messages: bool = False, mediator: CeusMediator | None = None, virtual_port: bool = False)[source]
Bases:
StreamA class to process input MIDI stream in real time
Parameters
- portmido.ports.BaseInput
Input MIDI port
- queueRECVQueue
Queue to store processed MIDI input
- init_timeOptional[float]
The initial time. If none given, the initial time will be set to the starting time of the thread.
- return_midi_messages: bool
Return MIDI messages in addition to the processed features.
- mediatorCeusMediator or None
A Mediator instance to filter input MIDI. This is useful for certain older instruments, like the Bösendorfer CEUS, which do not distinguish between notes played by a human, and notes sent from a different process (e.g., an accompaniment system)
- __init__(processor: Processor | None = None, file_path: str | None = None, polling_period: float | None = 0.01, port: BaseInput | str | None = None, queue: RECVQueue = None, init_time: float | None = None, return_midi_messages: bool = False, mediator: CeusMediator | None = None, virtual_port: bool = False)[source]
This constructor should always be called with keyword arguments. Arguments are:
group should be None; reserved for future extension when a ThreadGroup class is implemented.
target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.
name is the thread name. By default, a unique name is constructed of the form “Thread-N” where N is a small decimal number.
args is a list or tuple of arguments for the target invocation. Defaults to ().
kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}.
If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread.
- class matchmaker.io.audio.AudioStream(processor: Processor = None, file_path: str | None = None, sample_rate: int = 44100, hop_length: int = 1470, queue: RECVQueue | None = None, device_name_or_index: str | int | None = None, wait: bool = False, target_sr: int = 44100)[source]
Bases:
StreamA class to process an audio stream in real-time.
Parameters
- processorOptional[Processor]
The processor for the features. If
None, defaults toChromagramProcessor.- file_pathOptional[str]
If given, the audio stream will be simulated using the given file as an input instead.
- sample_rateint
Sample rate of the audio stream.
- hop_lengthint
Hop length of the audio stream.
- queueRECVQueue
Queue to store the processed audio.
- device_name_or_indexOptional[Union[str, int]]
Name or index of the audio device to be used. Ignored if
file_pathis given.
Notes
Frame caching: each call to
_process_featureprependsself.cache_sizesamples from the previous frame so that FFT windows wider thanhop_length(e.g. SKF’sRawSpectrumProcessorwithn_fft=512) have enough context. The cache size is auto-discovered at construction:If
processorexposes ann_fftattribute,cache_size = n_fft - hop_length.Otherwise
cache_size = hop_length(one previous hop).
The first frame is zero-padded by
cache_sizesamples.- __init__(processor: Processor = None, file_path: str | None = None, sample_rate: int = 44100, hop_length: int = 1470, queue: RECVQueue | None = None, device_name_or_index: str | int | None = None, wait: bool = False, target_sr: int = 44100)[source]
This constructor should always be called with keyword arguments. Arguments are:
group should be None; reserved for future extension when a ThreadGroup class is implemented.
target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.
name is the thread name. By default, a unique name is constructed of the form “Thread-N” where N is a small decimal number.
args is a list or tuple of arguments for the target invocation. Defaults to ().
kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}.
If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread.
- run_offline() None[source]
Process audio file in offline mode.
This method simulates real-time processing by reading chunks from an audio file at regular intervals. The processing speed can be controlled using the wait parameter.
Note
The audio file is processed in chunks of size hop_length, and features are extracted for each chunk.
- run_online() None[source]
Process audio in real-time from input device.
This method sets up and starts real-time audio processing from the specified input device. It initializes the PyAudio interface and opens an audio stream with the configured parameters.
Note
The audio is processed in chunks of size hop_length, and features are extracted in real-time.