2
$\begingroup$

Technology: C++, CodeBlocks IDE.

I've just read sample wav file (source - http://www.wavsource.com/snds_2015-12-13_4694675918641206/movies/2001/daisy.wav ) with an txt output (https://paste.ee/p/pXGvm), which i get from using this code:

    WavAnalysis wav_analyse;
    static const uint16_t BUFFER_SIZE = 1024;
    uint8_t* buffer = new uint8_t[BUFFER_SIZE];
    std::cout << "Buffering data... " << std::endl;
    fseek(wavFile, 44, SEEK_SET); // skip header data
    while ((bytesRead = fread(buffer, sizeof buffer[0], BUFFER_SIZE / (sizeof buffer[0]), wavFile)) > 0)
    {
        //do sth with buffer data
        wav_analyse.FFT(buffer); // currently shows data only
    }

Wav file header informations:

  • 1 channel PCM,

  • 8 bits per sample,

  • sampling rate is 11025Hz.

In next step I'm normalising values to the range of [-1;1) with function:

float WavAnalysis::normaliseValuetoFloat(uint8_t value){
    float normalisedValue = (float)value;
    normalisedValue -= 128;
    normalisedValue /= 128;
    return normalisedValue;
}

My goal is to create my own library for voice activity detection, now I'm working on FFT module. I need this data to calculate signal energy and its entropy in chosen signal parts.


updates:

After reading commented sources, I've learned that average and sufficient length of data for feeding FFT algorythm is 1024 (or any other that is equal to power of two).

Question now: FFT changes signal domain from time (real values) to frequency (which contains complex numbers). Why does available sources populates the FFT algorithm with complex array? Ex.: https://stackoverflow.com/questions/10121574/safe-and-fast-fft

$\endgroup$
5
  • $\begingroup$ You should be more specific about your programming environment, after having done your research, with these links: dsp.stackexchange.com/questions/11062/…, dsp.stackexchange.com/questions/19422/… $\endgroup$ Commented Dec 15, 2015 at 20:23
  • $\begingroup$ Also: please clarify what do you mean by "with an txt output". $\endgroup$
    – MBaz
    Commented Dec 15, 2015 at 20:41
  • $\begingroup$ @MBaz, the second linked file is a printout of each 8-bit sample value as ascii. $\endgroup$ Commented Dec 15, 2015 at 22:26
  • $\begingroup$ That isn't likely to work. The data is encoded as integers in offset binary. $\endgroup$
    – MBaz
    Commented Dec 15, 2015 at 23:58
  • $\begingroup$ Also, from your code, you seem to be reading the wav file's header as data. $\endgroup$
    – MBaz
    Commented Dec 16, 2015 at 0:00

1 Answer 1

1
$\begingroup$

Your FFT code initializes a complex array because that is what the Fourier Transform produces. You should understand the complex exponential, and the nature of the transform as a change of basis (i.e. a projection onto a basis of sines & cosines).

It is a big topic that is well travelled, start here: https://stackoverflow.com/questions/10304532/why-does-fft-produce-complex-numbers-instead-of-real-numbers

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.