I try to use pycarla to have a python script create and control midi output over the systems audio out.
I'm not very experienced with linux and this might cause the problem. Sorry for that... :)
However, I used the usage examples to have carla output a downloaded midifile. at the moment I'm using lubuntu 22.10.
Its a fresh install and I just did
sudo apt-get install jackd2
sudo apt-get install carla
However, Carla is not be able to start the engine if QjackCtl is not startet and running first. Maybe the wrong place to ask here?
Furthermore, I had to connect carla and systems out not only in the carla patchbay but also in the QjackCtl Patchcontrol have to connect them? I had a try earlier, where both of these steps worked flawlessly, but just cant reproduce it..
Then I installed pip and python 3.10.7 and followed the installation instructions. If I do all of that, created a carla project in the same folder and have carla up and running opening that project I used the following code:
from pycarla import Carla, MIDIPlayer, AudioRecorder, get_smf_duration
carla = Carla("A.carxp", ['-R', '-d', 'alsa'], min_wait=4)
carla.start()
player = MIDIPlayer()
with MIDIPlayer() as player:
#print("Playing full file using freewheeling mode..")
duration = get_smf_duration("test.mid")
# in the following, `condition` ensures that both the recorder and player
# start in the same cycle
player.synthesize_midi_file("test.mid", in_fw=True, out_fw=True)
# or asynchronously:
# player.synthesize_midi_file("filename.mid", sync=False)
# in this case, use
# player.wait(in_fw=True, out_fw=True)
player.close()
server.close()
#pass
try:
carla.kill()
except Exception as e:
print("Processes already closed!")
I get the following error:
Carla ready!
Traceback (most recent call last):
File "/home/mane/test1.py", line 12, in <module>
player.synthesize_midi_file("test.mid", in_fw=True, out_fw=True)
File "/usr/local/lib/python3.10/dist-packages/pycarla/midiplayer.py", line 193, in synthesize_midi_file
return self.synthesize_messages(messages, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/pycarla/midiplayer.py", line 118, in synthesize_messages
self.activate()
File "/usr/local/lib/python3.10/dist-packages/pycarla/midiplayer.py", line 36, in activate
raise RuntimeWarning(
RuntimeWarning: Cannot find the Carla instance, Retry later!
I would really appreciate any help with that! This package is exactly what I need, if only I could get it running! :)
I also (at least I think I did) solved the following problems so far, maybe it makes sense to add this to the documentation?:
- Carla has to be installed first, before installing pycarla. May be obvious. Still was costing me a few hours to fix.
- I think the user needs to be added to the audio group in order to have real time performance? (used "sudo usermod -a -G audio UserID" and restart to fix the error)
- I also ran into the developement steps out of the documentation, was also not obvious to me, that this is for the pros... ;)e