![]() |
CsoundUnity 3.4.0
https://github.com/rorywalsh/CsoundUnity
|
Csound Unity Class More...
Public Types | |
enum | EnvType { SFDIR , SSDIR , SADIR , SFOUTYP , INCDIR , OPCODE6DIR , OPCODE6DIR64 , SNAPDIR , CSOUNDRC , CSSTRNGS , CS_LANG , RAWWAVE_PATH , CSNOSTOP , MFDIR , CS_OMIT_LIBS } |
The enum representing the Csound Environment Variables More... | |
enum | SamplesOrigin { Resources , StreamingAssets , Absolute } |
Where the samples to load come from: More... | |
Public Member Functions | |
delegate void | CsoundInitialized () |
The delegate of the event OnCsoundInitialized More... | |
int | GetVersion () |
Returns the Csound version number times 1000 (5.00.0 = 5000). More... | |
int | GetAPIVersion () |
Returns the Csound API version number times 100 (1.00 = 100). More... | |
int | LoadPlugins (string dir) |
Loads all plugins from a given directory More... | |
bool | CompiledWithoutError () |
Returns true if the csd file was compiled without errors. More... | |
void | SetCsd (string guid) |
Sets the csd file More... | |
int | CompileOrc (string orcStr) |
Parse, and compile the given orchestra from an ASCII string, also evaluating any global space code (i-time only) this can be called during performance to compile a new orchestra. This sample shows how to use CompileOrc More... | |
void | SendScoreEvent (string scoreEvent) |
Send a score event to Csound in the form of "i1 0 10 .... More... | |
void | RewindScore () |
Rewinds a compiled Csound score to the time specified with SetScoreOffsetSeconds(). More... | |
void | SetScoreOffsetSeconds (MYFLT value) |
Csound score events prior to the specified time are not performed, and performance begins immediately at the specified time (real-time events will continue to be performed as they are received). Can be used by external software, such as a VST host, to begin score performance midway through a Csound score, for example to repeat a loop in a sequencer, or to synchronize other events with the Csound score. More... | |
MYFLT | GetSr () |
Get the current sample rate More... | |
MYFLT | GetKr () |
Get the current control rate More... | |
int | PerformKsmps () |
Process a ksmps-sized block of samples More... | |
uint | GetKsmps () |
Get the number of audio sample frames per control sample. More... | |
void | SetInputSample (int frame, int channel, MYFLT sample) |
Set a sample in Csound's input buffer More... | |
void | AddInputSample (int frame, int channel, MYFLT sample) |
Adds the indicated sample into the audio input working buffer (spin); this only ever makes sense before calling PerformKsmps(). The frame and channel must be in bounds relative to ksmps and nchnls. NB: the spin buffer needs to be cleared at every k-cycle by calling ClearSpin(). More... | |
void | ClearSpin () |
Clears the input buffer (spin). More... | |
MYFLT | GetOutputSample (int frame, int channel) |
Get a sample from Csound's audio output buffer More... | |
MYFLT[] | GetSpin () |
Get Csound's audio input buffer More... | |
MYFLT[] | GetSpout () |
Get Csound's audio output buffer More... | |
void | SetChannel (string channel, MYFLT val) |
Sets a Csound channel. Used in connection with a chnget opcode in your Csound instrument. More... | |
void | SetChannel (CsoundChannelController channelController) |
Sets a Csound channel. Useful for setting presets at runtime. Used in connection with a chnget opcode in your Csound instrument. More... | |
void | SetChannels (List< CsoundChannelController > channelControllers, bool excludeButtons=true) |
Sets a list of Csound channels. More... | |
void | SetStringChannel (string channel, string val) |
Sets a string channel in Csound. Used in connection with a chnget opcode in your Csound instrument. More... | |
MYFLT | GetChannel (string channel) |
Gets a Csound channel. Used in connection with a chnset opcode in your Csound instrument. More... | |
CsoundChannelController | GetChannelController (string channel) |
Get a serialized CsoundChannelController More... | |
IDictionary< string, CsoundUnityBridge.ChannelInfo > | GetChannelList () |
Blocking method to get a list of the channels from Csound, not from the serialized list of this instance. 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.
| |
MYFLT[] | GetAudioChannel (string channel) |
Gets a Csound Audio channel. Used in connection with a chnset opcode in your Csound instrument. More... | |
int | CreateFloatTable (int tableNumber, float[] samples) |
Creates a table with the supplied float samples. Can be called during performance. More... | |
int | CreateTable (int tableNumber, MYFLT[] samples) |
Creates a table with the supplied samples. Can be called during performance. More... | |
int | CreateTableInstrument (int tableNumber, int tableLength) |
Creates an empty table, to be filled with samples later. Please note that trying to read the samples from an empty folder will produce a crash. Can be called during performance. More... | |
int | GetTableLength (int table) |
Returns the length of a function table (not including the guard point), or -1 if the table does not exist. More... | |
MYFLT | GetTableSample (int tableNumber, int index) |
Retrieves a single sample from a Csound function table. More... | |
int | GetTable (out MYFLT[] tableValues, int numTable) |
Stores values to function table 'numTable' 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... | |
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 | CopyTableOut (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 | CopyTableOutAsync (int table, out MYFLT[] dest) |
Asynchronous version of CopyTableOut. More... | |
void | CopyFloatTableIn (int table, float[] source) |
Same as CopyTableIn but passing a float array. More... | |
void | CopyTableIn (int table, MYFLT[] source) |
Copy the contents of a supplied array into a function table 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 | CopyTableInAsync (int table, MYFLT[] source) |
Asynchronous version of CopyTableIn 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... | |
CsoundUnityBridge.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 (CsoundUnityBridge.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 (EnvType envType) |
Get Environment path. 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... | |
IDictionary< string, IList< CsoundUnityBridge.OpcodeArgumentTypes > > | GetOpcodeList () |
Get the Opcode List, blocking More... | |
uint | GetNchnlsInputs () |
Get the number of input channels More... | |
uint | GetNchnls () |
Get the number of output channels More... | |
MYFLT | Get0dbfs () |
Get 0 dbfs More... | |
long | GetCurrentTimeSamples () |
Returns the current performance time in samples More... | |
void | CsoundReset () |
Resets all internal memory and state in preparation for a new performance. Enables external software to run successive Csound performances without reloading Csound. Implies csoundCleanup(), unless already called. More... | |
void | Cleanup () |
Prints information about the end of a performance, and closes audio and MIDI devices. Note: after calling csoundCleanup(), the operation of the perform functions is undefined. More... | |
void | SavePresetAsScriptableObject (string presetName, string path=null) |
Save a CsoundUnityPreset of this CsoundUnity instance at the specified path, using the specified presetName. The current csoundFileName and list of CsoundChannelControllers will be saved in the preset. If no presetName is given, a default one will be used. More... | |
void | SavePresetAsJSON (string presetName, string path=null, bool overwriteIfExisting=false) |
Save a preset as JSON using CsoundChannelControllers and CsoundFileName from this CsoundUnity instance. See SavePresetAsJSON(CsoundUnityPreset, string, bool) More... | |
void | SaveGlobalPreset (string presetName, string path=null, bool overwriteIfExisting=false) |
Save a serialized copy of this CsoundUnity instance. Similar behaviour as saving a Unity Preset from the inspector of the CsoundUnity component, but this can be used at runtime. More... | |
void | ConvertPresetToScriptableObject (string path, string destination) |
Convert a JSON preset into a Scriptable Object preset to be written at the specified path. If path is empty the converted preset will be saved inside the Assets folder. More... | |
CsoundUnityPreset | SetPreset (string presetName, string presetData) |
Set a CsoundUnityPreset to this CsoundUnity instance using a presetName and presetData. The set preset will be returned. More... | |
CsoundUnityPreset | SetPreset (string presetData) |
Set a CsoundUnityPreset to this CsoundUnity instance using presetData. More... | |
void | SetPreset (CsoundUnityPreset preset) |
Set a CsoundUnityPreset to this CsoundUnity instance. More... | |
CsoundUnity | SetGlobalPreset (string presetName, string presetData) |
Set a global preset to this CsoundUnity instance using a presetName and presetData. More... | |
void | LoadPreset (string path, Action< CsoundUnityPreset > onPresetLoaded=null) |
Loads a preset from a JSON file. The JSON file should represent a CsoundUnityPreset. More... | |
void | LoadGlobalPreset (string path) |
Load a global preset on this CsoundUnity instance from a JSON file found at path. The JSON file should represent a Global Preset, ie a complete CsoundUnity instance. More... | |
Static Public Member Functions | |
static List< string > | ParseCsdFileForAudioChannels (string filename) |
Parse the csd and returns available audio channels (set in csd via: More... | |
static List< CsoundChannelController > | ParseCsdFile (string filename) |
Parse the csd file More... | |
static float | Remap (float value, float from1, float to1, float from2, float to2, bool clamp=false) |
Linear remap floats within one range to another More... | |
static float | RemapTo0to1 (float value, float from, float to, float skew=1f) |
Remap a value to a normalized (0-1) value specifying its expected "from" and "to" values, and the skew of the exponential curve of the remapping. If skew is 1 the remapping is linear, if 0.5 it's exponential. More... | |
static float | RemapFrom0to1 (float value, float from, float to, float skew=1f) |
Remap a normalized (0-1) value to a value in another range, specifying its "from" and "to" values, and the skew of the exponential curve of the remapping. If skew is 1 the remapping is linear, if 0.5 it's exponential. More... | |
static MYFLT[] | ConvertToMYFLT (float[] samples) |
Utility method to create an array of MYFLTs from an array of floats More... | |
static float[] | ConvertToFloat (MYFLT[] samples) |
Utility method to create an array of floats from an array of MYFLTs More... | |
static MYFLT[] | GetStereoSamples (string source) |
Get an array of MYFLTs in from the AudioClip source from the Resources folder. The first index in the returned array will have its value set as 2 like the number of channels. See GetSamples More... | |
static float[] | GetStereoFloatSamples (string source) |
Get an array of floats from the AudioClip source from the Resources folder. The first index in the returned array will have its value set as 2 like the number of channels. See GetSamples More... | |
static MYFLT[] | GetMonoSamples (string source, int channelNumber) |
Get an array of MYFLTs from the AudioClip source from the Resources folder. No information about the channels will be added in the first element of the returned array. See GetSamples More... | |
static float[] | GetMonoFloatSamples (string source, int channelNumber) |
Get an array of floats from the AudioClip source from the Resources folder. No information about the channels will be added in the first element of the returned array. See GetSamples More... | |
static MYFLT[] | GetSamples (string source, int channelNumber=1, bool writeChannelData=false) |
Get Samples from a "Resources" path. This will return an interleaved array of samples, with the first index used to specify the number of channels. This array can be passed to the CsoundUnity.CreateTable() method for processing by Csound. Use async version to load very large files, or load from external paths Note: You need to be careful that your AudioClips match the SR of the project. If not, you will hear some re-pitching issues with your audio when you play it back with a table reader opcode. More... | |
static float[] | GetFloatSamples (string source, int channelNumber=1, bool writeChannelData=false) |
Same as GetSamples but it will return a float array. More... | |
static IEnumerator | GetSamples (string source, SamplesOrigin origin, Action< MYFLT[]> onSamplesLoaded) |
Async version of GetSamples More... | |
static MYFLT[] | GetSamples (AudioClip audioClip) |
Get samples from an AudioClip as a MYFLT array. More... | |
static CsoundUnityPreset | CreatePreset (string presetName, string csoundFileName, List< CsoundChannelController > channels) |
Create a CsoundUnityPreset from a presetName, csoundFileName and a list of CsoundChannelControllers More... | |
static CsoundUnityPreset | CreatePreset (string presetName, string presetData) |
Create a CsoundUnityPreset from a presetName and presetData. More... | |
static void | WritePreset (CsoundUnityPreset preset, string path) |
Write a CsoundUnityPreset at the specified path inside the Assets folder. You can pass a full path, the Assets folder path will be extracted. More... | |
static void | SavePresetAsJSON (CsoundUnityPreset preset, string path=null, bool overwriteIfExisting=false) |
Save the specified CsoundUnityPreset as JSON, at the specified path. If a file exists at the specified path, it will be overwritten if overwriteIfExisting is true. More... | |
static void | SavePresetAsJSON (List< CsoundChannelController > channels, string csoundFileName, string presetName, string path=null, bool overwriteIfExisting=false) |
Save a preset as JSON from a list of CsoundChannelController, specifying the related CsoundFileName and the presetName. See SavePresetAsJSON(CsoundUnityPreset, string, bool) More... | |
static List< CsoundUnityPreset > | ParseSnap (string csdPath, string snapPath) |
Parse a Cabbage Snap and return a list of CsoundUnityPresets. More... | |
Public Attributes | |
bool | logCsoundOutput = false |
If true, all Csound output messages will be sent to the Unity output console. Note that this can slow down performance if there is a lot of information being printed. More... | |
bool | mute = false |
If true no audio is sent to output More... | |
bool | processClipAudio |
If true Csound uses as an input the AudioClip attached to this AudioSource If false, no processing occurs on the attached AudioClip More... | |
bool | loudVolumeWarning = true |
If true it will print warnings in the console when the output volume is too high, and mute all the samples above the loudWarningThreshold value More... | |
float | loudWarningThreshold = 10f |
The volume threshold at which a warning is output to the console, and audio output is filtered More... | |
readonly Dictionary< string, MYFLT[]> | namedAudioChannelDataDict = new Dictionary<string, MYFLT[]>() |
public named audio Channels shown in CsoundUnityChild inspector More... | |
string | csoundScore |
the score to send via editor More... | |
List< EnvironmentSettings > | environmentSettings = new List<EnvironmentSettings>() |
The list of the Environment Settings that will be set on start, using csoundSetGlobalEnv. Each setting can be used to specify the path of an environment variable. These settings will be applied to this CsoundUnity instance when the CsoundUnityBridge is created. More... | |
Static Public Attributes | |
const string | packageName = "com.csound.csoundunity" |
The name of this package More... | |
const string | packageVersion = "3.4.0" |
The version of this package More... | |
Properties | |
string | csoundFileGUID [get] |
the unique guid of the csd file More... | |
string | csoundFileName [get] |
The file CsoundUnity will try to load. You can only load one file with each instance of CsoundUnity, but you can use as many instruments within that file as you wish.You may also create as many of CsoundUnity objects as you wish. More... | |
string | csoundString [get] |
a string to hold all the csoundFile content More... | |
List< CsoundChannelController > | channels [get] |
list to hold channel data More... | |
List< string > | availableAudioChannels [get] |
list to hold available audioChannels names More... | |
bool | IsInitialized [get] |
Is Csound initialized? More... | |
bool | PerformanceFinished [get] |
string | CurrentPreset [get] |
The current preset name. If empty, no preset has been set. More... | |
Events | |
CsoundInitialized | OnCsoundInitialized |
An event that will be executed when Csound is initialized More... | |
Csound Unity Class
Definition at line 270 of file CsoundUnity.cs.
enum CsoundUnity.EnvType |
The enum representing the Csound Environment Variables
Definition at line 2363 of file CsoundUnity.cs.
Where the samples to load come from:
the Resources folder
the StreamingAssets folder
An absolute path, can be external of the Unity Project
Enumerator | |
---|---|
Resources | |
StreamingAssets | |
Absolute |
Definition at line 2466 of file CsoundUnity.cs.
void CsoundUnity.AddInputSample | ( | int | frame, |
int | channel, | ||
MYFLT | sample | ||
) |
Adds the indicated sample into the audio input working buffer (spin); this only ever makes sense before calling PerformKsmps(). The frame and channel must be in bounds relative to ksmps and nchnls. NB: the spin buffer needs to be cleared at every k-cycle by calling ClearSpin().
frame | |
channel | |
sample |
Definition at line 941 of file CsoundUnity.cs.
void CsoundUnity.Cleanup | ( | ) |
Prints information about the end of a performance, and closes audio and MIDI devices. Note: after calling csoundCleanup(), the operation of the perform functions is undefined.
Definition at line 1749 of file CsoundUnity.cs.
void CsoundUnity.ClearSpin | ( | ) |
Clears the input buffer (spin).
Definition at line 949 of file CsoundUnity.cs.
bool CsoundUnity.CompiledWithoutError | ( | ) |
Returns true if the csd file was compiled without errors.
Definition at line 578 of file CsoundUnity.cs.
int CsoundUnity.CompileOrc | ( | string | orcStr | ) |
Parse, and compile the given orchestra from an ASCII string, also evaluating any global space code (i-time only) this can be called during performance to compile a new orchestra. This sample shows how to use CompileOrc
string orc = "instr 1 \n a1 rand 0dbfs/4 \n out a1 \nendin\n"; CompileOrc(orc);
orcStr |
Definition at line 655 of file CsoundUnity.cs.
void CsoundUnity.ConvertPresetToScriptableObject | ( | string | path, |
string | destination | ||
) |
Convert a JSON preset into a Scriptable Object preset to be written at the specified path. If path is empty the converted preset will be saved inside the Assets folder.
path |
Definition at line 1998 of file CsoundUnity.cs.
|
static |
Utility method to create an array of floats from an array of MYFLTs
samples |
Definition at line 1485 of file CsoundUnity.cs.
|
static |
Utility method to create an array of MYFLTs from an array of floats
samples |
Definition at line 1469 of file CsoundUnity.cs.
void CsoundUnity.CopyFloatTableIn | ( | int | table, |
float[] | source | ||
) |
Same as CopyTableIn but passing a float array.
table | |
source |
Definition at line 1233 of file CsoundUnity.cs.
void CsoundUnity.CopyTableIn | ( | int | table, |
MYFLT[] | source | ||
) |
Copy the contents of a supplied array into a function table The table number is assumed to be valid, and the destination needs to have sufficient space to receive all the function table contents.
table | the number of the table |
source | the supplied array |
Definition at line 1245 of file CsoundUnity.cs.
void CsoundUnity.CopyTableInAsync | ( | int | table, |
MYFLT[] | source | ||
) |
Asynchronous version of CopyTableIn
table | |
source |
Definition at line 1255 of file CsoundUnity.cs.
void CsoundUnity.CopyTableOut | ( | 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.
table | |
dest |
Definition at line 1213 of file CsoundUnity.cs.
void CsoundUnity.CopyTableOutAsync | ( | int | table, |
out MYFLT[] | dest | ||
) |
Asynchronous version of CopyTableOut.
table | |
dest |
Definition at line 1223 of file CsoundUnity.cs.
int CsoundUnity.CreateFloatTable | ( | int | tableNumber, |
float[] | samples | ||
) |
Creates a table with the supplied float samples. Can be called during performance.
tableNumber | The table number |
samples |
Definition at line 1109 of file CsoundUnity.cs.
|
static |
Create a CsoundUnityPreset from a presetName, csoundFileName and a list of CsoundChannelControllers
presetName | |
csoundFileName | |
channels |
Definition at line 1763 of file CsoundUnity.cs.
|
static |
Create a CsoundUnityPreset from a presetName and presetData.
PresetData should be a CsoundUnityPreset in the JSON format.
It will use the presetName parameter if not empty, if presetName is empty it will use preset.presetName, if also preset.presetName is empty it will use "CsoundUnityPreset" as a default name.
presetName | |
presetData |
Definition at line 1788 of file CsoundUnity.cs.
int CsoundUnity.CreateTable | ( | int | tableNumber, |
MYFLT[] | samples | ||
) |
Creates a table with the supplied samples. Can be called during performance.
tableNumber | The table number |
samples |
Definition at line 1122 of file CsoundUnity.cs.
int CsoundUnity.CreateTableInstrument | ( | int | tableNumber, |
int | tableLength | ||
) |
Creates an empty table, to be filled with samples later. Please note that trying to read the samples from an empty folder will produce a crash. Can be called during performance.
tableNumber | The number of the newly created table |
tableLength | The length of the table in samples |
AudioSettings.outputSampleRate
Definition at line 1142 of file CsoundUnity.cs.
delegate void CsoundUnity.CsoundInitialized | ( | ) |
The delegate of the event OnCsoundInitialized
void CsoundUnity.CsoundReset | ( | ) |
Resets all internal memory and state in preparation for a new performance. Enables external software to run successive Csound performances without reloading Csound. Implies csoundCleanup(), unless already called.
Definition at line 1740 of file CsoundUnity.cs.
MYFLT CsoundUnity.Get0dbfs | ( | ) |
int CsoundUnity.GetAPIVersion | ( | ) |
Returns the Csound API version number times 100 (1.00 = 100).
Definition at line 559 of file CsoundUnity.cs.
MYFLT[] CsoundUnity.GetAudioChannel | ( | string | channel | ) |
Gets a Csound Audio channel. Used in connection with a chnset opcode in your Csound instrument.
channel |
Definition at line 1093 of file CsoundUnity.cs.
MYFLT CsoundUnity.GetChannel | ( | string | channel | ) |
Gets a Csound channel. Used in connection with a chnset opcode in your Csound instrument.
channel |
Definition at line 1055 of file CsoundUnity.cs.
CsoundChannelController CsoundUnity.GetChannelController | ( | string | channel | ) |
Get a serialized CsoundChannelController
channel | the Channel name |
Definition at line 1065 of file CsoundUnity.cs.
IDictionary< string, CsoundUnityBridge.ChannelInfo > CsoundUnity.GetChannelList | ( | ) |
Blocking method to get a list of the channels from Csound, not from the serialized list of this instance. 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.
Definition at line 1079 of file CsoundUnity.cs.
long CsoundUnity.GetCurrentTimeSamples | ( | ) |
Returns the current performance time in samples
Definition at line 1396 of file CsoundUnity.cs.
string CsoundUnity.GetEnv | ( | EnvType | envType | ) |
Get Environment path.
envType | the type of the environment to get |
Definition at line 1338 of file CsoundUnity.cs.
|
static |
Same as GetSamples but it will return a float array.
source | |
channelNumber | |
writeChannelData |
Definition at line 1603 of file CsoundUnity.cs.
MYFLT CsoundUnity.GetKr | ( | ) |
uint CsoundUnity.GetKsmps | ( | ) |
Get the number of audio sample frames per control sample.
Definition at line 722 of file CsoundUnity.cs.
|
static |
Get an array of floats from the AudioClip source from the Resources folder. No information about the channels will be added in the first element of the returned array. See GetSamples
source | The name of the source to retrieve |
Definition at line 1539 of file CsoundUnity.cs.
|
static |
Get an array of MYFLTs from the AudioClip source from the Resources folder. No information about the channels will be added in the first element of the returned array. See GetSamples
source | The name of the source to retrieve |
Definition at line 1527 of file CsoundUnity.cs.
void CsoundUnity.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)
num | |
name | |
len |
Definition at line 1278 of file CsoundUnity.cs.
IDictionary< string, int > CsoundUnity.GetNamedGens | ( | ) |
Returns a Dictionary keyed by the names of all named table generators. Each name is paired with its internal function number.
Definition at line 1288 of file CsoundUnity.cs.
uint CsoundUnity.GetNchnls | ( | ) |
uint CsoundUnity.GetNchnlsInputs | ( | ) |
IDictionary< string, IList< CsoundUnityBridge.OpcodeArgumentTypes > > CsoundUnity.GetOpcodeList | ( | ) |
MYFLT CsoundUnity.GetOutputSample | ( | int | frame, |
int | channel | ||
) |
Get a sample from Csound's audio output buffer
frame | |
channel |
Definition at line 964 of file CsoundUnity.cs.
CsoundUnityBridge.CSOUND_PARAMS CsoundUnity.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.
oparms | a CSOUND_PARAMS structure to be filled in by csound |
Definition at line 1314 of file CsoundUnity.cs.
|
static |
Get samples from an AudioClip as a MYFLT array.
audioClip |
Definition at line 1665 of file CsoundUnity.cs.
|
static |
Get Samples from a "Resources" path. This will return an interleaved array of samples, with the first index used to specify the number of channels. This array can be passed to the CsoundUnity.CreateTable() method for processing by Csound. Use async version to load very large files, or load from external paths Note: You need to be careful that your AudioClips match the SR of the project. If not, you will hear some re-pitching issues with your audio when you play it back with a table reader opcode.
source | The path of the audio source relative to a "Resources" folder |
channelNumber | The channel to read from the source |
writeChannelData |
Definition at line 1557 of file CsoundUnity.cs.
|
static |
Async version of GetSamples
Example of usage: yield return CsoundUnity.GetSamples(source.name, CsoundUnity.SamplesOrigin.Resources, (samples) => { Debug.Log("samples loaded: "+samples.Length+", creating table"); csound.CreateTable(100, samples); });
source | the name of the AudioClip to load |
origin | the origin of the path |
onSamplesLoaded | the callback when samples are loaded |
Definition at line 1625 of file CsoundUnity.cs.
MYFLT[] CsoundUnity.GetSpin | ( | ) |
MYFLT[] CsoundUnity.GetSpout | ( | ) |
MYFLT CsoundUnity.GetSr | ( | ) |
|
static |
Get an array of floats from the AudioClip source from the Resources folder. The first index in the returned array will have its value set as 2 like the number of channels. See GetSamples
source | The name of the source to retrieve |
Definition at line 1515 of file CsoundUnity.cs.
|
static |
Get an array of MYFLTs in from the AudioClip source from the Resources folder. The first index in the returned array will have its value set as 2 like the number of channels. See GetSamples
source | The name of the source to retrieve |
Definition at line 1503 of file CsoundUnity.cs.
int CsoundUnity.GetTable | ( | out MYFLT[] | tableValues, |
int | numTable | ||
) |
Stores values to function table 'numTable' 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.
tableValues | |
numTable |
Definition at line 1177 of file CsoundUnity.cs.
int CsoundUnity.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}
args | |
index |
Definition at line 1191 of file CsoundUnity.cs.
int CsoundUnity.GetTableLength | ( | int | table | ) |
Returns the length of a function table (not including the guard point), or -1 if the table does not exist.
table |
Definition at line 1154 of file CsoundUnity.cs.
MYFLT CsoundUnity.GetTableSample | ( | int | tableNumber, |
int | index | ||
) |
Retrieves a single sample from a Csound function table.
tableNumber | |
index |
Definition at line 1165 of file CsoundUnity.cs.
int CsoundUnity.GetVersion | ( | ) |
Returns the Csound version number times 1000 (5.00.0 = 5000).
Definition at line 550 of file CsoundUnity.cs.
int CsoundUnity.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.
num |
Definition at line 1266 of file CsoundUnity.cs.
void CsoundUnity.LoadGlobalPreset | ( | string | path | ) |
Load a global preset on this CsoundUnity instance from a JSON file found at path. The JSON file should represent a Global Preset, ie a complete CsoundUnity instance.
This also sets the global preset, overriding the current content of this CsoundUnity instance.
This could have unintended consequences in certain situations. You could need to disable this CsoundUnity GameObject and enable it again to restore the Csound internal state.
path | The path must point to an existing JSON file |
Definition at line 2145 of file CsoundUnity.cs.
int CsoundUnity.LoadPlugins | ( | string | dir | ) |
Loads all plugins from a given directory
dir |
Definition at line 569 of file CsoundUnity.cs.
void CsoundUnity.LoadPreset | ( | string | path, |
Action< CsoundUnityPreset > | onPresetLoaded = null |
||
) |
Loads a preset from a JSON file. The JSON file should represent a CsoundUnityPreset.
This doesn't set the preset.
You should use the Action to get the reference of the loaded preset. This is needed because of the async nature of this method, that uses a WebRequest on Android and iOS.
Example of usage:
LoadPreset("myPath/presetName.json", (loadedPreset) => { SetPreset(loadedPreset); });
path | The path must point to an existing JSON file |
Definition at line 2105 of file CsoundUnity.cs.
|
static |
Parse the csd file
filename | the csd file to parse |
Definition at line 769 of file CsoundUnity.cs.
|
static |
Parse the csd and returns available audio channels (set in csd via:
chnset avar, "audio channel name")
filename |
Definition at line 736 of file CsoundUnity.cs.
|
static |
Parse a Cabbage Snap and return a list of CsoundUnityPresets.
csdPath | |
snapPath |
Definition at line 2171 of file CsoundUnity.cs.
int CsoundUnity.PerformKsmps | ( | ) |
|
static |
Linear remap floats within one range to another
value | |
from1 | |
to1 | |
from2 | |
to2 |
Definition at line 1410 of file CsoundUnity.cs.
|
static |
Remap a normalized (0-1) value to a value in another range, specifying its "from" and "to" values, and the skew of the exponential curve of the remapping. If skew is 1 the remapping is linear, if 0.5 it's exponential.
value | |
from | |
to | |
skew |
Definition at line 1452 of file CsoundUnity.cs.
|
static |
Remap a value to a normalized (0-1) value specifying its expected "from" and "to" values, and the skew of the exponential curve of the remapping. If skew is 1 the remapping is linear, if 0.5 it's exponential.
value | |
from | |
to | |
skew |
Definition at line 1429 of file CsoundUnity.cs.
void CsoundUnity.RewindScore | ( | ) |
Rewinds a compiled Csound score to the time specified with SetScoreOffsetSeconds().
Definition at line 673 of file CsoundUnity.cs.
void CsoundUnity.SaveGlobalPreset | ( | string | presetName, |
string | path = null , |
||
bool | overwriteIfExisting = false |
||
) |
Save a serialized copy of this CsoundUnity instance. Similar behaviour as saving a Unity Preset from the inspector of the CsoundUnity component, but this can be used at runtime.
presetName |
Definition at line 1974 of file CsoundUnity.cs.
|
static |
Save the specified CsoundUnityPreset as JSON, at the specified path. If a file exists at the specified path, it will be overwritten if overwriteIfExisting is true.
preset | |
path | |
overwriteIfExisting |
Definition at line 1915 of file CsoundUnity.cs.
|
static |
Save a preset as JSON from a list of CsoundChannelController, specifying the related CsoundFileName and the presetName. See SavePresetAsJSON(CsoundUnityPreset, string, bool)
channels | |
csoundFileName | |
presetName | |
path | |
overwriteIfExisting |
Definition at line 1942 of file CsoundUnity.cs.
void CsoundUnity.SavePresetAsJSON | ( | string | presetName, |
string | path = null , |
||
bool | overwriteIfExisting = false |
||
) |
Save a preset as JSON using CsoundChannelControllers and CsoundFileName from this CsoundUnity instance. See SavePresetAsJSON(CsoundUnityPreset, string, bool)
presetName | |
path | |
overwriteIfExisting |
Definition at line 1959 of file CsoundUnity.cs.
void CsoundUnity.SavePresetAsScriptableObject | ( | string | presetName, |
string | path = null |
||
) |
Save a CsoundUnityPreset of this CsoundUnity instance at the specified path, using the specified presetName. The current csoundFileName and list of CsoundChannelControllers will be saved in the preset. If no presetName is given, a default one will be used.
presetName | |
path |
Definition at line 1900 of file CsoundUnity.cs.
void CsoundUnity.SendScoreEvent | ( | string | scoreEvent | ) |
Send a score event to Csound in the form of "i1 0 10 ....
scoreEvent | the score string to send |
Definition at line 664 of file CsoundUnity.cs.
void CsoundUnity.SetChannel | ( | CsoundChannelController | channelController | ) |
Sets a Csound channel. Useful for setting presets at runtime. Used in connection with a chnget opcode in your Csound instrument.
channelController |
Definition at line 1017 of file CsoundUnity.cs.
void CsoundUnity.SetChannel | ( | string | channel, |
MYFLT | val | ||
) |
Sets a Csound channel. Used in connection with a chnget opcode in your Csound instrument.
channel | |
val |
Definition at line 995 of file CsoundUnity.cs.
void CsoundUnity.SetChannels | ( | List< CsoundChannelController > | channelControllers, |
bool | excludeButtons = true |
||
) |
Sets a list of Csound channels.
channelControllers | |
excludeButtons |
Definition at line 1030 of file CsoundUnity.cs.
void CsoundUnity.SetCsd | ( | string | guid | ) |
Sets the csd file
guid | the guid of the csd file asset |
Definition at line 591 of file CsoundUnity.cs.
int CsoundUnity.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.
name | The name of the environment variable to set |
value | The value to set, ie a path |
Definition at line 1351 of file CsoundUnity.cs.
CsoundUnity CsoundUnity.SetGlobalPreset | ( | string | presetName, |
string | presetData | ||
) |
Set a global preset to this CsoundUnity instance using a presetName and presetData.
Preset data should represent a CsoundUnity instance in JSON format.
This overrides the current content of this CsoundUnity instance.
This could have unintended consequences in certain situations. You could need to disable this CsoundUnity GameObject and enable it again to restore the Csound internal state.
This updated CsoundUnity instance will be returned.
presetName | |
presetData |
Definition at line 2077 of file CsoundUnity.cs.
void CsoundUnity.SetInputSample | ( | int | frame, |
int | channel, | ||
MYFLT | sample | ||
) |
Set a sample in Csound's input buffer
frame | |
channel | |
sample |
Definition at line 927 of file CsoundUnity.cs.
void CsoundUnity.SetParams | ( | CsoundUnityBridge.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.
parms | a |
Definition at line 1328 of file CsoundUnity.cs.
void CsoundUnity.SetPreset | ( | CsoundUnityPreset | preset | ) |
Set a CsoundUnityPreset to this CsoundUnity instance.
If the preset csoundFileName is different from this CsoundUnity instance csoundFileName the preset will not be set and an error will be logged.
preset |
Definition at line 2049 of file CsoundUnity.cs.
CsoundUnityPreset CsoundUnity.SetPreset | ( | string | presetData | ) |
Set a CsoundUnityPreset to this CsoundUnity instance using presetData.
The set preset will be returned. The name of the preset will be the one found inside presetData, if not empty. Otherwise a default presetName will be used.
Preset data should represent a CsoundUnityPreset in JSON format.
If the preset csoundFileName is different from this CsoundUnity instance csoundFileName the preset will not be set and an error will be logged.
presetData |
Definition at line 2038 of file CsoundUnity.cs.
CsoundUnityPreset CsoundUnity.SetPreset | ( | string | presetName, |
string | presetData | ||
) |
Set a CsoundUnityPreset to this CsoundUnity instance using a presetName and presetData. The set preset will be returned.
Preset data should represent a CsoundUnityPreset in JSON format.
If the preset csoundFileName is different from this CsoundUnity instance csoundFileName the preset will not be set and an error will be logged.
presetName | |
presetData |
Definition at line 2020 of file CsoundUnity.cs.
void CsoundUnity.SetScoreOffsetSeconds | ( | MYFLT | value | ) |
Csound score events prior to the specified time are not performed, and performance begins immediately at the specified time (real-time events will continue to be performed as they are received). Can be used by external software, such as a VST host, to begin score performance midway through a Csound score, for example to repeat a loop in a sequencer, or to synchronize other events with the Csound score.
value |
Definition at line 686 of file CsoundUnity.cs.
void CsoundUnity.SetStringChannel | ( | string | channel, |
string | val | ||
) |
Sets a string channel in Csound. Used in connection with a chnget opcode in your Csound instrument.
channel | |
val |
Definition at line 1045 of file CsoundUnity.cs.
void CsoundUnity.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.
table | |
index | |
value |
Definition at line 1202 of file CsoundUnity.cs.
|
static |
Write a CsoundUnityPreset at the specified path inside the Assets folder. You can pass a full path, the Assets folder path will be extracted.
preset | |
path |
Definition at line 1815 of file CsoundUnity.cs.
string CsoundUnity.csoundScore |
the score to send via editor
Definition at line 373 of file CsoundUnity.cs.
List<EnvironmentSettings> CsoundUnity.environmentSettings = new List<EnvironmentSettings>() |
The list of the Environment Settings that will be set on start, using csoundSetGlobalEnv. Each setting can be used to specify the path of an environment variable. These settings will be applied to this CsoundUnity instance when the CsoundUnityBridge is created.
Definition at line 382 of file CsoundUnity.cs.
bool CsoundUnity.logCsoundOutput = false |
If true, all Csound output messages will be sent to the Unity output console. Note that this can slow down performance if there is a lot of information being printed.
Definition at line 315 of file CsoundUnity.cs.
bool CsoundUnity.loudVolumeWarning = true |
If true it will print warnings in the console when the output volume is too high, and mute all the samples above the loudWarningThreshold value
Definition at line 332 of file CsoundUnity.cs.
float CsoundUnity.loudWarningThreshold = 10f |
The volume threshold at which a warning is output to the console, and audio output is filtered
Definition at line 338 of file CsoundUnity.cs.
bool CsoundUnity.mute = false |
If true no audio is sent to output
Definition at line 320 of file CsoundUnity.cs.
readonly Dictionary<string, MYFLT[]> CsoundUnity.namedAudioChannelDataDict = new Dictionary<string, MYFLT[]>() |
public named audio Channels shown in CsoundUnityChild inspector
Definition at line 353 of file CsoundUnity.cs.
|
static |
The name of this package
Definition at line 277 of file CsoundUnity.cs.
|
static |
The version of this package
Definition at line 282 of file CsoundUnity.cs.
bool CsoundUnity.processClipAudio |
If true Csound uses as an input the AudioClip attached to this AudioSource If false, no processing occurs on the attached AudioClip
Definition at line 326 of file CsoundUnity.cs.
|
get |
list to hold available audioChannels names
Definition at line 348 of file CsoundUnity.cs.
|
get |
list to hold channel data
Definition at line 343 of file CsoundUnity.cs.
|
get |
the unique guid of the csd file
Definition at line 287 of file CsoundUnity.cs.
|
get |
The file CsoundUnity will try to load. You can only load one file with each instance of CsoundUnity, but you can use as many instruments within that file as you wish.You may also create as many of CsoundUnity objects as you wish.
Definition at line 294 of file CsoundUnity.cs.
|
get |
a string to hold all the csoundFile content
Definition at line 299 of file CsoundUnity.cs.
|
get |
The current preset name. If empty, no preset has been set.
Definition at line 387 of file CsoundUnity.cs.
|
get |
Is Csound initialized?
Definition at line 358 of file CsoundUnity.cs.
|
get |
Definition at line 369 of file CsoundUnity.cs.
CsoundInitialized CsoundUnity.OnCsoundInitialized |
An event that will be executed when Csound is initialized
Definition at line 367 of file CsoundUnity.cs.