Skip to content

Commit

Permalink
Added support for Bela
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
5 people committed Dec 20, 2020
1 parent 942113c commit 84f24e2
Show file tree
Hide file tree
Showing 44 changed files with 4,045 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ else() # ARM platforms do not have SSE
set(SSE2 OFF)
endif()

set(AUDIOAPI "default" CACHE STRING "Audio API to use (one of {default,coreaudio,jack,portaudio})")
set(AUDIOAPI "default" CACHE STRING "Audio API to use (one of {default,coreaudio,jack,portaudio,bela})")

if (AUDIOAPI STREQUAL jack)
# here we check for JACK metadata API
Expand Down
50 changes: 50 additions & 0 deletions HelpSource/Classes/AnalogIn.schelp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
class:: AnalogIn
summary:: Read data from an analog input of the BELA board
related:: Classes/AnalogOut, Classes/DigitalIn, Classes/DigitalOut, Classes/DigitalIO
categories:: UGens>BELA


Description::

Reads analog data from an analog input of the BELA board.

note::
This UGen only works on BeLa
::

classmethods::

method::ar

argument::analogPin

Analog pin number to read. Pin numbers begin at 0. This value can be modulated at audiorate.

argument::mul

argument::add

method::kr

argument::analogPin

Analog pin number to read. Pin numbers begin at 0.

argument::mul

argument::add

Examples::

code::
// modulate frequency of a sine oscillator

(
SynthDef("help-AnalogIn",{ arg out=0;
Out.ar(out,
SinOsc.ar( AnalogIn.ar( 0 ).exprange( 200, 5000 ), 0, 0.1 )
)
}).play;
)
::

55 changes: 55 additions & 0 deletions HelpSource/Classes/AnalogOut.schelp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
class:: AnalogOut
summary:: Write data to an analog output of the BELA board
related:: Classes/AnalogIn, Classes/DigitalIn, Classes/DigitalOut, Classes/DigitalIO
categories:: UGens>BELA


Description::

Writes analog data to an analog output of the BELA board.

note::
This UGen only works on BeLa
::

classmethods::

method::ar

argument::analogPin

Analog pin number to read. Pin numbers begin at 0. This value can be modulated at audiorate.

argument::output

Value to write out to the pin.

argument::mul

argument::add

method::kr

argument::analogPin

Analog pin number to read. Pin numbers begin at 0.

argument::output

Value to write out to the pin.

argument::mul

argument::add

Examples::

code::
// write a sine oscillator's output to a pin

(
SynthDef("help-AnalogOut",{ arg out=0;
AnalogOut.ar( 0 , SinOsc.ar( 10 ) );
}).play;
)
::
10 changes: 10 additions & 0 deletions HelpSource/Classes/Array.schelp
Original file line number Diff line number Diff line change
Expand Up @@ -404,3 +404,13 @@ code::
[0.1, [\s_new, \default, -1, 1, 1, \freq, 1961]].asRawOSC;
::

subsection:: Bela

method:: belaScope
Send this Array's content to Bela's Oscilloscope (see link::Classes/BelaScope:: for required setup)
argument:: scopeChannel
Bela's oscilloscope channel to start scoping on. This has to be a non-negative number, and can't be changed after scoping starts.

argument:: server
The server on which BelaScope is running. If not specified, it looks for the first server for which BelaScope was already initialized. If none is found, it attempts to initialize a link::Classes/BelaScope:: instance on link::Server#*default::.
returns:: This Array.
100 changes: 100 additions & 0 deletions HelpSource/Classes/BelaScope.schelp
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
class:: BelaScope
summary:: Bela's Oscilloscope interface
categories:: UGens>BELA

Description::
note::
This UGen only works on Bela
::
Allows to scope signals on Bela's built-in Oscilloscope, which can be accessed from Bela's web interface.
It is not needed to interact directly with this class, as UGens, Arrays, Busses, Functions and Servers can be scoped via their .belaScope() method.

subsection:: Setup

