jdxi_editor.audio.audio_analyser

Turn the newest samples into one snapshot, off the capture callback.

The worker thread reads the ring. The window only ever reads AudioAnalyser.latest_snapshot().

Classes

AudioAnalyser

Coordinates the three measurements and publishes the latest snapshot.

Module Contents

class jdxi_editor.audio.audio_analyser.AudioAnalyser(ring: jdxi_editor.audio.audio_buffer.SampleRing, sample_rate: int = SAMPLE_RATE, columns: int = WAVEFORM_COLUMNS)[source]

Coordinates the three measurements and publishes the latest snapshot.

ring[source]
sample_rate = 48000[source]
columns = 480[source]
timebase_ms = 20[source]
vu[source]
spectrum[source]
_snapshot: jdxi_editor.audio.audio_snapshot.AudioSnapshot | None = None[source]
_consumed = 0[source]
_last_time: float | None = None[source]
_stop[source]
_thread: threading.Thread | None = None[source]
set_sample_rate(sample_rate: int) → None[source]

The rate the input actually opened at.

Call while stopped: the timebase window and the spectrum’s frequency axis are both measured in samples.

Parameters:

sample_rate – int Hz

Returns:

None

set_timebase(timebase_ms: int) → None[source]

How much of the waveform the oscilloscope shows.

Parameters:

timebase_ms – int one of the waveform timebases

Returns:

None

latest_snapshot() → jdxi_editor.audio.audio_snapshot.AudioSnapshot | None[source]

The newest snapshot, or None before the first block.

Returns:

Optional[AudioSnapshot]

analyse_available(now: float | None = None) → jdxi_editor.audio.audio_snapshot.AudioSnapshot | None[source]

Measure whatever has arrived since the previous call.

Parameters:

now – Optional[float] monotonic seconds, for tests

Returns:

Optional[AudioSnapshot]

start() → None[source]

Analyse on a background thread at the display rate.

Returns:

None

stop() → None[source]

Stop the background thread.

Returns:

None

_loop() → None[source]
_since(previous: int) → tuple[numpy.ndarray, int][source]