|
| | CsoundWorker () |
| | Creates and starts an offline worker. Call from Unity's main thread.
|
| override bool | Reset () |
| | Refuses reset because the worker owns a performance thread outside the audio handshake.
|
| override bool | Destroy () |
| | Joins the performance thread, then frees the instance.
|
| int | CreateTable (int tableNumber, MYFLT[] samples) |
| | Creates a table with the supplied samples. Can be called during performance.
|
| 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 table will produce a crash. Can be called during performance.
|
| bool | SaveAudioFile (string destination, float[] samples, int bitsPerSample=16) |
| | Writes samples to an audio file, by loading them into a function table and running an instrument that calls ftaudio. The extension of destination picks the format.
|
| int | ScheduleInstrument (int instrNumber, float start, float duration, params string[] pfields) |
| | Schedules one instrument instance on this worker's instance.
|
| void | PerformanceThread () |
| | The worker's loop: calls csoundPerformKsmps until the score ends, an error comes back, or the worker is destroyed. This is the body of the dedicated thread.
|
| CsoundArrayChannelStatus | InitializeArrayChannel (string name, CsoundArrayChannelType type, params int[] sizes) |
| | Initialize an array channel, or validate an existing channel without resizing it. May allocate and briefly suspend Unity audio; never call from a performance callback. A subclass driving its own performance thread must stop that thread before initialization.
|
| CsoundArrayChannelStatus | GetArrayChannelInfo (string name, int[] sizes, out CsoundArrayChannelInfo info) |
| | Read array metadata and axis sizes into a reusable buffer; no channel is created.
|
| CsoundArrayChannelStatus | GetArrayChannel (string name, MYFLT[] destination, out int length) |
| | Copy a complete numeric array to a flat buffer; length reports required capacity on BufferTooSmall.
|
| CsoundArrayChannelStatus | GetArrayChannel (string name, MYFLT[] destination, int[] sizes, out CsoundArrayChannelInfo info) |
| | Read numeric values, axis sizes and matching metadata atomically; no partial copy occurs.
|
| CsoundArrayChannelStatus | SetArrayChannel (string name, MYFLT[] source) |
| | Write exactly the current number of numeric elements without creating or resizing the channel.
|
| CsoundArrayChannelStatus | GetAudioArrayChannel (string name, MYFLT[] destination, out int length) |
| | Read a[] blocks in element order, ksmps samples per element; length reports required samples.
|
| CsoundArrayChannelStatus | GetAudioArrayChannel (string name, MYFLT[] destination, int[] sizes, out CsoundArrayChannelInfo info) |
| | Read all audio blocks and their matching shape; no buffer changes on BufferTooSmall.
|
| CsoundArrayChannelStatus | SetAudioArrayChannel (string name, MYFLT[] source) |
| | Replace all a[] blocks; source must contain exactly ElementCount × ksmps samples.
|
| | CsoundUnityBridge () |
| | Default parameterless constructor. Creates an uninitialised bridge instance.
|
| | CsoundUnityBridge (string csdFile, List< EnvironmentSettings > environmentSettings, float audioRate, float controlRate, int ksmps=0) |
| | 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.
|
| void | EnqueueMidiMessage (byte[] data) |
| | Enqueues a raw MIDI message to be delivered to Csound on the next ksmps cycle. Can be called from any thread.
|
| int | LoadPlugins (string dir) |
| | Loads all Csound plugins found in the specified directory. Not available on iOS; use the conditional compilation guard before calling.
|
| int | GetVersion () |
| | Returns the Csound library version as an integer (e.g. 6180 for version 6.18.0). On WebGL, available after initialization completes.
|
| bool | CompiledWithoutError () |
| | Returns true if the CSD compiled without errors; equivalent to reading CompiledOk.
|
| int | CompileOrc (string orchStr) |
| | Compiles the given Csound orchestra string at runtime, adding new instruments and UDOs to the running instance.
|
| int | Start () |
| | Starts a compiled orchestra after reset and enables audio callbacks. Call CompileOrc first. A running instance is left running without starting it twice.
|
| int | PerformKsmps () |
| | Advances Csound by one ksmps block, filling the spout buffer, and caches the spout/spin pointers on the first successful call.
|
| MYFLT | Get0dbfs () |
| | Returns the 0 dBFS value (full-scale amplitude) for this Csound instance, as set by the 0dbfs header statement.
|
| long | GetCurrentTimeSamples () |
| | Returns the current performance position in samples from the start of the performance.
|
| void | SendScoreEvent (string scoreEvent) |
| | Sends a score event string to Csound (e.g. "i 1 0 1 0.5 440") for immediate processing.
|
| void | RewindScore () |
| | Rewinds the score to the beginning, allowing the performance to repeat from time zero.
|
| void | CsoundSetScoreOffsetSeconds (MYFLT value) |
| | Sets the score time offset in seconds, causing performance to start from the given point in the score.
|
| void | SetChannel (string channel, MYFLT value) |
| | Sets the value of a named Csound control channel.
|
| void | SetStringChannel (string channel, string value) |
| | Sets the value of a named Csound string channel.
|
| void | SetAudioChannel (string name, MYFLT[] audio) |
| | Writes a ksmps-length audio buffer into the named Csound audio channel. Only the first ksmps samples are used; excess samples are ignored. A shorter array is padded with silence; an empty array clears the channel.
|
| MYFLT[] | GetAudioChannel (string name) |
| | Reads the named Csound audio channel into a newly allocated array of length ksmps. Use the zero-allocation overload on hot audio-thread paths to avoid GC pressure.
|
| void | GetAudioChannel (string name, MYFLT[] dest) |
| | Zero-allocation overload: reads the named audio channel directly into dest without any managed or native heap allocation. Use this on hot audio-thread paths to avoid GC pressure.
|
| string | GetStringChannel (string name) |
| | Reads the current value of the named Csound string channel.
|
| int | TableLength (int table) |
| | Returns the length of a function table (not including the guard point), or -1 if the table does not exist.
|
| 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.
|
| 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.
|
| void | TableCopyOut (int table, out MYFLT[] dest) |
| | Copies the contents of a function table into a supplied array. The table number is assumed to be valid, and the destination will be resized to fit all table contents.
|
| void | TableCopyIn (int table, MYFLT[] source) |
| | Copies the contents of an array into a given function table. The table number is assumed to be valid, and the table must have sufficient space to receive all array contents.
|
| int | GetTable (out MYFLT[] tableValues, int numTable) |
| | Stores values of 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.
|
| int | GetTableArgs (out MYFLT[] args, int index) |
| | Stores the arguments used to generate function table index in args , and returns the number of arguments used. If the table does not exist, args is set to null and -1 is returned.
|
| MYFLT | GetSr () |
| | Returns the audio sample rate (sr) of the current Csound instance.
|
| MYFLT | GetKr () |
| | Returns the control rate (kr) of the current Csound instance.
|
| uint | GetKsmps () |
| | Returns the number of samples per control period (ksmps). Returns the cached value when available (set after csoundStart) to avoid a P/Invoke on the hot path.
|
| MYFLT | GetSpoutSample (int frame, int channel) |
| | Get a sample from Csound's audio output buffer. Hot path — uses cached spout pointer and channel count; zero allocation. The pointer is fetched lazily because csoundGetSpout may return NULL before the first csoundPerformKsmps.
|
| void | AddSpinSample (int frame, int channel, MYFLT sample) |
| | Add a value to a sample in Csound's audio input buffer. Hot path — uses cached spin pointer and channel count; zero allocation.
|
| void | SetSpinSample (int frame, int channel, MYFLT sample) |
| | Set a sample in Csound's audio input buffer. Hot path — uses cached spin pointer and channel count; zero allocation.
|
| void | ClearSpin () |
| | Clears the input buffer (spin).
|
| 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.
|
| 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.
|
| MYFLT | GetChannel (string channel) |
| | Returns the current value of the named Csound control channel. On WebGL returns the last-known cached value (0 until the first async read completes) and automatically schedules a non-blocking refresh via the callback-based overload.
|
| uint | GetNchnlsInput () |
| | Get number of input channels.
|
| uint | GetNchnls () |
| | Get number of output channels.
|
| int | GetCsoundMessageCount () |
| | Returns the number of pending messages in Csound's message buffer.
|
| string | GetCsoundMessage () |
| | Retrieves and removes the first pending message from Csound's message buffer.
|
| IDictionary< string, ChannelInfo > | 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 internally to initialize channel contents.
|
| 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.
|
| 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.
|
| CsoundPvsChannelStatus | InitializePvsChannel (string name, int fftSize, int overlap, int windowSize, int windowType=1, CsoundPvsFormat format=CsoundPvsFormat.AmplitudeFrequency) |
| | Create or verify a fixed-layout, non-sliding PVS channel. Setup only; may briefly suspend Unity audio.
|
| CsoundPvsChannelStatus | GetPvsChannelInfo (string name, out CsoundPvsChannelInfo info) |
| | Read PVS layout and frame counter without creating a channel.
|
| CsoundPvsChannelStatus | GetPvsChannel (string name, float[] destination, out CsoundPvsChannelInfo info) |
| | Read one complete N+2 float frame and matching metadata; unused trailing entries are unchanged.
|
| CsoundPvsChannelStatus | SetPvsChannel (string name, float[] source) |
| | Write exactly N+2 floats and advance the destination frame counter once on success.
|
| CsoundPvsChannelStatus | SetPvsChannel (string name, float[] source, CsoundPvsChannelInfo frame) |
| | Write a snapshot to a channel with the same layout, preserving the supplied frame counter.
|
| CsoundArrayChannelStatus | GetStringArrayChannel (string name, string[] destination, out int length) |
| | Read S[] values into a reusable container; changed strings allocate and unused trailing entries remain unchanged.
|
| CsoundArrayChannelStatus | GetStringArrayChannel (string name, string[] destination, int[] sizes, out CsoundArrayChannelInfo info) |
| | Read string data and matching axis sizes atomically; UTF-8 decoding happens outside the native lock.
|
| CsoundArrayChannelStatus | SetStringArrayChannel (string name, string[] source) |
| | Replace every S[] element; null becomes empty, embedded null characters are rejected. Not for audio callbacks.
|
| void | TableCopyOutAsync (int table, out MYFLT[] dest) |
| | Queues a table read. The returned array is filled during a later performance cycle.
|
| CsoundTableCopySubmission | TableCopyOutAsync (int table, out MYFLT[] dest, out CsoundTableCopyRequest request) |
| | Queues a table read and returns a request to poll. The destination is valid on success.
|
| void | TableCopyInAsync (int table, MYFLT[] source) |
| | Queues a copy of the source samples into the table, preserving any remaining entries.
|
| CsoundTableCopySubmission | TableCopyInAsync (int table, MYFLT[] source, out CsoundTableCopyRequest request) |
| | Queues a table write and returns a request to poll, or null if it could not be queued.
|
|
| enum | ChannelBehavior { None = 0
, Integer = 1
, Linear = 2
, Exponential = 3
} |
| | Defines the interpolation behavior of a Csound control channel. More...
|
| enum | ChannelType {
None = 0
, Control = 1
, Audio = 2
, String = 3
,
Pvs = 4
, Var = 5
, Array = 6
} |
| | Identifies the data type carried by a Csound software-bus channel. More...
|
| enum | ChannelDirection { Input = 1
, Output = 2
} |
| | Flags indicating whether a Csound channel is readable (input), writable (output), or both. More...
|
| IntPtr | csound |
| | The raw Csound instance handle used for all native P/Invoke calls.
|
| volatile bool | Muted |
| | Mirrors the owning CsoundUnity.mute flag so that the audio paths which read spout without going through ProcessBlock — IAudioGenerator and RootOutput — can honour it. ProcessBlock checks mute directly and does not use this.
|
| volatile bool | Paused |
| | Mirrors the owning CsoundUnity.pauseProcessing flag, for the same reason as Muted. When set, those paths skip PerformKsmps entirely and output silence.
|
| volatile int | StartupFadeFrames |
| | Length of the startup fade in output frames, 0 when off. Pushed by CsoundUnity from its fadeInSeconds; lives here for the same reason OutputGain does, so the paths that read spout directly — IAudioGenerator and RootOutput — cannot end up fading differently from each other or from OnAudioFilterRead.
|
| volatile float | LoudThreshold = float.PositiveInfinity |
| | Sample value at which an audio path silences a sample and reports a runaway. Pushed by CsoundUnity from its loudWarningThreshold, and PositiveInfinity when that check is off, which still catches a sample that is not a number. Here for the same reason StartupFadeFrames is: so the paths that read spout directly guard the output the way OnAudioFilterRead does.
|
| volatile float | SpatialBlend |
| | How far the AudioSource is spatialized, 0 to 1, pushed by CsoundUnity every frame. The IAudioGenerator path needs it because Unity sums a generator's channels for a spatialized source, so a mono bed written into every channel has to be divided by what that costs.
|
| volatile float | LoudPeak |
| | The largest sample an audio path had to silence in its last block, 0 when nothing tripped and infinity when what tripped it was not a number. Written on the audio thread and cleared by its reader, so the warning is printed on the thread that is allowed to print.
|
| static int | WebGLVariation = 3 |
| | Which @csound/browser variation to create: 0 single threaded, 1 worker with a SharedArrayBuffer, 2 worker with a MessagePort. Anything higher clamps to the last. Read only in a WebGL player, and declared outside the guard so that code setting it compiles on every platform.
|
| const int | DestroyedSentinel = int.MinValue |
| | Returned by PerformKsmps when the instance has already been destroyed. Distinct from 0 (running) and from every positive value (score ended), so that a caller testing > 0 cannot mistake a freed instance for a finished score.
|
| static string | UserOpcodeDir (List< EnvironmentSettings > environmentSettings) |
| | The plugin opcode folder the user asked for in the environment settings, or null when there is none for this platform. Csound takes the folder from the argument of csoundCreate, which wins over OPCODE7DIR64, so a setting that is only exported as an environment variable would be ignored.
|
| static IntPtr | CreateCsound (float sampleRate, int ksmps=0, string opcodeDir=null) |
| | Creates a Csound instance with the setup every path in the package needs: a message buffer, Csound's own audio I/O disabled, and the host's rates. The caller compiles the csd and calls csoundStart.
|
| static IDictionary< string, ChannelInfo > | GetChannelList (IntPtr csoundHandle) |
| | Lists the channels allocated on a raw Csound handle. CsoundWorker.ScanCsdForChannels calls it for the temporary instance it manages, and GetChannelList() for this one.
|
| static string | CharPtr2String (IntPtr pString) |
| | Converts the char* for an ascii "c" string represented by the provided IntPtr into a managed string. Usually used for values returning a const char * from a csound routine. Using this method avoids pInvoke's default automatic attempted deletion of the returned char[] when string is expressly given as a marshalling type.
|