Using BelaScope requires:
list::
## an instance of Server running on a Bela (either locally or remotely).

## ServerOptions.belaMaxScopeChannels should be set > 0 for Bela's server.
It represents the maximum number of channels that is possible to scope on that server, and affects resources allocation.
If set <= 0, the server won't instantiate any Scope object, and any attempt to instantiate a BelaScope from sclang will throw an error.
::

subsection:: Usage
Once a Bela server is started with options.belaMaxScopeChannels > 0, it is possible to scope UGens and Busses using their .belaScope() methods. See examples below.

classmethods::

method::scope
Send an array of UGen data to Bela's oscilloscope.

argument::channelOffset
Bela's oscilloscope channel to start scoping on. This has to be a non-negative number, and can't be changed after scoping starts.

argument::signals
Array of UGens to scope

returns:: the array of code::signals:: passed in as an argument. This allows for transparent usage of code::.belaScope():: in processing chains

code::
{ BelaScope.scope(0, SinOsc.ar) }.play;
// same using UGen::belaScope() shortcut method:
{ SinOsc.ar().belaScope(0) }.play

// transparent usage in chains:
// scoping LFNoise0 before and after .range, while still using it to modulate SinOsc
{ SinOsc.ar(LFNoise0.kr(10).belaScope(0).range(20,100).belaScope(1)) }.play
::

method::monitorBus
Scope a Bus on Bela's oscilloscope
argument::channelOffset
Bela's oscilloscope channel to start scoping on. This has to be a non-negative number, and can't be changed after scoping starts.

argument::busindex
Index of the audio bus to scope

argument::numChannels
Number of bus channels to scope

argument::target
Bela's SuperCollider server, or any node on that server. The bus is monitored strong::after:: this target, or after this server's link::Classes/RootNode:: if a server is provided as target.

returns:: A link::Class/Synth:: used to monitor the bus.

code::
// scope 2 channels from audio bus 4 on Bela Oscilloscope's channel 3
BelaScope.monitorBus(3, 4, 2, ~belaServer)
// same using Server::belaScope() shortcut method:
~belaServer.belaScope(3, 4, 2)
// same using Bus::belaScope() shortcut method
Bus(\audio, 4, 2, ~belaServer).belaScope(3)
::

Examples::

code::
~belaServer = Server.remote(\bela, NetAddr("192.168.6.2", 57110));

// UGens: usage like .poll
// scope the LFNoise0, and still use it to modulate a SinOsc
{ var freq = LFNoise0.kr.range(20,2000); SinOsc.ar(freq.belaScope(0)) }.play(~belaServer)

// scope an Array of UGens:
{ var freq = LFNoise0.kr.range(20,2000) ! 4; SinOsc.ar(freq.belaScope(0)) }.play(~belaServer)

// Bus: scope 3 channels from bus number 10 on Bela Oscilloscope's channel 4
b = Bus(\audio, 10, 6, ~belaServer);
{ SinOsc.ar }.play(~belaServer, outbus:b);
b.belaScope(4);

// Server: usage like .scope
// scope busses 10 and 11 on Bela's Oscilloscope channel 2
~belaServer.belaScope(2, 10, 2)
// scope main output busses on Bela's Oscilloscope channel 0
~belaServer.belaScope

// Function: usage like .scope
// play and scope a multi-output function; scope starting on BelaScope channel 4
{ SinOsc.ar(LFNoise0.ar([1,2,3]).exprange(20,20000)) * LFNoise1.ar([1,2,3]).exprange(0.001, 0.1) }.belaScope(4, ~belaServer)
::
19 changes: 19 additions & 0 deletions HelpSource/Classes/BelaScopeOut.schelp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class:: BelaScopeOut
summary:: Bela's Oscilloscope interface
categories:: UGens>BELA

Description::
note::
This UGen only works on Bela
::
This UGen effectively sends audio signals to Bela Oscilloscope, analogously to how link::/Classes/Out:: writes to a bus.
It can be used directly, or through link::Classes/UGen#-belaScope::, link::Classes/Array#-belaScope::, link::Classes/Bus#-belaScope::, link::Classes/Function#-belaScope:: and link::Classes/Server#-belaScope:: convenience functions.

