CsoundUnity 3.4.0
https://github.com/rorywalsh/CsoundUnity
CsoundUnityBridge Class Reference

Classes

class  ChannelHints
 This structure holds the parameter hints for control channels. More...
 
class  ChannelInfo
 
class  CSOUND_PARAMS
 
class  OpcodeArgumentTypes
 Defines a class to hold out and in types, and flags More...
 

Public Types

enum  ChannelBehavior { None = 0 , Integer = 1 , Linear = 2 , Exponential = 3 }
 
enum  ChannelType {
  None = 0 , Control = 1 , Audio = 2 , String = 3 ,
  Pvs = 4 , Var = 5
}
 
enum  ChannelDirection { Input = 1 , Output = 2 }
 

Public Member Functions

 CsoundUnityBridge (string csdFile, List< EnvironmentSettings > environmentSettings)
 The CsoundUnityBridge constructor sets up the Csound Global Environment Variables set by the user. Then it creates an instance of Csound and compiles the full csdFile passed as a string. Then it starts Csound. More...
 
int LoadPlugins (string dir)
 
int GetVersion ()
 
int GetAPIVersion ()
 
void StopCsound ()
 
void OnApplicationQuit ()
 
void Cleanup ()
 
void Reset ()
 
bool CompiledWithoutError ()
 
int CompileOrc (string orchStr)
 
int PerformKsmps ()
 
MYFLT Get0dbfs ()
 
long GetCurrentTimeSamples ()
 
void SendScoreEvent (string scoreEvent)
 
void RewindScore ()
 
void CsoundSetScoreOffsetSeconds (MYFLT value)
 
void SetChannel (string channel, MYFLT value)
 
void SetStringChannel (string channel, string value)
 
void SetAudioChannel (string name, MYFLT[] audio)
 
MYFLT[] GetAudioChannel (string name)
 
int TableLength (int table)
 Returns the length of a function table (not including the guard point), or -1 if the table does not exist. More...
 
MYFLT GetTable (int table, int index)
 Returns the value of a slot in a function table. The table number and index are assumed to be valid. More...
 
void SetTable (int table, int index, MYFLT value)
 Sets the value of a slot in a function table. The table number and index are assumed to be valid. More...
 
void TableCopyOut (int table, out MYFLT[] dest)
 Copy the contents of a function table into a supplied array dest The table number is assumed to be valid, and the destination needs to have sufficient space to receive all the function table contents. More...
 
void TableCopyOutAsync (int table, out MYFLT[] dest)
 Asynchronous version of tableCopyOut() More...
 
void TableCopyIn (int table, MYFLT[] source)
 Copy the contents of an array source into a given function table The table number is assumed to be valid, and the table needs to have sufficient space to receive all the array contents. More...
 
void TableCopyInAsync (int table, MYFLT[] source)
 Asynchronous version of csoundTableCopyIn() More...
 
int GetTable (out MYFLT[] tableValues, int numTable)
 Stores values to function table 'tableNum' in tableValues, and returns the table length (not including the guard point). If the table does not exist, tableValues is set to NULL and -1 is returned. More...
 
int GetTableArgs (out MYFLT[] args, int index)
 Stores the arguments used to generate function table 'tableNum' in args, and returns the number of arguments used. If the table does not exist, args is set to NULL and -1 is returned. NB: the argument list starts with the GEN number and is followed by its parameters. eg. f 1 0 1024 10 1 0.5 yields the list {10.0,1.0,0.5} More...
 
int IsNamedGEN (int num)
 Checks if a given GEN number num is a named GEN if so, it returns the string length (excluding terminating NULL char) Otherwise it returns 0. More...
 
void GetNamedGEN (int num, out string name, int len)
 Gets the GEN name from a number num, if this is a named GEN The final parameter is the max len of the string (excluding termination) More...
 
IDictionary< string, int > GetNamedGens ()
 Returns a Dictionary keyed by the names of all named table generators. Each name is paired with its internal function number. More...
 
MYFLT GetSr ()
 
MYFLT GetKr ()
 
uint GetKsmps ()
 
MYFLT GetSpoutSample (int frame, int channel)
 Get a sample from Csound's audio output buffer More...
 
void AddSpinSample (int frame, int channel, MYFLT sample)
 
