C# FFT Troubleshooting: Sampling at 44100 Hz, 16384 Samples

  • Context: C# 
  • Thread starter Thread starter btb4198
  • Start date Start date
  • Tags Tags
    Fft
Click For Summary

Discussion Overview

The discussion revolves around troubleshooting issues with a Fast Fourier Transform (FFT) implementation in C#. Participants are examining the accuracy of FFT results when sampling audio data at a rate of 44100 Hz using 16384 samples. The conversation includes comparisons with MATLAB outputs and considerations of data handling techniques.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant reports discrepancies between their FFT results and those obtained from MATLAB, suggesting the need for troubleshooting.
  • Questions arise about the method of comparison with MATLAB, including whether a sine wave or mixed sound source was used.
  • Another participant inquires about windowing the sample data before applying the FFT, referencing the importance of this step.
  • Concerns are raised regarding the nature of the input signal, with suggestions to test with known sine waves to verify the FFT implementation.
  • Participants discuss the potential for under-sampling issues, with one suggesting that the samples might be 8-bit instead of 16-bit or that stereo data is being captured instead of mono.
  • There are mentions of specific frequencies tested and the resulting peaks observed in the FFT output, indicating possible issues with capturing the correct signal.
  • One participant shares code snippets related to how samples are processed and questions the correctness of their frequency calculations.
  • Another participant suggests filtering out noise based on magnitude thresholds, leading to discussions about how to handle small magnitude values in the FFT results.

Areas of Agreement / Disagreement

Participants express varying opinions on the causes of the discrepancies in FFT results, with no consensus reached on the specific issues affecting the accuracy of the output. Multiple competing views regarding the handling of audio data and FFT implementation remain present throughout the discussion.

Contextual Notes

Participants mention the importance of ensuring correct data types (e.g., 16-bit vs. 8-bit samples) and the potential impact of windowing on FFT results. There are unresolved questions about the nature of the input signal and how it affects the FFT output.

Who May Find This Useful

This discussion may be useful for software developers working with audio signal processing, particularly those implementing FFT algorithms in C# or comparing results with established tools like MATLAB.

  • #31
btb4198 said:
however, I am still getting half the Frequencies...
I can just do * by 2 at the very end and get the right Frequencies but I really want to know why it is doing this
Are you looking at stereo information?
 
Technology news on Phys.org
  • #32
I do not know... how can I find out ?
I am using the default microphone on my computer..
what is the different between stereo and mono for a microphone ?
mono is one.. so one mic
so it stereo more that one mic?

how would did affect the input samples ?
 
  • #33
btb4198 said:
I do not know... how can I find out ?
I am using the default microphone on my computer..
what is the different between stereo and mono for a microphone ?
mono is one.. so one mic
so it stereo more that one mic?

how would did affect the input samples ?
I don't know how you are grabbing the information. At some point you must have specified 44100Hz, 16 bits per sample. When you did that, the same data structure should have included whether the signal would be stereo or mono.
 
  • #34
AlephZero
this code:
Code:
    int tempint = 0;
            for (int index = 0; index < 32768; index += 2)
            {

                buffer1[tempint] = ((buffer[index + 1] << 8) |
                                        buffer[index + 0]);
                if (buffer1[tempint] > 32767)
                    buffer1[tempint] = buffer1[tempint] - 65536;
                tempint++;

            }
I am really reading in 44100 bytes at a time from the Microphone and not 32768
I am sending 16384 samples to the FFT because I am 2^N sample for the FFT

anynow so should the code really be
Code:
 int tempint = 0;
            for (int index = 0; index < 32768; index += 2)
            {

                buffer1[tempint] = ((buffer[index + 1] << 8) |
                                        buffer[index + 0]);
                if (buffer1[tempint] > 44100)
                    buffer1[tempint] = buffer1[tempint] - 88200;
                tempint++;
because the Microphone is sending 44100 bytes
I am not sure about this
so i maybe thinking of this all wrong
 

Similar threads

  • · Replies 6 ·
Replies
6
Views
2K
Replies
3
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 12 ·
Replies
12
Views
2K