예제 #1
0
        public unsafe void MathSharp()
        {
            var length    = SampleRate;
            var vecLength = SampleRate & ~3;

            var samplePoints   = Constants[0];
            var sampleRate     = Constants[1];
            var sampleIterator = Constants[2];
            var sine           = Constants[3];

            var i = 0;

            fixed(float *ptr = _audioBufferVectorized)
            {
                while (i < vecLength)
                {
                    Vector128 <float> vector = Divide(samplePoints, sampleRate);
                    vector = Multiply(vector, sine);

                    vector = Sin(vector);
                    vector.Store4D(&ptr[i]);

                    i           += 4;
                    samplePoints = Add(samplePoints, sampleIterator);
                }
            }

            while (i < length)
            {
                _audioBufferVectorized[i] = MathF.Sin(Tau * Frequency * ((float)i / SampleRate));
                i++;
            }
        }
예제 #2
0
 public static void Store(this Vector128 <float> vector, out Vector4S destination)
 {
     fixed(void *p = &destination)
     {
         vector.Store4D((float *)p);
     }
 }