SourceManager

The SourceManager component is responsible for creating and dispatching sources of motion sensors.

Como sources are represented as soundworks SharedState and act as middlewares between the actual sources of data (e.g. hardware) and the application, e.g.:

motion sensor -- [OSC] -> como source -- [websocket / SharedState] -> como application

Hence, the como source can exists but be inactive due to its underlying motion sensor being shutdown.

Como source stream must output a stream that follows the specification defined here: https://github.com/ircam-ismm/sc-motion/blob/main/FORMAT.md

The shared state is defined by the following parameters:

  • id - id of the source
  • type - type of the "real" source of motion data
  • nodeId - node who owns the source
  • infos - information (e.g. OSC config) used to configure the source
  • frame - motion data stream
  • active - whether the underlying sensor is active or not
  • record - if true record the source on the filesystem

Constructor

new SourceManager(como, name)

Description:
  • The SourceManager component is automatically created by the ComoNode instance.

    This constructor should never be called manually

Source:
Example
import { Client } from '@soundworks/core/client.js';
import ComoClient from '@ircam/como/ComoClient.js';

const client = new Client(config);
const como = new ComoClient(client);
await como.start();

const sourceId = await como.sourceManager.createSource({
  type: 'riot',
  id: '0',
  port: 8081,
  verbose: false,
});
Parameters:
Name Type Description
como ComoNode
name String

Attributes

(readonly) list :Array.<String>

Description:
  • List of current source ids.

Source:

(readonly) sources :SharedStateCollection

Description:
  • Lightweight collection of all the sources on the network. The collection only contains information that allows to monitor or control the sources, but does not contain the actual stream of data.

    If a node is interested in a particular motion stream source, it should explicity retrieve to the "full" source using SourceManager#getSource.

Source:

Methods

(async) createSource(config, nodeIdopt) → {String}

Description:
  • Create a new como source.

Source:
Parameters:
Name Type Attributes Default Description
config Object

The configuration object for the source.

nodeId String <optional>
this.como.nodeId

If given, creates the source on given como node.

Returns:

The id of the created source

Type
String

(async) deleteRecording(Filename)

Description:
  • Delete a given recording.

Source:
Parameters:
Name Type Description
Filename Filename

Filename of the recording

(async) deleteSource()

Description:
  • NOT IMPLEMENTED YET

    Delete an existing source.

Source:

(async) getSource(sourceId) → {SharedState|null}

Description:
  • Retrieve the full version of a source (i.e. with its stream) from its id.

    If the node is the owner of the source, the retrieved source will be the owned original instance of the shared state.

Source:
Parameters:
Name Type Description
sourceId String
Returns:
Type
SharedState | null

getSourceFiltered(sourceId) → {SharedState|undefined}

Description:
  • Return the lightweight version of a source (i.e. without its stream) from its id.

Source:
Parameters:
Name Type Description
sourceId String
Returns:
Type
SharedState | undefined

listRecordings() → {Object}

Description:
  • Returns the list of the existing recordings.

Source:
Returns:

The file tree of the projects's recordings directory

Type
Object

(async) readRecording(Filename) → {Blob}

Description:
  • Retrieve the content of a given recording.

Source:
Parameters:
Name Type Description
Filename Filename

Filename of the recording

Returns:
Type
Blob

sourceExists(sourceId) → {Boolean}

Description:
  • Check whether the given source id correspond to an existing source

Source:
Parameters:
Name Type Description
sourceId String
Returns:
Type
Boolean