Note that there are some explanatory texts on larger screens.

plurals
  1. POSuppressing Frequencies From FFT
    primarykey
    data
    text
    <p>What I am trying to do is to retrieve the frequencies from some song and suppress all the frequencies that do not appear in the human vocal range or in general any range. Here is my suppress function.</p> <pre><code> public void SupressAndWrite(Func&lt;FrequencyUnit, bool&gt; func) { this.WaveManipulated = true; while (this.mainWave.WAVFile.NumSamplesRemaining &gt; 0) { FrequencyUnit[] freqUnits = this.mainWave.NextFrequencyUnits(); Complex[] compUnits = (from item in freqUnits select (func(item) ? new Complex(item.Frequency, 0) :Complex.Zero)) .ToArray(); FourierTransform.FFT(compUnits, FourierTransform.Direction.Backward); short[] shorts = (from item in compUnits select (short)item.Real).ToArray(); foreach (short item in shorts) { this.ManipulatedFile.AddSample16bit(item); } } this.ManipulatedFile.Close(); } </code></pre> <p>Here is my class for my wave.</p> <pre><code>public sealed class ComplexWave { public readonly WAVFile WAVFile; public readonly Int32 SampleSize; private FourierTransform.Direction fourierDirection { get; set; } private long position; /// &lt;param name="file"&gt;&lt;/param&gt; /// &lt;param name="sampleSize in BLOCKS"&gt;&lt;/param&gt; public ComplexWave(WAVFile file, int sampleSize) { file.NullReferenceExceptionCheck(); this.WAVFile = file; this.SampleSize = sampleSize; if (this.SampleSize % 8 != 0) { if (this.SampleSize % 16 != 0) { throw new ArgumentException("Sample Size"); } } if (!MathTools.IsPowerOf2(sampleSize)) { throw new ArgumentException("Sample Size"); } this.fourierDirection = FourierTransform.Direction.Forward; } public Complex[] NextSampleFourierTransform() { short[] newInput = this.GetNextSample(); Complex[] data = newInput.CopyToComplex(); if (newInput.Any((x) =&gt; x != 0)) { Debug.Write("done"); } FourierTransform.FFT(data, this.fourierDirection); return data; } public FrequencyUnit[] NextFrequencyUnits() { Complex[] cm = this.NextSampleFourierTransform(); FrequencyUnit[] freqUn = new FrequencyUnit[(cm.Length / 2)]; int max = (cm.Length / 2); for (int i = 0; i &lt; max; i++) { freqUn[i] = new FrequencyUnit(cm[i], this.WAVFile.SampleRateHz, i, cm.Length); } Array.Sort(freqUn); return freqUn; } private short[] GetNextSample() { short[] retval = new short[this.SampleSize]; for (int i = 0; i &lt; this.SampleSize; i++) { if (this.WAVFile.NumSamplesRemaining &gt; 0) { retval[i] = this.WAVFile.GetNextSampleAs16Bit(); this.position++; } } return retval; } } </code></pre> <p>Both FFT forward and FFT backwards work correctly. Could you please tell me what my error is.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload