spell-music / csound-expression

Haskell Framework for Electronic Music
320 stars 31 forks source link

how to use jack output #55

Closed jwaldmann closed 5 years ago

jwaldmann commented 5 years ago

I have here a computer where I needed a lot of experimenting until I found a way to play sound from csound-expression via jack:

 dacBy (setJack "ce" <> setRates 48000 0 <> setBufs 0 2041  ) $ osc 300

where 2041 seems minimal. I have no idea what 0 0 2041 mean.

Perhaps this information is helpful for others.

anton-k commented 5 years ago

setRates 48000 0 - is really bad idea

second parameter can not be zero, uusually it's 64 or 128 for real time or 1 for precise samples. no parameters in setRates and setBufs can be zero/ Second parameter is block-size. How many numbers are in array buffer for audio.

typical settings for real time on Linux would be:

dacBy (setJack "ce" <> setRates 44100 64 <> setBufs 1024  256) $ fromMono  $ osc 300

You can experiment with setBufs by trying to reduce in halves it's parameters it can lead to better latency at the expense of CPU usage. You need to find the minimum values that suits your needs. If it starts to have artifacts and Xruns we need to increase the parameter (multiply by 2).

You can read on this values at the manual:

https://csound.com/docs/manual/CommandFlagsCategory.html

Search for hardwarebufsamps and iobufsamps in the section "Performance Configuration and Control"