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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:25:11+00:00 2026-06-06T14:25:11+00:00

I’m tying to implement a basic audio delay – but all I’m getting is

  • 0

I’m tying to implement a basic audio delay – but all I’m getting is garbage, probably something very obvious – but I can’t seem to spot it…

Audio is processed via buffers that are determined at runtime.

I think I’m doing something horribly wrong with the pointers, tried looking at some other code – but they all seem “incomplete” always something rudimentary is missing – probably what’s miss in my code as well.

// Process audio
// 1
void Gain::subProcessSimpleDelay( int bufferOffset, int sampleFrames )
{
    // Assign pointers to your in/output buffers. 
    // Each buffer is an array of float samples.
    float* in1  = bufferOffset + pinInput1.getBuffer();
    float* in2  = bufferOffset + pinInput2.getBuffer();
    float* out1 = bufferOffset + pinOutput1.getBuffer();

    // SampleFrames = how many samples to process (can vary). 
    // Repeat (loop) that many times
    for( int s = sampleFrames; s > 0; --s ) 
    {
        // get the sample 'POINTED TO' by in1.
        float input1 = *in1;    

        float feedback = *in2;
        float output;
        unsigned short int p, r;
        unsigned short int len;
        len =  600;

        // check at delay length calculation
        if (len > 65535) 
            len = 65535; 
        // otherwise, a length of 0 will output the input from 
        // 65536 samples ago
        else if (len < 1) 
            len = 1; 

        r = p - len; // loop
        output = buffer[r];
        buffer[p] = input1 + output * feedback;
        p++;

        *out1 = output;

        // store the result in the output buffer.
        // increment the pointers (move to next sample in buffers).
        in1++;
        in2++;
        out1++;
    }
}

Could anyone tell me what’s wrong?

  • 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-06T14:25:13+00:00Added an answer on June 6, 2026 at 2:25 pm

    You haven’t initialized p. Other things to be careful of in this code:-

    • Are you sure that sampleFrames + bufferOffset is less than the size of your input and output buffers? You could really do with a way to check that.
    • It’s not clear where buffer comes from, or what else might be writing to it. If it’s garbage before your code runs, you’re going to end up with garbage everywhere, because the first thing you do is read from it.
    • You don’t say what types pinInput1.getBuffer() etc. return. If they return a char*, and you just know that it happens to point to an array of floats, you need to cast the result to float* before you do any pointer arithmetic, to make sure you’re advancing to the next float in the array, not the next byte of the array.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
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 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
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from
I want to construct a data frame in an Rcpp function, but when I
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am trying to understand how to use SyndicationItem to display feed which is

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.