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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:51:12+00:00 2026-05-16T07:51:12+00:00

I have information (20,000 frames of data) about an audio track that I have

  • 0

I have information (20,000 frames of data) about an audio track that I have auto-correlated using:

[r,lags] = xcorr(XX,XX,'biased');

And it looks like this:

alt text

Which hopefully is so far so good. Ideally I would like to be able to take the frame number that corresponds to the highest part of the second peak. I’ve read around and tried a load of different methods but I just can’t seem to get it to retrieve the information for me.

Would anybody be able to shed some light on what I have to do?

Many thanks!


edit1:
I have tried using findpeaks, but it doesn’t seem to work for me. I’m not sure if that’s because I’m using the wrong data or not.

edit2: I’m currently testing a method to use on just this audio track, but soon I want to expand it so that I can perform this method on a whole directory of files, so I kind of need a script that can detect peaks rather than finding the information myself.

edit3: My .M file:

[y, fs, nb] = wavread('Three.wav');                 %# Load the signal into variable y

frameWidth = 441;                                   %# 10ms
numSamples = length(y);                             %# Number of samples in y
numFrames = floor(numSamples/frameWidth);           %# Number of full frames in y
energy = zeros(1,numFrames);                        %# Initialize energy
startSample = zeros(1,numFrames);                   %# Initialize start indices
endSample = zeros(1,numFrames);                     %# Initialize end indices

for frame = 1:numFrames                             %# Loop over frames
  startSample(frame) = (frame-1)*frameWidth+1;      %# Starting index of frame
  endSample(frame) = frame*frameWidth;              %# Ending index of frame
  frameIndex = startSample(frame):endSample(frame); %# Indices of frame samples
  energy(frame) = sum(y(frameIndex).^2);            %# Calculate frame energy
end                                                 %# End loop

XX = filtfilt(ones(1,10)/10, 1, energy);            %# Smooths signal

[r,lags] = xcorr(XX,XX,'biased');                   %# Auto-correlates the data
plot(lags,r), xlabel('lag'), ylabel('xcorr')        %# Plots data
  • 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-05-16T07:51:13+00:00Added an answer on May 16, 2026 at 7:51 am

    EDIT:

    %# load the signal
    [y, fs, nb] = wavread('Three.wav');
    y = mean(y,2);                               %# stereo, take avrg of 2 channels
    
    %# Calculate frame energy
    fWidth = round(fs*10e-3);                    %# 10ms
    numFrames = floor(length(y)/fWidth);
    energy = zeros(1,numFrames);
    for f=1:numFrames
      energy(f) = sum( y((f-1)*fWidth+1:f*fWidth).^2 );
    end
    
    %# smooth the signal (moving average with window size = 1% * length of data)
    WINDOW_SIZE = round(length(energy) * 0.01);  %# 200
    XX = filtfilt(ones(1,WINDOW_SIZE)/WINDOW_SIZE, 1, energy);
    
    %# auto-correlation
    [r,lags] = xcorr(XX, 'biased');
    
    %# find extrema points
    dr = diff(r);
    eIdx = find(dr(1:end-1) .* dr(2:end) <= 0) + 1;
    
    [~,loc] = sort(r(eIdx), 'descend');
    loc = loc(1:min(3,end));                     %# take the highest 3 values
    
    %# plot
    plot(lags,r), hold on
    plot(lags(eIdx), r(eIdx), 'g*')
    plot(lags(eIdx(loc)), r(eIdx(loc)), 'ro')
    hold off, xlabel('lag'), ylabel('xcorr')
    

    alt text

    and the lag values corresponding to the marked peaks:

    >> lags( eIdx(loc) )
    ans =
               0       -6316        6316
    

    Note that we smoothed the signal prior to computing the derivative of the autocorrelation function in order to find the extrema points

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

Sidebar

Related Questions

So I have a table of data that is 10,000 lines long. Several of
I have about 150 000 rows of data written to a database everyday. These
I have to generate roughly 18,000 PDFs that contain sensitive information. The PDFs will
If I have 50,000-100,000 product skus with accompanying information, including specifications and descriptions, that
I have a form that users use to input information about a posting. When
I have a database containing about 300,000 rows of product information. I need to
I am using Bing Maps with Ajax and I have about 80,000 locations to
I have information stored in a database that I want to use to create
I have some information in my database like 'author', 'book' etc., that are all
I have a table where I keep information about financial returns. The columns includes

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.