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 8662421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:44:04+00:00 2026-06-12T16:44:04+00:00

I’m trying to implement a Discrete Fourier Transformation algorithm for a project I’m doing

  • 0

I’m trying to implement a Discrete Fourier Transformation algorithm for a project I’m doing in school. But creating a class is seeming to be difficult(which it shouldn’t be).
I’m using Visual Studio 2012.

Basically I need a class called Complex to store the two values I get from a DFT; The real portion and the imaginary portion.

This is what I have so far for that:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SoundEditor_V3
{
    public class Complex
    {
        public double real;
        public double im;

        public Complex()
        {
            real = 0;
            im = 0;
        }
    }
}

The problem is that it doesn’t recognize the constructor as a constructor, I’m just learning C#, but I looked it up online and this is how it’s supposed to look.
But it recognizes my constructor as a method.

Why is that?
Am I creating the class wrong?

It’s doing the same thing for my Fourier class as well. So each time I try to create a
Fourier object and then use it’s method…there is no such thing.

example, I do this:

Fourier fou = new Fourier();
fou.DFT(s, N,  amp, 0);

and it tells me fou is a ‘field’ but is used like a ‘type’
why is it saying that?

Here is the code for my Fourier class as well:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SoundEditor_V3
{
   public class Fourier
   {

        //FOURIER
        //N = number of samples
        //s is the array of samples(data)
        //amp is the array where the complex result will be written to
        //start is the where in the array to start
        public void DFT(byte[] s, int N, ref Complex[] amp, int start)
        {
            Complex tem = new Complex();
            int f;
            int t;

            for (f = 0; f < N; f++)
            {

                tem.real = 0;
                tem.im = 0;

                for (t = 0; t < N; t++)
                {
                    tem.real += s[t + start] * Math.Cos(2 * Math.PI * t * f / N);
                    tem.im -= s[t + start] * Math.Sin(2 * Math.PI * t * f / N);

                }
                amp[f].real = tem.real;
                amp[f].im = tem.im;

            }
        }

        //INVERSE FOURIER
        public void IDFT(Complex[] A, ref int[] s)
        {
            int N = A.Length;
            int t, f;
            double result;
            for (t = 0; t < N; t++)
            {
                result = 0;
                for (f = 0; f < N; f++)
                {
                    result += A[f].real * Math.Cos(2 * Math.PI * t * f / N) - A[f].im * Math.Sin(2 * Math.PI * t * f / N);
                }
                s[t] = (int)Math.Round(result);
            }
        }
    }
}

I’m very much stuck at the moment, any and all help would be appreciated. Thank you.

edit:

this is where I’m trying to access all my classes:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SoundEditor_V3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        string filename;
        NAudio.Wave.WaveStream waveStream;

        private NAudio.Wave.DirectSoundOut sout = null;

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {

            OpenFileDialog open = new OpenFileDialog();
            open.Filter = "Wave File (*.wav)|*.wav";
            if (open.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            waveStream = new NAudio.Wave.WaveFileReader(open.FileName);
            filename = open.FileName;
            sout = new NAudio.Wave.DirectSoundOut();
            sout.Init(new NAudio.Wave.WaveChannel32(waveStream));

        }

        //Play
        private void Play_btn_Click(object sender, EventArgs e)
        {
            sout.Play();
        }

        //Stop
        private void Stop_btn_Click(object sender, EventArgs e)
        {
            sout.Stop();
            waveStream.Position = 0;
        }

        //Pause
        private void Pause_btn_Click(object sender, EventArgs e)
        {
            sout.Pause();
        }



        //display fourier
        //N = number of samples(length of array)
        //s is the array of samples(data)
        //amp is the array where the complex result will be written to
        //start is the where in the array to start
        static int N = 8;
        byte[] s = {1,2,3,4,5,6,7,8};


        Complex[] amp = new Complex[N];

        Fourier xfo = new Fourier();



        //xfo.DFT(s, N,  amp, 0); 

    }
}
  • 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-12T16:44:05+00:00Added an answer on June 12, 2026 at 4:44 pm

    Thank you for all your help; I actually ended up figuring everything out.
    I couldn’t access methods in the area I was trying to access them in. I had to put them inside a method block because this was all being coded inside a form.
    That’s my understanding anyway.

    But again, thank you for all your suggestions, they were all helpful.

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

Sidebar

Related Questions

I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms

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.