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
SUMMARY

The discussion centers on troubleshooting Fast Fourier Transform (FFT) implementation in C# at a sampling rate of 44100 Hz with 16384 samples. The user compares their FFT results with MATLAB, noting discrepancies in frequency peaks, particularly with a sine wave input. Key issues identified include the lack of windowing before FFT, potential under-sampling, and incorrect handling of signed 16-bit audio data. The conversation emphasizes the importance of verifying microphone input and suggests testing with known sine wave signals to validate the FFT implementation.

PREREQUISITES
  • C# programming proficiency
  • Understanding of Fast Fourier Transform (FFT) algorithms
  • Knowledge of audio sampling rates and formats (e.g., 44100 Hz, 16-bit signed integers)
  • Familiarity with windowing functions in signal processing
NEXT STEPS
  • Implement windowing techniques before FFT to reduce spectral leakage
  • Test FFT with known sine wave signals using the sin() function
  • Investigate audio input settings to ensure correct sampling format (mono vs. stereo)
  • Explore the effects of different buffer sizes on FFT accuracy
USEFUL FOR

Software developers working with audio signal processing, data scientists analyzing frequency data, and engineers implementing FFT in C# applications.

  • #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
2K
  • · 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