Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8487655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:18:33+00:00 2026-06-10T21:18:33+00:00

I am trying to do a project in sound processing and need to put

  • 0

I am trying to do a project in sound processing and need to put the frequencies into another domain. Now, I have tried to implement an FFT, that didn’t go well. I tried to understand the z-transform, that didn’t go to well either. I read up and found DFT’s a lot more simple to understand, especially the algorithm. So I coded the algorithm using examples but I do not know or think the output is right. (I don’t have Matlab on here, and cannot find any resources to test it) and wondered if you guys knew if I was going in the right direction. Here is my code so far:

#include <iostream>
#include <complex>
#include <vector>

using namespace std;

const double PI = 3.141592;

vector< complex<double> > DFT(vector< complex<double> >& theData)
{
// Define the Size of the read in vector
const int S = theData.size();

// Initalise new vector with size of S
vector< complex<double> > out(S, 0);
for(unsigned i=0; (i < S); i++)
{
    out[i] = complex<double>(0.0, 0.0);
    for(unsigned j=0; (j < S); j++)
    {
        out[i] += theData[j] * polar<double>(1.0, - 2 * PI * i * j / S);
    }
}

return out;
}

int main(int argc, char *argv[]) {

vector< complex<double> > numbers;

numbers.push_back(102023);
numbers.push_back(102023);
numbers.push_back(102023);
numbers.push_back(102023);

vector< complex<double> > testing = DFT(numbers);

for(unsigned i=0; (i < testing.size()); i++)
{
    cout << testing[i] << endl;

}
}

The inputs are:

102023               102023

102023               102023

And the result:

(408092,       0)

(-0.0666812,  -0.0666812)

(1.30764e-07, -0.133362)

(0.200044,    -0.200043)

Any help or advice would be great, I’m not expecting a lot, but, anything would be great. Thank you 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:18:34+00:00Added an answer on June 10, 2026 at 9:18 pm

    Your code looks okey. out[0] should represent the “DC” component of your input waveform. In your case, it is 4 times bigger than the input waveform, because your normalization coefficient is 1.

    The other coefficients should represent the amplitude and phase of your input waveform. The coefficients are mirrored, i.e., out[i] == out[N-i]. You can test this with the following code:

    double frequency = 1; /* use other values like 2, 3, 4 etc. */
    for (int i = 0; i < 16; i++)
        numbers.push_back(sin((double)i / 16 * frequency * 2 * PI));
    

    For frequency = 1, this gives:

    (6.53592e-07,0)
    (6.53592e-07,-8)
    (6.53592e-07,1.75661e-07)
    (6.53591e-07,2.70728e-07)
    (6.5359e-07,3.75466e-07)
    (6.5359e-07,4.95006e-07)
    (6.53588e-07,6.36767e-07)
    (6.53587e-07,8.12183e-07)
    (6.53584e-07,1.04006e-06)
    (6.53581e-07,1.35364e-06)
    (6.53576e-07,1.81691e-06)
    (6.53568e-07,2.56792e-06)
    (6.53553e-07,3.95615e-06)
    (6.53519e-07,7.1238e-06)
    (6.53402e-07,1.82855e-05)
    (-8.30058e-05,7.99999)
    

    which seems correct to me: negligible DC, amplitude 8 for 1st harmonics, negligible amplitudes for other harmonics.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Android Actionscript project that I am trying to incorporate sound in,
Right now I am trying to solve Project Euler 71 . Consider the fraction,
I'm currently working on a ASP.Net 3.5 project and trying to implement session timeout
I am trying to add a sound library to a GLFW / OpenGL project
I have an existing WCF RIA project built on the Release Candidate; I'm now
I've been trying to create a sound library as a learning project. I get
I am new to PHP and trying to start a PHP Project with sound
I've been working with FFT, and I'm currently trying to get a sound waveform
I am trying to solve Project Euler problem in Clojure using recursion. The following
I'm working on a project and trying to use JavaScript for validating all inputs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.