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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:52:39+00:00 2026-05-17T16:52:39+00:00

I wrote a little Python script which uses an Adder plugin to mix two

  • 0

I wrote a little Python script which uses an Adder plugin to mix two source streams together.

After starting the program, you hear a 1kHz tone generated by the audiotestsrc plugin. When you press Enter, an another 500Hz test tone is connected to the Adder so you hear them together. (By the way, i don’t really get why should i set the pipeline again to playing state here to hear the mix. Is there any way i can plug in new sources without having to restart the pipeline?)

When you press Enter once again, the 1kHz tone should be removed from the mix and the 500Hz tone should keep playing, but instead i hear nothing anymore. I get a pulse pulsesink.c:528:gst_pulsering_stream_underflow_cb:<pulseaudio_output> Got underflow in the debug output as the last line. I don’t really know what to try next.

Here is the full source code:

#!/usr/bin/python
# On-the-go source removal doesn't work this way with GStreamer. Why?

import gobject;
gobject.threads_init()
import gst;

if __name__ == "__main__":
    pipe = gst.Pipeline("mypipe")

    adder = gst.element_factory_make("adder","audiomixer")
    pipe.add(adder)

    buzzer = gst.element_factory_make("audiotestsrc","buzzer")
    buzzer.set_property("freq",1000)
    pipe.add(buzzer)

    pulse = gst.element_factory_make("pulsesink", "pulseaudio_output")
    pipe.add(pulse)

    buzzer.link(adder)
    adder.link(pulse)
    pipe.set_state(gst.STATE_PLAYING)

    raw_input("1kHz test sound. Press <ENTER> to continue.")

    buzzer2=gst.element_factory_make("audiotestsrc","buzzer2")
    buzzer2.set_property("freq",500)

    pipe.add(buzzer2)
    buzzer2.link(adder)
    pipe.set_state(gst.STATE_PLAYING)

    raw_input("1kHz + 500Hz test sound playing simoultenously. Press <ENTER> to continue.")

    buzzer.unlink(adder)
    pipe.set_state(gst.STATE_PLAYING)

    raw_input("Only 500Hz test sound. Press <ENTER> to stop.")
  • 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-17T16:52:40+00:00Added an answer on May 17, 2026 at 4:52 pm

    I’ve found the solution on my own. I had to use request pads with Adder and use the pad blocking capability of GStreamer.

    Here’s the working source code with some descriptions:

    #!/usr/bin/python
    
    import gobject;
    gobject.threads_init()
    import gst;
    
    if __name__ == "__main__":
        # First create our pipeline
        pipe = gst.Pipeline("mypipe")
    
        # Create a software mixer with "Adder"
        adder = gst.element_factory_make("adder","audiomixer")
        pipe.add(adder)
    
        # Gather a request sink pad on the mixer
        sinkpad1=adder.get_request_pad("sink%d")
    
        # Create the first buzzer..
        buzzer1 = gst.element_factory_make("audiotestsrc","buzzer1")
        buzzer1.set_property("freq",1000)
        pipe.add(buzzer1)
        # .. and connect it's source pad to the previously gathered request pad
        buzzersrc1=buzzer1.get_pad("src")
        buzzersrc1.link(sinkpad1)
    
        # Add some output
        output = gst.element_factory_make("autoaudiosink", "audio_out")
        pipe.add(output)
        adder.link(output)
    
        # Start the playback
        pipe.set_state(gst.STATE_PLAYING)
    
        raw_input("1kHz test sound. Press <ENTER> to continue.")
    
        # Get an another request sink pad on the mixer
        sinkpad2=adder.get_request_pad("sink%d")
    
        # Create an another buzzer and connect it the same way
        buzzer2 = gst.element_factory_make("audiotestsrc","buzzer2")
        buzzer2.set_property("freq",500)
        pipe.add(buzzer2)
    
        buzzersrc2=buzzer2.get_pad("src")
        buzzersrc2.link(sinkpad2)
    
        # Start the second buzzer (other ways streaming stops because of starvation)
        buzzer2.set_state(gst.STATE_PLAYING)
    
        raw_input("1kHz + 500Hz test sound playing simoultenously. Press <ENTER> to continue.")
    
        # Before removing a source, we must use pad blocking to prevent state changes
        buzzersrc1.set_blocked(True)
        # Stop the first buzzer
        buzzer1.set_state(gst.STATE_NULL)
        # Unlink from the mixer
        buzzersrc1.unlink(sinkpad1)
        # Release the mixers first sink pad
        adder.release_request_pad(sinkpad1)
        # Because here none of the Adder's sink pads block, streaming continues
    
        raw_input("Only 500Hz test sound. Press <ENTER> to stop.")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a little Python script wrapcl.py script which wraps our compiler binary (
So I wrote a little script in python that brings up a gui with
I am still learning Python and as a little Project I wrote a script
I wrote a little python script to accept BitBucket POST callbacks of repository changes
I've recently started learning Python and wrote a little script that informs me when
I have a little script I wrote in python and it actually works on
i wrote a little addin, which does some formatting of my C# code. in
i wrote a little test programm which queries the status servlet of a tomcat
I wrote a little search script for a client, it works and words get
Was looking to write a little web crawler in python. I was starting to

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.