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

  • Home
  • SEARCH
  • 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 4028850
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:16:18+00:00 2026-05-20T11:16:18+00:00

I have an array of int samples ranging from 32766 to -32767. In part

  • 0

I have an array of int samples ranging from 32766 to -32767. In part of trying to create an envelope detector I’ve written a low pass filter, but it doesn’t seem to be doing the job. Please keep in mind I’m trying to filter an entire array in one shot (no buffers).

This is not streamed, but applied to recorded audio for later playback. It is written in C. An example cutoff argument would be 0.5.

void lopass(int *input, float cutoff, int *output) 
{

float sample = 0;

for (int i=1 ; i < (1430529-10); i++) // we will go through all except the last 10 samples 
{
    for (int j = i; j < (i+10); j++) { // only do this for a WINDOW of a hundred samples

        float _in = (float)input[j];
        float _out = (float)output[j-1];

         sample = (cutoff * _in) + (32766 - (32766*cutoff)) * _out;

    }

    output[i] = (int)sample;
}

}

I thought that I would run my filtering statement on a window of 10 samples. Not only is it super slow, but it doesn’t really do much but seemingly lower the overall amplitude. \

If you have any advice, or suggestions (or code!) on how to do this properly, that would be great!

  • 1 1 Answer
  • 1 View
  • 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-05-20T11:16:18+00:00Added an answer on May 20, 2026 at 11:16 am

    A low-pass filter is basically some variant of averaging a number of values together. That means at least in the normal case your inner loop will accumulate a value. It’s hard to guess the exact intent from your code, but you end up with something on the extremely general order of:

    sample = 0;
    for (int j=i; j<i+10; j++)
        sample += input[j];
    output[i] = sample / 10;
    

    As it stands right now, this just does averaging, with no cutoff specified — that means it has a fixed (and fairly slow) cuttoff curve. The cutoff is governed only by the number of samples in the window.

    To control the cutoff, you do not (at least normally) multiply all the input values by the same amount — that would basically just modify the scale factor. Instead, you take a set of samples (10 of them, in your case) of the cutoff curve you want to apply, run them through an inverse FFT, and get a set of 10 coefficients. You then apply those coefficients in your loop:

    sample = 0;
    for (j=0; j<10; j++)
       sample += input[i+j] * coefficients[j];
    output[i] = sample;
    

    The number of samples in your window isn’t normally an input to the design process — rather, it’s an output. You start by specify the cutoff frequency (as a fraction of the sampling frequency) and the cutoff width, and based on those you compute the necessary window size.

    There are quite a few different techniques for computing your coefficients. Regardless of how you compute them, however, you normally end up with something on this general order — accumulate the sum of the samples in the window, each multiplied by its respective coefficient.

    The EE times had a pretty good article on filter design a few years ago.

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

Sidebar

Related Questions

I have an int array containing gray scale values from 0-254, i also have
I have an int array which has no elements and I'm trying to check
I'm trying to get a string in my call from an array. But have
I have an array: int[][] lawn = new int[980][1280]; wich stores the values of
I have an Array like below in PHP array( (int) 0 => array( 'id'
Let us say I have an array int aVar[10]; ... ... for(i=0; i<10; i++)
i have an array like below int[] array = new array[n];// n may be
i have two int array of images , i have implemented it in grid
I have an int array for which i have allocated space for 100 elements.
I have an int[] array. I need to take an int and append it

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.