SpatialRender:
Filter:
3Dj/Classes (extension) | Libraries > 3Dj

SpatialRender
ExtensionExtension

a SpatDIF compilant spatial render

Description

A SuperCollider implementation of a Spatial Render. It reads OSC messages in SpatDIF format (from SSWorld or any other Sound Scene Simulator), as well as audio streams from Jack, and renders the corresponding audio.

Three different audio spatialization techniques are available, which can be changed on the fly:

  1. Ambisonics Up to full 3rd order. Decoding is provided externally by the AmbDec software.
    WARNING: AmbDec must be installed in the system in order to get the proper spatialized audio. The SpatialRender manages internally the connexions

  2. VBAP Thanks to the VBAP implementation
  3. Binaural Provided by the wonderful Ambisonic Toolkit, first encodes in HOA and then decodes using the HRTF models

It also handles internally a SpatDifLogger with autosaving features for recording the incoming messages.

See 3Dj for a deeper insight into the concepts.

Class Methods

.new

Create a instance of SpatialRender.

Default render parameters are \binaural decoder, \listen head, hrtfID 1002

Arguments:

server

Reference to the server

spatDifLoggerPath

String with the path to the folder in which save the log files.

If nil, the default path "~/.local/share/SuperCollider/SpatialRender" will be used

Discussion:

When a SpatialRender is instanciated, the server is (re)booted, in order to load VBAP and Binaural Buffers.

It also sets the SuperCollider output number to 24 (this parameter is accesible in the variable numAudioOutputs), and sets the required Jack connexions.

Instance Methods

Spatializatoin Techniques

.spatialTechnique

Get the current spatialization technique.

.setSpatializationTechnique

Set the desired spatialization technique. The possible values are either \ambisonics, \binaural or \vbap.

It manages internally the required Jack connexions (and eventually AmbDec instanciation/quit)

Ambisonics

.ambisonicsParameters

Get a Dictionary with the form (sourceName -> [order, shape] )

.setAmbisonicsParameters

If ambisonics is the current spatialization technique, configure its properties.

Arguments:

source

A Symbol with the name of one source, or nil for applying to all sources

NOTE: Notice that, in ambisonics, each source can be encoded in a different order, and with a different shape
order

Integer with the desired order. For the moment, between 0 and 3. Default to 3.

shape

One of the following

  1. \point classical punctual source. Default
  2. \ring arbitrary width ring-type surface around a virtual sphere's surface
  3. \extended arbitrary squared surface around a virtual sphere's surface
  4. \meridian a half meridian shape
internal

Private use

Binaural

.binauralDecoder

Get the current binaural decoder type

.binauralSubjectID

Get the current subject ID for the binaural model used

.setBinauralDecoder

Configure the binaural model, if \binaural is the current spatialization technique.

decoderType should be one of these: \spherical, \listen or \cipic. subjectID is the integer holding the subject code.

NOTE: subjectID number are not consecutive. Please check the reference

For more information about binaural decoders, check FoaDecoderKernel.

Vbap

.vbapSpeakerArray

Get the current vbap speaker configuration

.vbapSpeakerBuffer

Get the current vbap speaker buffer

.vbapNumSpeakers

get the current number of speakers in vbap

.setVbapParameters

Set the vbap speaker configuration.

speakerArray is an instance of VBAPSpeakerArray

Rendering Parameters

.setMaximumAttenuation

Set the maximum attenuation used used for the distance attenuation function. Default to 0.000016.

.setMaximumDistance

Set the maximum source distance used for the distance attenuation function. Default to 62500 m.

.setReferenceDistance

Set the reference distance used for the distance attenuation function. Default to 1 m.

.absorptionModel

.setAbsorptionModel

Select the air absorption model. The possible values are 0 for no model, 1 for standard model, or \default. Default to 1.

Check http://redmine.spatdif.org/attachments/download/105/SpatDIF-specs-V0.3.pdf, Appendix F

.attenuationModel

.setAttenuationModel

Select the distance attenuation model. Possible values are 0 for no model, 1 for higher attenuation model, 2 for lower attenuation model, or \default. Default to 2.

Check http://redmine.spatdif.org/attachments/download/105/SpatDIF-specs-V0.3.pdf, Appendix F

Network Communication

.worldAddresses

Get the list of all Classes/SSWorld addresses where to send back the scene information (in case of SpatDifPlayer playback) or remote control. Multiple addresses are allowed.

At instanciation, the only address available will be NetAddr: -localAddr. It is responsability of the user to provide a correct address, when working in remote.

.addWorldAddress

Add a NetAddress to the SpatialRender: -worldAddresses list.

.removeWorldAddress

Remove a NetAddress from the SpatialRender: -worldAddresses list.

Returns:

The removed NetAddress if succesful, or nil if not.

.resendToWorld

Get/set whether scene information will be resended to all associated SSWorld, when there is no SpatDifPlayer playback.

By default it will be false. User should set it only for remote visualization.

Control

.sourceNames

Get a List with all source names

.receiverFunctions

Get a Dictionary in the form [sourceName -> OSCReceiver function associated]

SpatDIF Logger

A SpatDifLogger instance is provided with the Spatial Render. It is recommended to control it from the following methods.

.spatDifLoggerPath

Get the current path for the SpatDIF log file.

.spatDifLoggerFilename

Get the complete file name for the SpatDIF log file.

.logOSC

Set wheter the SpatDifLogger is active or inactive.

.autosaveOSC

Activate or deactivate the autosave functionality of the log file. Default to true.

.autosavePeriod

Get/set the period between consecutive autosavings of the log file. Default to 10 s.

SpatDIF Player

A SpatDifPlayer instance is provided with the Spatial Render. It is recommended to control it from the following methods.

.spatDifPlayer_load

Load the content of a OSC-SpatDIF file and prepare it for playback.

Arguments:

aFile

String with the path to the file.

.spatDifPlayer_start

Start playback from the beggining of the document.

Arguments:

loop

Set the looping. 1 for one-shot, 2 for two repetitions... inf for eternal repeat

.spatDifPlayer_play

Starts playback from where it was paused last time.

.spatDifPlayer_pause

Pauses playback. Next call to SpatialRender: -spatDifPlayer_play will start from where it was paused.

.spatDifPlayer_stop

Stop playback. Next call to SpatialRender: -spatDifPlayer_play will start from the beginning

.spatDifPlayer_reset

Next call to SpatialRender: -spatDifPlayer_play will start from the beginning

.spatDifPlayer_isPlaying

Answer whether the player is currently playing. See SpatDifPlayer: -isPlaying

.spatDifPlayer_verbose

If true, it will print all sended messages.

Other

.verbose

If verbose is set to true, outcoming messages will be printed

.close

Close all OSCResponders, free all synths, close the OSC Logger file.

.server

Get the used server

Examples