/// <summary> /// Fill <paramref name="samplesOut"/> with samples from the internal buffer. /// </summary> /// <remarks> /// This method reads the internal buffer starting from the oldest data. /// If the internal buffer is exhausted (underrun), <paramref name="samplesOut"/> /// is padded according to the value of <paramref name="padBehavior"/>. /// /// This method should be called regularly to consume the audio data as it is /// received. Note that the internal buffer can overrun (and some frames can be /// dropped) if this is not called frequently enough. /// </remarks> /// <param name="sampleRate"> /// Desired sample rate. Data in the buffer is resampled if this is different from /// the native track rate. /// </param> /// <param name="numChannels"> /// Desired number of channels. Should be 1 or 2. Data in the buffer is split/averaged /// if this is different from the native track channels number. /// </param> /// <param name="samplesOut"> /// Will be filled with the samples read from the internal buffer. The function will /// try to fill the entire length of the array. /// </param> /// <param name="numSamplesRead"> /// Set to the effective number of samples read. /// This will be generally equal to the length of <paramref name="samplesOut"/>, but can be less in /// case of underrun. /// </param> /// <param name="hasOverrun"> /// Set to <c>true</c> if frames have been dropped from the internal /// buffer between the previous call to <c>Read</c> and this. /// </param> /// <param name="padBehavior">Controls how <paramref name="samplesOut"/> is padded in case of underrun.</param> public void Read(int sampleRate, int numChannels, float[] samplesOut, out int numSamplesRead, out bool hasOverrun, PadBehavior padBehavior = PadBehavior.PadWithZero) { RemoteAudioTrackInterop.AudioTrackReadBuffer_Read(_nativeHandle, sampleRate, numChannels, padBehavior, samplesOut, samplesOut.Length, out numSamplesRead, out mrsBool has_overrun_res); hasOverrun = (bool)has_overrun_res; }
//+++++++Assignment Functions++++++// //attempt to assign this citizen to currentProspect //reverts to its old assignment if that can't be done //BE CAREFUL ABOUT ORDER OF 'IF CHAIN' HERE public void Assign() { Unassign(); if (currentProspect == null) { currentProspect = currentSlot; Utilities.FloatText(transform.position + new Vector3(0, 1, 0), "no assign!", Utilities.TextTypes.Neutral); } if (currentProspect.tag == "WorkStation" && currentProspect.GetComponent <WorkStationBehavior>().IsFull()) { currentProspect = currentSlot; Utilities.FloatText(transform.position + new Vector3(0, 1, 0), "station full!", Utilities.TextTypes.Neutral); } if (currentProspect.tag == "Pad") { PadBehavior currentScript = currentProspect.GetComponent <PadBehavior>(); currentScript.Assign(this.gameObject); SetTaskAttributes(currentScript.primaryEff, currentScript.secondaryEff, currentScript.primaryQual, currentScript.secondaryQual, currentScript.fatigueRate); currentSlot = currentProspect; } else if (currentProspect.tag == "WorkStation") { WorkStationBehavior currentScript = currentProspect.GetComponent <WorkStationBehavior>(); currentScript.Assign(this.gameObject); SetTaskAttributes(currentScript.primaryEff, currentScript.secondaryEff, currentScript.primaryQual, currentScript.secondaryQual, currentScript.fatigueRate); currentSlot = currentProspect; } else { print("ERROR IN CITIZENBEHAVIOR ASSIGN - TAG OF CURRENT PROSPECT NOT HANDLED"); } }
/// <summary> /// Fill <paramref name="samplesOut"/> with samples from the internal buffer. /// See <see cref="Read(int, int, float[], out int, out bool, PadBehavior)"/>. /// </summary> public void Read(int sampleRate, int channels, float[] samplesOut, PadBehavior padBehavior = PadBehavior.PadWithZero) { Read(sampleRate, channels, samplesOut, out int _, out bool _, padBehavior); }