Exemplo n.º 1
0
 public boolean validFreq(float f) {
   if (f < 60) {
     Minim.error("This filter quickly becomes unstable below 60 Hz, setting frequency to 60 Hz.");
     return false;
   }
   return true;
 }
Exemplo n.º 2
0
 /**
  * Performs a forward transform on the passed buffers.
  *
  * @param buffReal the real part of the time domain signal to transform
  * @param buffImag the imaginary part of the time domain signal to transform
  */
 public void forward(float[] buffReal, float[] buffImag) {
   if (buffReal.length != timeSize || buffImag.length != timeSize) {
     Minim.error("FFT.forward: The length of the passed buffers must be equal to timeSize().");
     return;
   }
   setComplex(buffReal, buffImag);
   bitReverseComplex();
   fft();
   fillSpectrum();
 }
Exemplo n.º 3
0
 @Override
 public void forward(float[] buffer) {
   if (buffer.length != timeSize) {
     Minim.error(
         "FFT.forward: The length of the passed sample buffer " + "must be equal to timeSize().");
     return;
   }
   doWindow(buffer);
   // copy samples to real/imag in bit-reversed order
   bitReverseSamples(buffer);
   // perform the fft
   fft();
   // fill the spectrum buffer with amplitudes
   fillSpectrum();
 }
Exemplo n.º 4
0
 @Override
 public void inverse(float[] buffer) {
   if (buffer.length > real.length) {
     Minim.error("FFT.inverse: the passed array's length must equal FFT.timeSize().");
     return;
   }
   // conjugate
   for (int i = 0; i < timeSize; i++) {
     imag[i] *= -1;
   }
   bitReverseComplex();
   fft();
   // copy the result in real into buffer, scaling as we do
   for (int i = 0; i < buffer.length; i++) {
     buffer[i] = real[i] / real.length;
   }
 }
Exemplo n.º 5
0
 @Override
 public void scaleBand(int i, float s) {
   if (s < 0) {
     Minim.error("Can't scale a frequency band by a negative value.");
     return;
   }
   if (spectrum[i] != 0) {
     real[i] /= spectrum[i];
     imag[i] /= spectrum[i];
     spectrum[i] *= s;
     real[i] *= spectrum[i];
     imag[i] *= spectrum[i];
   }
   if (i != 0 && i != timeSize / 2) {
     real[timeSize - i] = real[i];
     imag[timeSize - i] = -imag[i];
   }
 }
Exemplo n.º 6
0
 @Override
 public void setBand(int i, float a) {
   if (a < 0) {
     Minim.error("Can't set a frequency band to a negative value.");
     return;
   }
   if (real[i] == 0 && imag[i] == 0) {
     real[i] = a;
     spectrum[i] = a;
   } else {
     real[i] /= spectrum[i];
     imag[i] /= spectrum[i];
     spectrum[i] = a;
     real[i] *= spectrum[i];
     imag[i] *= spectrum[i];
   }
   if (i != 0 && i != timeSize / 2) {
     real[timeSize - i] = real[i];
     imag[timeSize - i] = -imag[i];
   }
 }