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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:04:46+00:00 2026-06-08T19:04:46+00:00

I need to detect silence in PCM audio stream with IMediaSample. Signal is provided

  • 0

I need to detect silence in PCM audio stream with IMediaSample. Signal is provided by TV and is connected with PC by optic cable to Prodigy 7.1 HiFi soundcard. So far I have this:

bool detectSound(IMediaSample *pSamples)
{
    BYTE *pData;
    pSamples->GetPointer(&pData);
    long size = pSamples->GetActualDataLength();

    long nulls = 0;
    for(long i = 0; i < size; ++i) {
        if(pData[i] == 0)
            ++nulls;
    }

    /* 0.9 to eliminate interference */
    long max_nulls = (long) (0.9 * size);
    if(nulls > max_nulls) {                 /* STOP */
        /* no audio */
        return false;
    }
    else {
        /* audio available */
        return true;
    }
}

The problem is that if I put breakpoint at line marked “STOP”, nulls has nearly always the same value and is smaller than max_nulls no matter if I mute TV or not. I noticed that pData[i] values are always 0 or 255. (strange, or not?)

Probably I don’t understand what exactly this “data” is and how to interpret it. All I’m sure of is that if there is no audio than all sampled values from waveform should be almost 0.

Could you verify my way of thinking? Thanks in advance.

eclipse

edit:

The problem is somewhere around drivers and AC3 Filter settings, because in “SPDIF Test” I got that 44.1 kHz, 48 kHz and 32 kHz are not supported by DirectSound. Roman’s idea is just right and will work when I fix this.

  • 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-08T19:04:48+00:00Added an answer on June 8, 2026 at 7:04 pm

    The better way is to find out what PCM data is, and the answer to the posted question is going to be trivial.

    The quicker way is:

    • treat those audio data bytes as SHORT values (you did not mention, but I suppose your audio is 16 bit)
    • it would be better to split into channels and process separately
    • calculate standard deviation
    • silence is when/if the calculated value is under certain small thresold
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to detect whether the Android device is connected or disconnected to the
I need to detect a post_remove signal, so I have written : def handler1(sender,
I need to detect all the red pixels in an image using Java. What
I need to detect IE7 (and IE6) using the user agent string: I have
I need to detect android device orientation change without playing manually with sensor data,
I need to detect which version of SQL I am dealing with to perorm
I need to detect and eval the Javascript code contained in a string. The
I need to detect character encoding in HTTP responses. To do this I look
I need to detect information about the Application Server my EJBs are running in.
I need to detect if a request cookie - value is different from a

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.