void SetSpinSample (int frame, int channel, MYFLT sample)
 Set a sample from Csound's audio output buffer More...
 
void ClearSpin ()
 Clears the input buffer (spin). More...
 
MYFLT[] GetSpin ()
 Returns the Csound audio input working buffer (spin) as a MYFLT array. Enables external software to write audio into Csound before calling csoundPerformKsmps. More...
 
MYFLT[] GetSpout ()
 Returns the Csound audio output working buffer (spout) as a MYFLT array. Enables external software to read audio from Csound after calling csoundPerformKsmps. More...
 
MYFLT GetChannel (string channel)
 Get a a control channel More...
 
uint GetNchnlsInput ()
 Get number of input channels More...
 
uint GetNchnls ()
 Get number of input channels More...
 
int GetCsoundMessageCount ()
 
string GetCsoundMessage ()
 
IDictionary< string, IList< OpcodeArgumentTypes > > GetOpcodeList ()
 Returns a sorted Dictionary keyed by all opcodes which are active in the current instance of csound. The values contain argument strings representing signatures for an opcode's output and input parameters. The argument strings pairs are stored in a list to accomodate opcodes with multiple signatures. More...
 
IDictionary< string, ChannelInfoGetChannelList ()
 Provides a dictionary of all currently defined channels resulting from compilation of an orchestra containing channel definitions. Entries, keyed by name, are polymorphically assigned to their correct data type: control, audio, string, pvc. Used by the Csound6SoftwareBus class to initialize its contents. More...
 
CSOUND_PARAMS GetParams ()
 Fills in a provided raw CSOUND_PARAMS object with csounds current parameter settings. This method is used internally to manage this class and is not expected to be used directly by a host program. More...
 
void SetParams (CSOUND_PARAMS parms)
 Transfers the contents of the provided raw CSOUND_PARAMS object into csound's internal data structues (chiefly its OPARMS structure). This method is used internally to manage this class and is not expected to be used directly by a host program. Most values are used and reflected in CSOUND_PARAMS. Internally to csound, as of release 6.0.0, Heartbeat and IsComputingOpcodeWeights are ignored and IsUsingCsdLineCounts can only be set and never reset once set. More...
 
string GetEnv (string key)
 Gets a string value from csound's environment values. Meaningful values include the contents of Windows' OS environment values such as SFDIR or SADIR for path name defaults. More...
 
int SetGlobalEnv (string name, string value)
 Set the global value of environment variable 'name' to 'value', or delete variable if 'value' is NULL. It is not safe to call this function while any Csound instances are active. See https://csound.com/docs/manual/CommandEnvironment.html for a list of the variables that can be used. More...
 

Static Public Member Functions

static string GetMessageText (IntPtr message)
 

Public Attributes

IntPtr csound
 

Detailed Description

Definition at line 42 of file CsoundUnityBridge.cs.

Member Enumeration Documentation

◆ ChannelBehavior

Enumerator
None 
Integer 
Linear 
Exponential 

Definition at line 789 of file CsoundUnityBridge.cs.

◆ ChannelDirection

Enumerator
Input 
Output 

Definition at line 811 of file CsoundUnityBridge.cs.

◆ ChannelType

Enumerator
None 
Control 
Audio 
String 
Pvs 
Var 

Definition at line 800 of file CsoundUnityBridge.cs.

Constructor & Destructor Documentation

◆ CsoundUnityBridge()

CsoundUnityBridge.CsoundUnityBridge ( string  csdFile,
List< EnvironmentSettings environmentSettings 
)

The CsoundUnityBridge constructor sets up the Csound Global Environment Variables set by the user. Then it creates an instance of Csound and compiles the full csdFile passed as a string. Then it starts Csound.

Parameters
csdFileThe Csound (.csd) file content as a string
environmentSettingsA list of the Csound Environments settings defined by the user

Definition at line 115 of file CsoundUnityBridge.cs.

Member Function Documentation

◆ AddSpinSample()

void CsoundUnityBridge.AddSpinSample ( int  frame,
int  channel,
MYFLT  sample 
)

Definition at line 471 of file CsoundUnityBridge.cs.

◆ Cleanup()

void CsoundUnityBridge.Cleanup ( )

