Accord.Audio.Signal.SetSample C# (CSharp) Method

SetSample() public method

Sets the value of the specified sample in the Signal.
public SetSample ( int channel, int position, float value ) : void
channel int The channel's index of the sample to set.
position int The position of the sample to set.
value float A floating-point value ranging from -1 to 1 /// specifying the value to set. Conversion will be done automatically /// to the underlying signal sample format if supported.
return void
        public void SetSample(int channel, int position, float value)
        {
            unsafe
            {
                void* ptr = ptrData.ToPointer();
                int pos = position * Channels + channel;

                switch (format)
                {
                    case SampleFormat.Format32BitIeeeFloat:
                        ((float*)ptr)[pos] = value;
                        break;

                    default:
                        throw new NotSupportedException();
                }
            }
        }