New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
supernova: enable building JACK API on macOS #4291
Conversation
All of your observations about installation, caveats, and starting jack by various means seem worth documenting. I could see this in either a new section of |
I added documentation for building and running SC with JACK on macOS. For the sake of completeness, I also tested with JackOSX (which is jack2, as opposed to jack1 from homebrew). The build process mostly worked, SC starts and I can make sound using SC<->JACK, however, when building, the
Jack libraries are present (symlinked) at
For comparison, when building against
Thinking more about it, the linking issue applies both to scsynth and supernova and is not related to the changes in this PR. I think that this is now ready for review. |
4bf802f
to
1a393a0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. I didn't test the build, because I'm not on MacOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! one substantial thing, the rest are minor/style issues
README_MACOS.md
Outdated
In order to build with JACK, you need to add the `-DAUDIOAPI=jack` flag to cmake. The full command to configure the build (with supernova) would be: | ||
|
||
``` | ||
cmake -G Xcode -DCMAKE_PREFIX_PATH=`brew --prefix qt5` -DSUPERNOVA=ON -DAUDIOAPI=jack .. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would prefer to stay away from giving full commands, as it looks different for everyone depending on use case and ends up cluttering the readme. i think it's enough to say you would pass that as another option when you configure your build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I included this since I personally like full commands I can just copy/paste - I know this is lazy, but I like to have that option. If you insist this is suboptimal, I'm happy to remove that.
My question is in what case on macOS the command would be different? If you have a custom place for QT you probably know enough to change it, and if not, this is helpful for newbies (which is what I was for quite some time as far as building goes)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are over a dozen options you can pass to cmake to configure your supercollider build, some of them are documented in this very file.
i understand the desire to be beginner friendly but this really isn't that in my opinion, it's just creating clutter. let's teach people how to effectively use the build system if they don't know, rather than giving complete commands for every possible build scenario. if this command were universal or even the common case, you might have a point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this command were universal or even the common case, you might have a point.
IMO this was the common case for this particular scenario (building with JACK) but I see your point it might not be so I'll remove it.
README_MACOS.md
Outdated
``` | ||
jackd -d coreaudio | ||
//or | ||
jackd -d coreaudio -r48000 -p512 //specifying sample rate and buffer size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
most shells on macOS use #
for comments
README_MACOS.md
Outdated
|
||
Afterwards proceed with the build process as usual. | ||
|
||
##### Running SuperCollider with JACK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should probably be only ###
(same below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#####
was intentional it's used elsewhere in this file as well, but if you prefer to have ###
here that's fine.
endif() | ||
message(STATUS "Supernova audio API: ${AUDIOAPI}") | ||
|
||
if (AUDIOAPI STREQUAL jack) | ||
find_library(JACK NAMES jack) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this necessary with find_package
above? seems like the same work done twice in different ways. also dubious of just failing silently if jack isn't found here
server/supernova/CMakeLists.txt
Outdated
endif() | ||
message(STATUS "Supernova audio API: ${AUDIOAPI}") | ||
|
||
if (AUDIOAPI STREQUAL jack) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change this and the portaudio check below from jack
to "jack"
-- otherwise, cmake will first see if a variable with the name jack
exists, which is not what you want
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is taken from the scsynth CMakeLists:
if(AUDIOAPI STREQUAL jack) |
should this be changed in scsynth's CMakeLists as well?
server/supernova/CMakeLists.txt
Outdated
find_library(JACK NAMES jack) | ||
if (JACK) | ||
target_compile_definitions(libsupernova PUBLIC JACK_BACKEND) | ||
target_link_libraries(libsupernova ${JACK}) | ||
target_include_directories(libsupernova PUBLIC ${JACK_INCLUDE_DIRS}) | ||
endif() | ||
elseif (AUDIOAPI STREQUAL portaudio) | ||
target_include_directories(libsupernova PUBLIC ${PORTAUDIO_INCLUDE_DIRS}) | ||
if (WIN32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove spaces between if
/elseif
and paren throughout the code you added
@brianlheim I can't seem to respond to the comment pointing to code that has changed (?), here's more response regarding switching backend from coreaudio to portaudio in supernova:
I personally treat it as a temporary situation where we don't have coreaudio backend for supernova. If you feel strongly about it, I can change it to throw an error if coreaudio is explicitly requested. I think adding more granularity to cmake is not optimal, there's already a lot there... but if you think that's best then I can add that. I personally don't think having 2 servers with different backends is useful (unless necessary, as it is now on macOS), but again I'm happy to be persuaded about it. |
…dio API selection Modified CMakeLists.txt to make Supernova build with native JACK backend on OSX when specified JACK as audio API in cmake options.
358b305
to
fad6d7c
Compare
I rebased this PR to include the latest changes from I also added an error message if the user explicitly requests
|
abort cmake when not implemented coreaudio API is requested
fad6d7c
to
a14f5db
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! this all looks good to me. i didn't respond to them individually, but your comments from the last round of review were all reasonable. sorry, i didn't realize you had cut-and-pasted that CMake config section.
Purpose and Motivation
Currently supernova is hardcoded to use PortAudio on macOS. This PR modifies CMakeLists file to mimic the API choice in scsynth (with the exception of choosing portaudio instead of coreaudio by default on macOS).
Types of changes
To-do list
Comments
Previously I had a problem connecting to JACK server when the scsynth/supernova were booted from SC:
(details)
I am able to start servers from command line, and they connect to JACK backend and make sound. However, if I try booting server from SC, I'm gettingfor scsynth
and
for supernova.
Again, if I boot the server in terminal with the same options (taken from s.options.asOptionsString), it starts and works. I'd appreciate ideas how to debug this further...I realized, that this was due to JACK (installed by homebrew in
/usr/local/bin
) not being in the$PATH
in the SC environment.Solution:
And also make the scsynth/supernova automatically connect to system inputs/outputs:
After that, I was able to start scsynth/supernova and connect it to (previously started) jack server.
Caveats:
jackd
seems to require a single device for input and output, so in order to use it with the internal soundcard on a mac, one needs to create an aggregate deviceI was able to start jack either from terminal,
qjackctl
gui, or with SC:JACK was installed with
and
for the GUI allowing control over JACK connections.
For reference: what sparked this PR is a problem I discovered with JackOSX.
edit:
I tested this with both jack1 from homebrew and jack2 from JackOSX.0.92_b3. Compilation works in both cases (with some problem in the verification stage for jack2).
The takeaway is that both JACKs seem to be a little broken:
coreaudiod
process is left with ~150MB of garbage memory (?) after each start/stop of jack server