Definition at line 191 of file CsoundUnityBridge.cs.

◆ ClearSpin()

void CsoundUnityBridge.ClearSpin ( )

Clears the input buffer (spin).

Definition at line 487 of file CsoundUnityBridge.cs.

◆ CompiledWithoutError()

bool CsoundUnityBridge.CompiledWithoutError ( )

Definition at line 201 of file CsoundUnityBridge.cs.

◆ CompileOrc()

int CsoundUnityBridge.CompileOrc ( string  orchStr)

Definition at line 206 of file CsoundUnityBridge.cs.

◆ CsoundSetScoreOffsetSeconds()

void CsoundUnityBridge.CsoundSetScoreOffsetSeconds ( MYFLT  value)

Definition at line 236 of file CsoundUnityBridge.cs.

◆ Get0dbfs()

MYFLT CsoundUnityBridge.Get0dbfs ( )

Definition at line 216 of file CsoundUnityBridge.cs.

◆ GetAPIVersion()

int CsoundUnityBridge.GetAPIVersion ( )

Definition at line 173 of file CsoundUnityBridge.cs.

◆ GetAudioChannel()

MYFLT[] CsoundUnityBridge.GetAudioChannel ( string  name)

Definition at line 260 of file CsoundUnityBridge.cs.

◆ GetChannel()

MYFLT CsoundUnityBridge.GetChannel ( string  channel)

Get a a control channel

Definition at line 523 of file CsoundUnityBridge.cs.

◆ GetChannelList()

IDictionary< string, ChannelInfo > CsoundUnityBridge.GetChannelList ( )

Provides a dictionary of all currently defined channels resulting from compilation of an orchestra containing channel definitions. Entries, keyed by name, are polymorphically assigned to their correct data type: control, audio, string, pvc. Used by the Csound6SoftwareBus class to initialize its contents.

Returns
a dictionary of all currently defined channels keyed by their name to its ChannelInfo

Definition at line 609 of file CsoundUnityBridge.cs.

◆ GetCsoundMessage()

string CsoundUnityBridge.GetCsoundMessage ( )

Definition at line 549 of file CsoundUnityBridge.cs.

◆ GetCsoundMessageCount()

int CsoundUnityBridge.GetCsoundMessageCount ( )

Definition at line 544 of file CsoundUnityBridge.cs.

◆ GetCurrentTimeSamples()

long CsoundUnityBridge.GetCurrentTimeSamples ( )

Definition at line 221 of file CsoundUnityBridge.cs.

◆ GetEnv()

string CsoundUnityBridge.GetEnv ( string  key)

Gets a string value from csound's environment values. Meaningful values include the contents of Windows' OS environment values such as SFDIR or SADIR for path name defaults.

Parameters
keythe name of the Environment Variable to get
Returns
the corresponding value or an empty string if no such key exists

Definition at line 866 of file CsoundUnityBridge.cs.

◆ GetKr()

MYFLT CsoundUnityBridge.GetKr ( )

Definition at line 453 of file CsoundUnityBridge.cs.

◆ GetKsmps()

uint CsoundUnityBridge.GetKsmps ( )

Definition at line 458 of file CsoundUnityBridge.cs.

◆ GetMessageText()

static string CsoundUnityBridge.GetMessageText ( IntPtr  message)
static

Definition at line 556 of file CsoundUnityBridge.cs.

◆ GetNamedGEN()

void CsoundUnityBridge.GetNamedGEN ( int  num,
out string  name,
int  len 
)

Gets the GEN name from a number num, if this is a named GEN The final parameter is the max len of the string (excluding termination)

Definition at line 414 of file CsoundUnityBridge.cs.

◆ GetNamedGens()

IDictionary< string, int > CsoundUnityBridge.GetNamedGens ( )

Returns a Dictionary keyed by the names of all named table generators. Each name is paired with its internal function number.

Returns

Definition at line 435 of file CsoundUnityBridge.cs.

◆ GetNchnls()

uint CsoundUnityBridge.GetNchnls ( )

Get number of input channels

Definition at line 539 of file CsoundUnityBridge.cs.

◆ GetNchnlsInput()

uint CsoundUnityBridge.GetNchnlsInput ( )

Get number of input channels

Definition at line 531 of file CsoundUnityBridge.cs.

