Esempio n. 1
0
 public float[] map(final float[] data) {
   final float[] out = new float[data.length * upFactor / downFactor];
   for (int i = 0; i < data.length; i++) {
     final float sample = data[i];
     for (int j = 0; j < upFactor; j++) {
       final Filters.FIRFilter filter = filters[j];
       filter.addToDelayLine(sample);
       final int upsampledIndex = i * upFactor + j;
       if (upsampledIndex % downFactor == 0) {
         out[upsampledIndex / downFactor] = (float) filter.filter();
       }
     }
   }
   return out;
 }
Esempio n. 2
0
 public float[] map(final float[] data) {
   final int outLength = data.length * factor;
   if (out == null || out.length != outLength) {
     out = new float[outLength];
   } else {
     Arrays.fill(out, 0);
   }
   for (int i = 0; i < data.length; i++) {
     final float sample = data[i];
     for (int j = 0; j < factor; j++) {
       final Filters.FIRFilter filter = filters[j];
       filter.addToDelayLine(sample);
       out[i * factor + j] = (float) filter.filter();
     }
   }
   return out;
 }
Esempio n. 3
0
 /**
  * Creates a decimator with the given FIR (low pass) filter.
  *
  * @param filter FIR filter
  * @param factor nth frame to keep (factor)
  */
 public Decimator(final Filters.FIRFilter filter, final int factor) {
   super(filter.getCoefficients());
   this.factor = factor;
 }
Esempio n. 4
0
 @Override
 public void reset() {
   super.reset();
   pos = 0;
 }
Esempio n. 5
0
 /**
  * Creates a resampler using a FIR low pass filter and the given up- and down-sample factors.
  * The filter must be appropriate for the given factors. Internally the up- and down-factors are
  * divided by their greatest common divisor to increase efficiency.
  *
  * @param filter FIR filter
  * @param upFactor upsample factor
  * @param downFactor downsample factor
  */
 public Resampler(final Filters.FIRFilter filter, final int upFactor, final int downFactor) {
   this(filter.getCoefficients(), upFactor, downFactor);
 }
Esempio n. 6
0
 /**
  * Creates an interpolator with the given FIR filter for filtering after upsampling to avoid
  * aliasing. It's recommended to use a filter with a multiple of the upsample factor as the
  * number of coefficients (taps). If that's not the case, zeros are added to the filter's
  * coefficients.
  *
  * @param filter FIR filter
  * @param factor upsample factor
  */
 public Interpolator(final Filters.FIRFilter filter, final int factor) {
   this(filter.getCoefficients(), factor);
 }