From 05a3406de3e26d21865db87960f80c5f40f9cd83 Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Tue, 13 Oct 2026 20:36:02 +0200 Subject: Add option to specify audio device (only applicable for metronome and recorder) --- solo-tool-project/src/solo_tool/metronome.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'solo-tool-project/src/solo_tool/metronome.py') diff --git a/solo-tool-project/src/solo_tool/metronome.py b/solo-tool-project/src/solo_tool/metronome.py index 9c65357..3ffc6bc 100644 --- a/solo-tool-project/src/solo_tool/metronome.py +++ b/solo-tool-project/src/solo_tool/metronome.py @@ -1,6 +1,8 @@ import pyaudio as pa from array import array +from solo_tool.utils import getAudioDeviceIndex + def _createClickSample(clickFrequency: int, samplingRate: int) -> array: clickDuration = 0.03 # seconds @@ -22,9 +24,10 @@ def _createOutputBuffer(bpm: int, clickFrequency: int, samplingRate: int) -> arr return clickSample + array('h', [0] * (samplesPerBeat - len(clickSample))) class Metronome: - def __init__(self, bufferSize: int, samplingRate: int): + def __init__(self, bufferSize: int, samplingRate: int, deviceName: str): self._bufferSize = bufferSize self._samplingRate = samplingRate + self._deviceName = deviceName self._sampleFormat = pa.paInt16 self._channels = 1 self._pa = pa.PyAudio() @@ -58,6 +61,7 @@ class Metronome: rate=self._samplingRate, frames_per_buffer=self._bufferSize, output=True, + output_device_index=getAudioDeviceIndex(self._deviceName, self._pa), stream_callback=self._callback) def stop(self) -> None: -- cgit v1.2.3