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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:17:32+00:00 2026-06-01T10:17:32+00:00

I’d like to build a small Python program that can listen to and analyze

  • 0

I’d like to build a small Python program that can listen to and analyze currently playing audio on a computer, for example, from any media player.

I know that this is possible with DirectShow on Windows, but I’m not sure how to use it from Python. However, I’d ideally like a cross-platform way that does not use DirectX.

  • 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-01T10:17:33+00:00Added an answer on June 1, 2026 at 10:17 am

    In general, to “listen to something” from your sound card you are going to have to use some audio toolkit / module and usually, you will end up setting up a record-process-play routine (you can ommit play of course)

    If your application is not a hard real-time one (i.e. you can afford to miss a few samples from the input) you could start off with PyAudio’s “Record a few seconds of audio and save it to a file” example from their website.
    So in your case, you would:

    1. Record a buffer
    2. Process it
    3. If the terminating condition is not satisfied, Go back to (1).

    But, in this case,
    (You may have noticed) You would be missing samples from the input while you are doing the processing because during that time, you are not recording anything.
    Depending on your application, you could get away with that…This is especially true for PyAudio because for the moment it only supports blocking-mode so if you want real-time (ish) operation you would have to use threads.

    If your real-time specifications are more strict (i.e. you can’t afford to lose even a few samples from your input) you would still use the “record-process-[play]” routine but this time you would need to do it in a Thread and have it communicating with your main process through a LIFO stack (Last In First Out or Deque).

    It would go something like this:

    Recording Thread:

    1. Record a buffer
    2. Push the data on the Deque
    3. Repeat from (1)

    Main Process:

    1. If the Deque has buffers then
      1. Pull a buffer from the Deque
      2. Process it
    2. Repeat from (1)

    In this way, your processing can go on at its own pace while the recording thread keeps filling up buffers and pushing them on the Deque.

    The good news in the case of Python is that the Deque is thread safe, so you will not have any sync problems when your main process and thread try to access the Deque simultaneously.

    Again,
    Depending on your application you might also need to move towards faster hardware such as those that are based on the ASIO protocol.

    Eventually,
    You will also need to modify your processing algorithms a little bit to take into account that you are now working with frames instead of one buffer…Therefore, to keep things smooth you would have to save the state of your operations from one frame to the next. For more information you can see the “overlap-add” method

    All the best

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

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I would like to run a str_replace or preg_replace which looks for certain words

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.