-
Notifications
You must be signed in to change notification settings - Fork 757
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
Added Bela support #5295
Added Bela support #5295
Conversation
52c95a6
to
d2a4db4
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.
Looks good to me! I'll test it soon and see how it works on both Bela and a Linux computer!
Only very minor comments in a few spots.
I have been looking at Bela's SuperCollider fork for a while now, and I don't see anything surprising here, nor any potential damage to other platforms. Still I think it's important for a merge like this that someone else also takes a look :)
Thanks for this @giuliomoro |
2abebcc
to
8dad85b
Compare
thanks for having a look!
Is it OK not to have it in there? I feel like those things tend to get outdated over time and I am never sure what their purpose is ... The commit history will tell who the author(s) have been more in detail. |
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 for this!
some general notes that i would like you to address before more substantial review:
- format the sc code so it is indented in tabs, not spaces, including any code examples in schelp and scd files. follow the other points in our style guide, too, as much as you have time for. especially regarding
if
, spacing of operators, and argument lists. - rename the folder SCClassLibrary/Common/Audio/bela to Bela
- indent all the new cmake code at 4 spaces, except lines 156-158 of
server/plugins/CMakeLists.txt
- replace the
try_or_retry
macro in XenomaiLock.cpp with a real function - add
#pragma once
to all new headers - make sure all your files have an ending newline -- for instance
examples/bela/bela_example_analogin_2.scd
does not - change the C++ macro
BELA
toSC_BELA
to make clear it comes from our project - remove any vestigial commented-out code, it's especially bad in BELAUgens.cpp
- rename both the file and target BELAUGens to "BelaUGens", this is easier to read and more in line with our naming conventions
git author does not necessarily tell you who is the actual author of the code, and it's not a replacement for a copyright claim which as i understand it is primarily to give a person or persons legal standing to sue in the case of a license violation. that said, we don't have a policy as far as i know regarding this. in my experience if the author of a piece of code wishes to name either themself, James McCartney, or the Free Software Foundation as the copyright holder that's generally acceptable, so long as they are ok with it being licensed with GPL3 or another compatible license. AFAIK it's not ok to remove copyright notices without explicit permission of the author. |
also, this is the most co-authors (5) i've ever seen on a commit, cool: 84f24e2 |
thanks @brianlheim
and this cannot be done with
even when the surrounding code uses tabs (e.g.: lines 148:153 of server/scsynth/CMakeLists.txt) ? I understand this should hold, but I thought I should ask.
this would lead to plenty of code duplication, is that really preferable to the current situation? |
thanks @brianlheim
good luck getting llvm devs to accept that PR. :) you can do this in the SCIDE. no plans right now for having a linter/formatter for sc code but it would be nice.
yes
i don't understand. there will not be much duplicated code if you replace the macro with a function. and yes, almost anything would be better than that macro. |
2. rename the folder SCClassLibrary/Common/Audio/bela to Bela 3. indent all the new cmake code at 4 spaces 5. add #pragma once to all new headers 6. make sure all your files have an ending newline -- for instance examples/bela/bela_example_analogin_2.scd does not 9. rename both the file and target BELAUGens to "BelaUGens", this is easier to read and more in line with our naming conventions
As suggested by @brianlheim in supercollider#5295 7. change the C++ macro BELA to SC_BELA to make clear it comes from our project
As suggested by @brianlheim in supercollider#5295 8. remove any vestigial commented-out code, it's especially bad in BELAUgens.cpp
As suggested by @brianlheim in supercollider#5295: 1. format the sc code so it is indented in tabs, not spaces, including any code examples in schelp and scd files.
Does this mean:
I tried the above for all the files we created/modified and this is the outcome: 9be6c8c Most of the changes look OK, but
|
yeah, the sc code changes look good now, thanks! FYI, the cmake code in the FindX.cmake modules is still indented at 2 instead of 4 spaces |
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.
It would be good if the bela-specific functionality would go into a specific folder in the class library, and – unless it is intended to make them work on other platforms – the UGens should have a prefix. The platform is (at least still) not used by so many people, and the common classes should work cross-platform.
Thanks for all this, I'm looking forward to trying out bela with sc!
2. rename the folder SCClassLibrary/Common/Audio/bela to Bela 3. indent all the new cmake code at 4 spaces 5. add #pragma once to all new headers 6. make sure all your files have an ending newline -- for instance examples/bela/bela_example_analogin_2.scd does not 9. rename both the file and target BELAUGens to "BelaUGens", this is easier to read and more in line with our naming conventions
As suggested by @brianlheim in supercollider#5295 7. change the C++ macro BELA to SC_BELA to make clear it comes from our project
As suggested by @brianlheim in supercollider#5295 8. remove any vestigial commented-out code, it's especially bad in BELAUgens.cpp
9be6c8c
to
ecda799
Compare
Thanks, fixed that. |
They refer to the sclang classes added in this PR. |
Addresses supercollider/supercollider#5295 (comment) in a future-proof way.
4d2f5a9
to
36015f3
Compare
thanks again @giuliomoro . i've opened a 3rd and final PR to your branch here: https://github.com/BelaPlatform/supercollider/pull/91/files |
d033d13
to
e778569
Compare
merged Re: BelaScope using a C API instead of C++, is this enough? https://github.com/BelaPlatform/supercollider/tree/topic/bela-scope-c |
thanks @giuliomoro !
unfortunately i don't think that's enough, because BelaScope itself is still a C++ class using C++ language features (new, delete, classes, etc.). let's leave this discussion until after the PR is merged please, it is too difficult to keep track of everything going on here. please update the readme when you have time and then i'll approve and merge this :) |
OK thanks, I will ping you when done. |
Agreed. Generally, just use a plain C struct for the public data members that the plugins should see. Then inherit from this struct for the actual private implementation. All operations on the struct that go beyond simple member access have to happen via plugin API methods. In your case that would probably be:
BTW, if you need to add several API methods to the interface table, it might make sense to group them in a seperate Bela interface and put that in the SC InterfaceTable.
|
30498e8
to
68007f6
Compare
@brianlheim here's the updated README. https://github.com/BelaPlatform/supercollider/blob/bela-ready-to-merge/README_BELA.md New code is tested and ready to go. |
@giuliomoro I just looked over the readme and it looks good. thanks for that, and for testing the new changes too! yes, could you please squash it? |
0bec501
to
68007f6
Compare
8f41d6b
to
0be1e36
Compare
Co-authored-by: elgiano <elgiano@gmail.com> Co-authored-by: sensestage <nescivi@gmail.com> Co-authored-by: Dan Stowell <danstowell@users.sourceforge.net> Co-authored-by: Andrew McPherson <a.mcpherson@qmul.ac.uk> Co-authored-by: brianlheim <self@brianlheim.com>
0be1e36
to
b773117
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! just waiting for Appveyor to complete now
thanks to everyone who worked on this! Bela is now in mainline SC 🎉 |
thanks @brianlheim for taking so much time to go through this and improve it a fair bit in the process and thanks everyone else who has contributed to it with precious code and/or precious reviews. |
Purpose and Motivation
This PR adds support for Bela, an ultra low-latency platform for audio and sensor processing with a few thousand (not all of them using Sc!) users worldwide. Bela is a headless Linux computer, so one can either run
sclang
on Bela itself (running an.scd
file, without live-coding), or runscsynth
on Bela and live-code it from the Sc IDE on the host.Work on this was started by @danstowell during the Kickstarter launch in 2016. In the following months and the following year, @sensestage added more complete support with help from me and @apmcpherson. Since then we started shipping a Sc build of our Sc fork with our image and I have occasionally rebased our changes on newer versions of the Sc
develop
branch, somewhere at 3.9beta, somewhere at 3.10, also fixing some bugs (development took place at https://github.com/BelaPlatform/supercollider). More recently @elgiano added support for the Bela Scope (a browser-based oscilloscope with some more features than Sc's own) and tied up some loose ends. Now we are in pretty good shape and we are taking @brianlheim up on his offer from a few months ago to try to merge upstream (i.e.: closes BelaPlatform#73 ). Thanks everyone, we wouldn't be at this stage without you!All of this has been rebased on top of the latest
develop
and squashed for your reviewing convenience into 3 commits.Types of changes
Bela requires a custom (non-ALSA, non-Portaudio, etc) audio backend as well as some Ugens to perform analog and digital I/O. Additionally it has its own oscilloscope. These Ugens need access to the
BelaContext
, which is owned by the audio backend. This required modifyingstruct World
. Additionally, newServer
options were added to deal with Bela specifics (e.g.: number of analog I/O, digital I/O, scope channels, multiplexing analog inputs etc etc).Xenomai is a real-time co-kernel for Linux, which is used by Bela, but could be in the future be used by other backends. Xenomai offers POSIX-like services that are real-time safe. Calling non-Xenomai services from a Xenomai thread (such as Bela's audio thread), will cause "mode switches", which in turn will make the thread lose its real-time guarantees and ultimately lead to dropouts if running at very low latencies. For this reason,
unique_lock
andcondition_variable_any
from the standard C++ library cannot be used without losing real-time guarantees. I therefore had to add Xenomai-compatible equivalents ofSC_Lock
andSC_SyncCondition
.README_BELA.md
covers building, installation and basics.New command-line options on the
scsynth
side have been added and documented inserver/scsynth/scsynth_main.cpp
. New language-side classes have been added and a new primitivehasBelaSupport
has been added. These are documented inHelpSource/
.No breaking changes when building without
-DAUDIOAPI=bela
. When building with it, as some of the public includes have been modified, externally-hosted UGens (e.g.: sc3) have to be rebuilt.To-do list