sc3.base.main module

Kernel.sc & Main.sc

main

Default main class global variable set by sc3.init().

alias of sc3.base.main.RtMain

class Process(*_)

Bases: type

RT_MODE = 0
NRT_MODE = 1
property platform
open_udp_port(port)

Open extra UDP port.

close_udp_port(port)

Close extra UDP port. Default library port can’t be closed.

add_osc_recv_func(func)
remove_osc_recv_func(func)
elapsed_time()
class RtMain

Bases: object

classmethod elapsed_time()

Physical time since library initialization.

classmethod wait(timeout=None, tasks=1, tailtime=0)

Main thread lock until timeout or notified by resume.

This method doesn’t have to acquire a lock before calling. Internally it uses a counter to follow the calls to main.resume() which may happen even before this method is called and will resume when the count is less or equal to zero or after timeout (if present). The internal counter is reset after this method resumes.

Note: This is an utility method that makes less verbose the code for some simple actions that need to wait for routines to finish.

Parameters
  • timeout (float) – Optional wait time for the lock in seconds.

  • tasks (int) – Number of tasks that have to call main.resume() to unlock the main thread.

  • tailtime (float) – Optional sleep time in seconds added after resume is called, tailtime time is ignored if the the given timeout expired.

Returns

The value is False if timeout expired otherwise is True.

Return type

bool

classmethod resume()

Unlock the main thread.

This method must be called from another thread, e.g. from a routine scheduled by a clock using play.

classmethod sync(server, timeout=None)

Main thread blocking sync command.

Parameters
  • server (Server) – Instance to wait for.

  • timeout (float) – Optional wait time for the lock in seconds.

Returns

The value is False if timeout expired otherwise is True.

Return type

bool

current_tt = <sc3.base.stream._MainTimeThread object>
main_tt = <sc3.base.stream._MainTimeThread object>
class NrtMain

Bases: object

classmethod elapsed_time()

Return main time thread’s seconds.

classmethod process(tailtime=0, proto='osc')

Generate and return OSC or MIDI command scores.

Parameters
  • tailtime (float) – Wait time after the last event. Used for reverb time or alike. Only has effect for OSC scores.

  • proto (str) – Score protocol to generate, possible values are ‘osc’ or`’midi’`.

Returns

Return type

An instance of either OscScore or MidiScore.

classmethod reset()

Reset sc3 time, scheduler and command scores to initial state.