hamiltron/py-simple-audio

Output through JACK on Linux?

Opened this issue · 0 comments

I'd like to be able to output sound clips using simpleaudio via JACK on a Raspberry Pi while another application is also producing sound output through JACK (using ALSA backend) - specifically FluidSynth. Is there an existing way to tell simpleaudio to do this? Here's my example code:

#!/usr/bin/env python3

import simpleaudio as sa

wave_obj = sa.WaveObject.from_wave_file("test.wav")
play_obj = wave_obj.play()
play_obj.wait_done()

The result is

Traceback (most recent call last):
  File "./test.py", line 6, in <module>
    play_obj = wave_obj.play()
  File "/usr/local/lib/python3.7/dist-packages/simpleaudio/shiny.py", line 20, in play
    self.bytes_per_sample, self.sample_rate)
  File "/usr/local/lib/python3.7/dist-packages/simpleaudio/shiny.py", line 61, in play_buffer
    sample_rate)
_simpleaudio.SimpleaudioError: Error opening PCM device. -- CODE: -16 -- MSG: Device or resource busy

Which makes sense, since the sound card is being used by JACK - but is there a way to get simpleaudio to appear as a JACK client I can connect to the system outputs?