Ejemplo n.º 1
0
 public static void Process(double[] data, IEqualizer eq, uint sampleRate)
 {
     wave_lib2.FFT2 f = new FFT2(data.Length / 2);
     f.transform(data, false);
     int j;
     uint l_freq = 0xFFFFFFFF;
     double _amp = 0;
     uint tmp = 0;
     for (j = 0; j < (int)(data.Length / 2); j++)
     {
         tmp = (uint)(((double)j) / data.Length * sampleRate);
         if (tmp != l_freq)
         {
             l_freq = tmp;
             _amp = eq.GetPoint(tmp);
         }
         data[j] *= _amp;// eq.GetPoint();
     }
     for (j = data.Length / 2; j < data.Length; j++)
     {
         data[j] = 0.0;
     }
     double mult = 1;
     // multiply transforms to get convolution
     for (j = 0; j != data.Length; j += 2)
     {
         double a = data[j] - data[j + 1];
         double b = data[j] + data[j + 1];
         data[j] = a * mult;
         data[j + 1] = b * mult;
         //mult += 0.001;
     }
     f.transform(data, true);
 }
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            PointCollection points = new PointCollection();

            if ((values.Length != 4) || (parameter == DependencyProperty.UnsetValue) ||
                (values[0] == null) || (values[0] == DependencyProperty.UnsetValue) ||
                (values[1] == null) || (values[1] == DependencyProperty.UnsetValue) || //HACK DarthAffe 13.08.2017: I need this only to update the binding
                (values[2] == null) || (values[2] == DependencyProperty.UnsetValue) ||
                (values[3] == null) || (values[3] == DependencyProperty.UnsetValue))
            {
                return(points);
            }

            IEqualizer equalizer  = (IEqualizer)values[0];
            double     width      = (double)values[2];
            double     height     = (double)values[3];
            int        valueCount = int.Parse(parameter.ToString());
            double     halfHeight = height / 2.0;

            List <(float offset, float value)> pointValues = equalizer.Bands.Select(b => (b.Offset, b.Value)).ToList();

            float[] calculatedValues = equalizer.CalculateValues(valueCount);
            for (int i = 0; i < calculatedValues.Length; i++)
            {
                pointValues.Add(((float)i / calculatedValues.Length, calculatedValues[i]));
            }

            foreach ((float offset, float value) in pointValues.OrderBy(x => x.offset))
            {
                points.Add(new Point(offset * width, GetPosY(value, halfHeight)));
            }

            return(points);
        }
        public void SaveFrom(IEqualizer equalizer)
        {
            IsEnabled = equalizer.IsEnabled;

            Bands.Clear();
            foreach (EqualizerBand band in equalizer.Bands)
            {
                Bands.Add(new EqualizerBand(band.Offset, band.Value, band.IsFixedOffset));
            }
        }
Ejemplo n.º 4
0
            public stream_cb(int buf_size)
            {
                _eq = new lowpass_eq();
                d   = this.cb;

                /*eq = WaveOut.create_equalizer(channels, sampleRate, bitsPerSample, buf_size);
                 * WaveOut.equalizer_set_freq(eq, 0, 0.5F);
                 * WaveOut.equalizer_set_freq(eq, 1, 0.5F);
                 * WaveOut.equalizer_set_freq(eq, 2, 0.5F);
                 * WaveOut.equalizer_set_freq(eq, 3, 0.5F);
                 * WaveOut.equalizer_set_freq(eq, 4, 0.5F);
                 * WaveOut.equalizer_set_freq(eq, 5, 0.2F);
                 * WaveOut.equalizer_set_freq(eq, 6, 0F);
                 * WaveOut.equalizer_set_freq(eq, 7, -0.2F);
                 * WaveOut.equalizer_set_freq(eq, 8, -0.2F);
                 * WaveOut.equalizer_set_freq(eq, 9, -0.5F);
                 * WaveOut.equalizer_set_freq(eq, 10, -0.5F);
                 * WaveOut.equalizer_set_freq(eq, 11, -0.5F);*/
            }
        public void LoadInto(IEqualizer equalizer)
        {
            equalizer.IsEnabled = IsEnabled;

            foreach (EqualizerBand band in Bands)
            {
                if (band.IsFixedOffset)
                {
                    EqualizerBand bandToUpdate = equalizer.Bands.FirstOrDefault(b => b.IsFixedOffset && (Math.Abs(b.Offset - band.Offset) < 0.01));
                    if (bandToUpdate != null)
                    {
                        bandToUpdate.Value = band.Value;
                    }
                }
                else
                {
                    equalizer.AddBand(band.Offset, band.Value);
                }
            }
        }
Ejemplo n.º 6
0
        public static void GetNoise(double[] data, IEqualizer eq, uint sampleRate)
        {
            wave_lib2.FFT2 f = new FFT2(data.Length / 2);
            //f.transform(data, false);
            int    j;
            uint   l_freq = 0xFFFFFFFF;
            double _amp   = 0;
            uint   tmp    = 0;

            for (j = 0; j < (int)(data.Length / 2); j++)
            {
                tmp = (uint)(((double)j) / data.Length * sampleRate);
                if (tmp != l_freq)
                {
                    l_freq = tmp;
                    _amp   = eq.GetPoint(tmp);
                }
                data[j] = _amp;                // eq.GetPoint();
            }
            for (j = data.Length / 2; j < data.Length; j++)
            {
                data[j] = 0.0;
            }
            double mult = 1;

            // multiply transforms to get convolution
            for (j = 0; j != data.Length; j += 2)
            {
                double a = data[j] - data[j + 1];
                double b = data[j] + data[j + 1];
                data[j]     = a * mult;
                data[j + 1] = b * mult;
                //mult += 0.001;
            }
            f.transform(data, true);
        }
Ejemplo n.º 7
0
 public stream_cb(int buf_size)
 {
     _eq = new lowpass_eq ();
     d = this.cb;
     /*eq = WaveOut.create_equalizer(channels, sampleRate, bitsPerSample, buf_size);
     WaveOut.equalizer_set_freq(eq, 0, 0.5F);
     WaveOut.equalizer_set_freq(eq, 1, 0.5F);
     WaveOut.equalizer_set_freq(eq, 2, 0.5F);
     WaveOut.equalizer_set_freq(eq, 3, 0.5F);
     WaveOut.equalizer_set_freq(eq, 4, 0.5F);
     WaveOut.equalizer_set_freq(eq, 5, 0.2F);
     WaveOut.equalizer_set_freq(eq, 6, 0F);
     WaveOut.equalizer_set_freq(eq, 7, -0.2F);
     WaveOut.equalizer_set_freq(eq, 8, -0.2F);
     WaveOut.equalizer_set_freq(eq, 9, -0.5F);
     WaveOut.equalizer_set_freq(eq, 10, -0.5F);
     WaveOut.equalizer_set_freq(eq, 11, -0.5F);*/
 }