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

GetSample() public method

Gets the value of the specified sample in the Signal.
public GetSample ( int channel, int position ) : float
channel int The channel's index of the sample to set.
position int The position of the sample to set.
return float
        public float GetSample(int channel, int position)
        {
            float sample;

            unsafe
            {
                void* ptr = ptrData.ToPointer();
                int pos = position * Channels + channel;

                switch (format)
                {
                    case SampleFormat.Format32BitIeeeFloat:
                        sample = ((float*)ptr)[pos];
                        break;
                    default:
                        throw new NotSupportedException();
                }
            }

            return sample;
        }