Clicking sound during start and stop of audio playback RRS feed

  • Question

  • On both RPi2 and RPi3 there is a noticeable click at the beginning and ending of every audio file playback using MediaElement. Is there a way to fix the audio playback?

                var synth = new SpeechSynthesizer();
                string text = "This is " + synth.Voice.DisplayName;
                SpeechSynthesisStream stream = await synth.SynthesizeTextToStreamAsync(text);
                _mediaElementObject.SetSource(stream, stream.ContentType);

    Monday, June 20, 2016 3:47 PM

All replies

  • Hi Mark,

    Could this be related to the speakers themselves? Do they "Click" if used at the same audio settings with this code from your desktop machine?



    Tuesday, June 21, 2016 5:09 PM
  • I haven't tried them on the actual external speakers. But when using the same code on my laptop with its internal speakers, there are no clicking sounds. I've worked with MediaFoundation and filter graphs in another project (using windows 8 XAML app, not related to UWP) and it seems to me that the clicking has something to do with the hardware output driver or some other filter graph when opening and closing the pins (filter graph pins, not gpio pins).

    Tuesday, June 21, 2016 7:24 PM
  • Hi Mark,

    I have asked a member of the IoT Team to take a look. Is there anything unique about your setup that we would need to know to experience this issue?

    NOTE: I have played with a number of different speakers over the years and some are more sensitive to gain changes (volume setting) than others. I would suggest making sure that these speakers are indeed shielded and not set to near either end of their gain range.



    Tuesday, June 21, 2016 7:39 PM
  • Hi IoTGirl,

    Nothing. I'm using common off the shelf amplified desktop speakers with a standard 3.5mm audio jack connected to the 3.5mm AV port on the RPi. BTW, I also hear the click if I use headphones. I'm using RPi 2. You should be able to hear the clicking. New Windows UPS app. Add MediaElement to the main page and give it a x:Name="_mediaElement". Add abutton and wire up the click event with the sample code above. It's that simple.


    Wednesday, June 22, 2016 12:53 AM
  • In my UWP app I have a <MediaPlayerElement />

    In the code I play a video from within the app like this...

    Uri pathUri = new Uri("ms-appx:///Videos/Sleep_mpeg4.avi");
    mediaPlayer.Source = MediaSource.CreateFromUri(pathUri);

    When the video starts to play it emits an audio POP and when it stops playing it emits an audio POP.

    Even when you mute or turn the volume down with...

    mediaPlayer.MediaPlayer.IsMuted = true;

    I tried the VideoPlayer Sample from the UWP Samples pack and the same problem arises.

    This behaviour happens on RPi3 and DragonBoard 410c.

    On the DragonBoard 410c I have added a headphone socket and audio therefore doesn't go through HDMI and cause video jitter - so at least that makes me happy :o)

    On the RPi3 I lived with the software rendering video jitter just to test for the pops.

    On my desktop windows 10 pc - the videos play with NO POP.

    Anyone else had this problem? Have you solved it? Help me :)

    Wednesday, October 5, 2016 3:14 PM
  • Hi Folks,

    This is a known issue with the Audio firmware on the Raspberry Pi.  It was researched by Microsoft and we were unable to devise a fix without investigation into a change from RPi to their firmware. (Microsoft Ref #8004096)



    Wednesday, October 5, 2016 8:56 PM
  • IoTGirl, I just wanted to highlight this also happens with a DragonBoard 410c as discussed in my post above.


    Thursday, October 6, 2016 7:22 AM
  • The Raspberry PI 3 is running this version of Windows 10 IoT core...

    Device Model: Raspberry Pi 3
    OS Version: 10.0.14936.1000

    The DragonBoard 410c is...

    Device Model: SBC
    OS Version: 10.0.14393.187

    Thursday, October 6, 2016 8:09 AM
  • Nice work merging these two threads IoTGirl :o)
    Thursday, October 6, 2016 8:21 AM
  • Hi Gaz,

    We have a separate open issue (Microsoft Ref#7104482) with Qualcomm on video/audio jitter and are waiting on an update from them at this point.  For RPi we have confirmation that the firmware will not be updated.

    Essentially Microsoft builds a universal OS that relies on OEM drivers to create the interface between the OS and the hardware so we need an update to the OEM side to address this issue.



    Thursday, October 6, 2016 4:19 PM
  • I have solved the problem by using the AudioGraph API.
    Windows.Media.Audio.AudioGraph. The AudioGraph run as a separate process on the device so you get the POP only once on startup. I have only been working with audio files not video. 

    Thursday, October 6, 2016 7:30 PM
  • IoTGirl thank you for the reply. I find it a strange coincidence that the popping happens on DragonBoard410c and RPi?

    Thanks POB43 - I shall see what I can do about following your lead here with Video files.

    Friday, October 7, 2016 12:57 PM
  • I have solved the problem by using the AudioGraph API.
    Windows.Media.Audio.AudioGraph. The AudioGraph run as a separate process on the device so you get the POP only once on startup. I have only been working with audio files not video. 

    Unfortunately AudioGraph is not suitable for use with streams created using SpeechSynthesizer. The latency of saving the stream to a file first creates too much delay from sentence to sentence. So this is not a solution for me.

    However, it is curios that you say that AudioGraph doesn't have the popping sound on each clip. That tells me that although the problem is caused by RPi OEM firmware, that there should be a way for MediaPlayer to implement a work around for the firmware issue.

    Tuesday, October 25, 2016 7:27 AM
  • Whilst the AudioGraph does eliminate subsequent popping noises, it adds a constant interference noise for me (RPi 2) - it's not that loud, but noticeable.
    Tuesday, October 25, 2016 12:37 PM
  • I've managed to implement a way of using AudioGraph to render SpeechSynthesizerStream instances without the need for using intermediate files. I've documented the approach on my bloghere. TL/DR; it uses AudioFrameInputNode to copy the binary sample data from the stream into AudioFrame instances.

    Unfortunately it doesn't solve the issue with a pop sound at application start-up (I actually get three pop sounds!). That said, I've not noticed any "constant interference noise" when using this approach on a RPi3.

    Wednesday, January 25, 2017 10:58 PM
  • FYI, it turns out that the USB Sound Adapter I referred to in my blog does indeed prevent the 'popping' noises at application start-up. I assume it would resolve the issue with popping noises when emitting speech through MediaPlayer too (but haven’t tried this).
    Friday, January 27, 2017 9:31 AM