◆ GetOpcodeList()

IDictionary< string, IList< OpcodeArgumentTypes > > CsoundUnityBridge.GetOpcodeList ( )

Returns a sorted Dictionary keyed by all opcodes which are active in the current instance of csound. The values contain argument strings representing signatures for an opcode's output and input parameters. The argument strings pairs are stored in a list to accomodate opcodes with multiple signatures.

Returns
A sorted Dictionary keyed by all opcodes which are active in the current instance of csound.

Definition at line 568 of file CsoundUnityBridge.cs.

◆ GetParams()

CSOUND_PARAMS CsoundUnityBridge.GetParams ( )

Fills in a provided raw CSOUND_PARAMS object with csounds current parameter settings. This method is used internally to manage this class and is not expected to be used directly by a host program.

Parameters
oparmsa CSOUND_PARAMS structure to be filled in by csound
Returns
The same parameter structure that was provided but filled in with csounds current internal contents

Definition at line 647 of file CsoundUnityBridge.cs.

◆ GetSpin()

MYFLT[] CsoundUnityBridge.GetSpin ( )

Returns the Csound audio input working buffer (spin) as a MYFLT array. Enables external software to write audio into Csound before calling csoundPerformKsmps.

Returns
a MYFLT array representing the Csound audio input buffer

Definition at line 497 of file CsoundUnityBridge.cs.

◆ GetSpout()

MYFLT[] CsoundUnityBridge.GetSpout ( )

Returns the Csound audio output working buffer (spout) as a MYFLT array. Enables external software to read audio from Csound after calling csoundPerformKsmps.

Returns
a MYFLT array representing the Csound audio output buffer

Definition at line 511 of file CsoundUnityBridge.cs.

◆ GetSpoutSample()

MYFLT CsoundUnityBridge.GetSpoutSample ( int  frame,
int  channel 
)

Get a sample from Csound's audio output buffer

Definition at line 466 of file CsoundUnityBridge.cs.

◆ GetSr()

MYFLT CsoundUnityBridge.GetSr ( )

Definition at line 448 of file CsoundUnityBridge.cs.

◆ GetTable() [1/2]

MYFLT CsoundUnityBridge.GetTable ( int  table,
int  index 
)

Returns the value of a slot in a function table. The table number and index are assumed to be valid.

Definition at line 282 of file CsoundUnityBridge.cs.

◆ GetTable() [2/2]

int CsoundUnityBridge.GetTable ( out MYFLT[]  tableValues,
int  numTable 
)

Stores values to function table 'tableNum' in tableValues, and returns the table length (not including the guard point). If the table does not exist, tableValues is set to NULL and -1 is returned.

Definition at line 364 of file CsoundUnityBridge.cs.

◆ GetTableArgs()

int CsoundUnityBridge.GetTableArgs ( out MYFLT[]  args,
int  index 
)

Stores the arguments used to generate function table 'tableNum' in args, and returns the number of arguments used. If the table does not exist, args is set to NULL and -1 is returned. NB: the argument list starts with the GEN number and is followed by its parameters. eg. f 1 0 1024 10 1 0.5 yields the list {10.0,1.0,0.5}

Definition at line 389 of file CsoundUnityBridge.cs.

◆ GetVersion()

int CsoundUnityBridge.GetVersion ( )

Definition at line 168 of file CsoundUnityBridge.cs.

◆ IsNamedGEN()

int CsoundUnityBridge.IsNamedGEN ( int  num)

Checks if a given GEN number num is a named GEN if so, it returns the string length (excluding terminating NULL char) Otherwise it returns 0.

Definition at line 405 of file CsoundUnityBridge.cs.

◆ LoadPlugins()

int CsoundUnityBridge.LoadPlugins ( string  dir)

Definition at line 162 of file CsoundUnityBridge.cs.

◆ OnApplicationQuit()

void CsoundUnityBridge.OnApplicationQuit ( )

Definition at line 183 of file CsoundUnityBridge.cs.

◆ PerformKsmps()

int CsoundUnityBridge.PerformKsmps ( )

Definition at line 211 of file CsoundUnityBridge.cs.

◆ Reset()

void CsoundUnityBridge.Reset ( )

Definition at line 196 of file CsoundUnityBridge.cs.