classmethods::

method::ar
argument::offset
The Bela Oscilloscope's channel where to start writing. This is read only at construction time and thus it's not modulatable.
argument::channelsArray
An array of UGens to be scoped.

11 changes: 11 additions & 0 deletions HelpSource/Classes/Bus.schelp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,17 @@ a.free;
b.free;
::

subsection:: Bela

method:: belaScope
Scope all channels from this Bus to Bela's Oscilloscope (see link::Classes/BelaScope:: for required setup).
It is required that this Bus is on Server running on a Bela, which is thus capable of using BelaScope.

argument:: scopeChannel
Bela's oscilloscope channel to start scoping on. This has to be a non-negative number, and can't be changed after scoping starts.

returns:: A link::Classes/Synth::, linking this Bus to BelaScope's bus.

Examples::
code::
s.boot;
Expand Down
72 changes: 72 additions & 0 deletions HelpSource/Classes/DigitalIO.schelp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
class:: DigitalIO
summary:: Read or write data to a digital pin of the BELA board
related:: Classes/AnalogIn, Classes/AnalogOut, Classes/DigitalIn, Classes/DigitalOut
categories:: UGens>BELA


Description::

Read or write digital data from or to a digital pin. The pin number of this UGen can be modulated, as well as its I/O mode.

note::
This UGen only works on BeLa.
::

note::
If you do not need to change the pin mode or the pin, you should use the UGen link::Classes/DigitalIn:: or link::Classes/DigitalOut::
::

classmethods::

method::ar

The output of this UGen is always the last value read when the digital pin was an input.

argument::digitalPin

Digital pin number to write to. Pin numbers begin at 0. This value can be modulated at audiorate.

argument::output

Value to write out to the pin - the value will be 1 when the argument is larger than 0, otherwise 0. This value can be modulated at audio rate.

argument::pinMode

Value to write out to the pin - the pin will be an input when the argument is smaller than 0.5, otherwise an output. This value can be modulated at audiorate.

argument::mul

argument::add

method::kr

The output of this UGen is always the last value read when the digital pin was an input.

argument::digitalPin

Digital pin number to write to. Pin numbers begin at 0.

argument::output

Value to write out to the pin - the value will be 1 when the argument is larger than 0, otherwise 0.

argument::pinMode

Value to write out to the pin - the pin will be an input when the argument is smaller than 0.5, otherwise an output.

argument::mul

argument::add

Examples::

code::
// write a sine oscillator's output to a pin, and read the pin value at other times

(
SynthDef("help-DigitalIO",{ arg out=0;
DigitalIO.ar( 0, SinOsc.ar( 10 ),LFPulse.kr( 0.1 ) ).poll;
}).play;
)

::
55 changes: 55 additions & 0 deletions HelpSource/Classes/DigitalIn.schelp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
class:: DigitalIn
summary:: Read data from a digital input of the BELA board
related:: Classes/AnalogIn, Classes/AnalogOut, Classes/DigitalOut, Classes/DigitalIO
categories:: UGens>BELA


Description::

Reads digital data from an digital input of the BELA board.

note::
This UGen only works on BeLa.
::

note::
If you want to modulate the pin number, you should use the UGen link::Classes/DigitalIO::
::

classmethods::

method::ar

argument::digitalPin

Digital pin number to read. Pin numbers begin at 0. This value cannot be modulated.

argument::mul

argument::add

method::kr

argument::digitalPin

Digital pin number to read. Pin numbers begin at 0. This value cannot be modulated.

argument::mul

argument::add


Examples::

code::
// turn on and off a sine oscillator

(
SynthDef("help-DigitalIn",{ arg out=0;
Out.ar(out,
SinOsc.ar( 500, 0, 0.1 * DigitalIn.ar( 0 ) )
)
}).play;
)
::

Loading

0 comments on commit 84f24e2

Please sign in to comment.