CsoundUnity 4.0.0-alpha.3
Loading...
Searching...
No Matches
Csound.Unity.CarrierClip Class Reference

Builds the clip CsoundUnity and CsoundUnityChild put on their AudioSource when the user has not put one there themselves. It carries no audio: it exists so FMOD gives the AudioSource a DSP node, without which OnAudioFilterRead is never called at all, and so that what arrives in that callback is the gain Unity wants applied — volume, mute, distance and the panner's placement, all of it already in those samples. More...

Static Public Member Functions

static AudioClip Build (string name)
 Builds a carrier matching Unity's current output channel count and sample rate.
static AudioClip Build (string name, int channels, int sampleRate)
 Builds a carrier of ones, channels wide. As wide as Unity's output is what the callers pass: a narrower one leaves zeros in the channels it does not cover, and those zero out whatever is written there.

Static Package Functions

static void Fill (AudioClip clip, float value)
 Writes value into every sample of a carrier: 1 to make it the multiplicand the filter needs, 0 to make it silence.

Detailed Description

Builds the clip CsoundUnity and CsoundUnityChild put on their AudioSource when the user has not put one there themselves. It carries no audio: it exists so FMOD gives the AudioSource a DSP node, without which OnAudioFilterRead is never called at all, and so that what arrives in that callback is the gain Unity wants applied — volume, mute, distance and the panner's placement, all of it already in those samples.

Components and samples share the builder. The caller owns the returned clip and is responsible for its lifetime. CsoundUnity's internal lifecycle also uses this helper to silence carriers it owns.

Member Function Documentation

◆ Build() [1/2]

AudioClip Csound.Unity.CarrierClip.Build ( string name)
inlinestatic

Builds a carrier matching Unity's current output channel count and sample rate.

Parameters
nameName of the generated clip.
Returns
A new clip containing 32 frames of ones. Call on the main thread.

◆ Build() [2/2]

AudioClip Csound.Unity.CarrierClip.Build ( string name,
int channels,
int sampleRate )
inlinestatic

Builds a carrier of ones, channels wide. As wide as Unity's output is what the callers pass: a narrower one leaves zeros in the channels it does not cover, and those zero out whatever is written there.

Parameters
nameName of the generated clip.
channelsChannel count of the carrier.
sampleRateSample rate in Hz, normally AudioSettings.outputSampleRate.
Returns
A new, non-streaming clip containing 32 frames of ones. Call on the main thread.

◆ Fill()

void Csound.Unity.CarrierClip.Fill ( AudioClip clip,
float value )
inlinestaticpackage

Writes value into every sample of a carrier: 1 to make it the multiplicand the filter needs, 0 to make it silence.

Zeroing it is what makes the silence hold by construction rather than by covering every route. Pausing controls one of them, and anything that calls Play on the source takes it back — playOnAwake after the AudioSource component is toggled, a pooling system recycling the object, a test harness. Measured: with the component disabled and the carrier re-played by hand, the output went to |dc|/rms 1.00. A carrier of zeros has nothing to hand out, whoever plays it.

The clip is 32 frames, so the loop turns over in well under a millisecond and the change is heard at once. The audio thread may read these samples while this writes them, which is benign: the worst it can see is one block part ones and part zeros, at a boundary that is already a step.


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