◆ RewindScore()

void CsoundUnityBridge.RewindScore ( )

Definition at line 231 of file CsoundUnityBridge.cs.

◆ SendScoreEvent()

void CsoundUnityBridge.SendScoreEvent ( string  scoreEvent)

Definition at line 226 of file CsoundUnityBridge.cs.

◆ SetAudioChannel()

void CsoundUnityBridge.SetAudioChannel ( string  name,
MYFLT[]  audio 
)

Definition at line 251 of file CsoundUnityBridge.cs.

◆ SetChannel()

void CsoundUnityBridge.SetChannel ( string  channel,
MYFLT  value 
)

Definition at line 241 of file CsoundUnityBridge.cs.

◆ SetGlobalEnv()

int CsoundUnityBridge.SetGlobalEnv ( string  name,
string  value 
)

Set the global value of environment variable 'name' to 'value', or delete variable if 'value' is NULL. It is not safe to call this function while any Csound instances are active. See https://csound.com/docs/manual/CommandEnvironment.html for a list of the variables that can be used.

Parameters
nameThe name of the environment variable to set
valueThe value to set, ie a path
Returns
Returns zero on success.

Definition at line 879 of file CsoundUnityBridge.cs.

◆ SetParams()

void CsoundUnityBridge.SetParams ( CSOUND_PARAMS  parms)

Transfers the contents of the provided raw CSOUND_PARAMS object into csound's internal data structues (chiefly its OPARMS structure). This method is used internally to manage this class and is not expected to be used directly by a host program. Most values are used and reflected in CSOUND_PARAMS. Internally to csound, as of release 6.0.0, Heartbeat and IsComputingOpcodeWeights are ignored and IsUsingCsdLineCounts can only be set and never reset once set.

Parameters
parmsa

Definition at line 663 of file CsoundUnityBridge.cs.

◆ SetSpinSample()

void CsoundUnityBridge.SetSpinSample ( int  frame,
int  channel,
MYFLT  sample 
)

Set a sample from Csound's audio output buffer

Definition at line 479 of file CsoundUnityBridge.cs.

◆ SetStringChannel()

void CsoundUnityBridge.SetStringChannel ( string  channel,
string  value 
)

Definition at line 246 of file CsoundUnityBridge.cs.

◆ SetTable()

void CsoundUnityBridge.SetTable ( int  table,
int  index,
MYFLT  value 
)

Sets the value of a slot in a function table. The table number and index are assumed to be valid.

Definition at line 290 of file CsoundUnityBridge.cs.

◆ StopCsound()

void CsoundUnityBridge.StopCsound ( )

Definition at line 178 of file CsoundUnityBridge.cs.

◆ TableCopyIn()

void CsoundUnityBridge.TableCopyIn ( int  table,
MYFLT[]  source 
)

Copy the contents of an array source into a given function table The table number is assumed to be valid, and the table needs to have sufficient space to receive all the array contents.

Definition at line 337 of file CsoundUnityBridge.cs.

◆ TableCopyInAsync()

void CsoundUnityBridge.TableCopyInAsync ( int  table,
MYFLT[]  source 
)

Asynchronous version of csoundTableCopyIn()

Definition at line 350 of file CsoundUnityBridge.cs.

◆ TableCopyOut()

void CsoundUnityBridge.TableCopyOut ( int  table,
out MYFLT[]  dest 
)

Copy the contents of a function table into a supplied array dest The table number is assumed to be valid, and the destination needs to have sufficient space to receive all the function table contents.

Definition at line 298 of file CsoundUnityBridge.cs.

◆ TableCopyOutAsync()

void CsoundUnityBridge.TableCopyOutAsync ( int  table,
out MYFLT[]  dest 
)

Asynchronous version of tableCopyOut()

Definition at line 317 of file CsoundUnityBridge.cs.

◆ TableLength()

int CsoundUnityBridge.TableLength ( int  table)

Returns the length of a function table (not including the guard point), or -1 if the table does not exist.

Definition at line 274 of file CsoundUnityBridge.cs.

Member Data Documentation

◆ csound

IntPtr CsoundUnityBridge.csound

Definition at line 44 of file CsoundUnityBridge.cs.


The documentation for this class was generated from the following file: