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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:51:35+00:00 2026-06-15T15:51:35+00:00

I wanted to invoke Spectrum method at the end of the BufferReady method but

  • 0

I wanted to invoke Spectrum method at the end of the BufferReady method but I don’t know why I get error which tells me that I pass wrong arguments to it. Raw is an int.

  void microphone_BufferReady(object sender, EventArgs e) {
                if (buffer.Length <= 0) return;

                // Retrieve audio data
                microphone.GetData(buffer);

                double[] sampleBuffer = new  double[(Utilities.NextPowerOfTwo((uint)buffer.Length))];
                int index = 0;
                for (int i = 0; i < 2048; i += 2) {
                    sampleBuffer[index] = Convert.ToDouble(BitConverter.ToInt16((byte[])buffer, i)); index++;
                }
        //ERROR UNDER
                double[] spectrum = FourierTransform.Spectrum(sampleBuffer, Raw);// I GOT ERROR HERE
            }

    -----------------------

        public static double[] Spectrum(ref double[] x, int method = Raw)
                {
                    //uint pow2Samples = FFT.NextPowerOfTwo((uint)x.Length);
                    double[] xre = new double[x.Length];
                    double[] xim = new double[x.Length];

                    Compute((uint)x.Length, x, null, xre, xim, false);

                    double[] decibel = new double[xre.Length / 2];

                    for (int i = 0; i < decibel.Length; i++)
                        decibel[i] = (method == Decibel) ? 10.0 * Math.Log10((float)(Math.Sqrt((xre[i] * xre[i]) + (xim[i] * xim[i])))) : (float)(Math.Sqrt((xre[i] * xre[i]) + (xim[i] * xim[i])));
                    return decibel;
                }
  • 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-15T15:51:36+00:00Added an answer on June 15, 2026 at 3:51 pm

    Add ref keyword to first parameter of Spectrum method call

    double[] spectrum = FourierTransform.Spectrum(ref sampleBuffer, Raw);
    

    UPDATE ref keyword states, that array should be passed by reference to Spectrum method, and if you will assign new value to x in Spectrum method, then this will assign new value to sampleBuffer variable in microphone_BufferReady method. But as Jon stated in comments, in this particular case ref could be removed from your Spectrum method definition (but also you will have to modify all other calls of that method).

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

Sidebar

Related Questions

I wanted to know that if I am doing correctly, regarding retain and release
Say I wanted to invoke the following url that returns Json through an Ajax
I know there is an invoke function that does the stuff, I am overall
I wanted to invoke a function using the javascript apply() method. This works fine
I'm a newbie to Java, but somewhat familiar to C. I wanted to know
Wanted to know if there was a way one could query shelveset details from
Wanted to know if someone had a suggestion on code or maybe there's a
I wanted to use 6 different textures on a cube, one per side, but
I wanted to know about Data Type implementation in PHP so I need a
I have a closed source unmanaged DLL coded in C++ that I wanted to

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.