Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: little "click" when playing/stopping wav file

  1. #1
    Junior Member
    Join Date
    Dec 2018
    Posts
    7

    little "click" when playing/stopping wav file

    Hello,

    I am working on a simple wav player. Let's say I have 2 buttons. The first is "Play my wav sample", and the second "Stop my wav sample". When I press stop, there is a little "click" sound. I can't get rid of it.

    I use very basic code :
    playSdRaw1.play("my_file.wav");
    playSdRaw1.stop("my_file.wav");

    I have tried to use a mixer device with a gain set to 0 to mute the sound. Still this little noise.

    I use a teensy 3.2 with the audio shield.

    Any suggestion ?
    Thanks
    Emmanuel

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,178
    The click is caused when the sound level is abruptly dropped to zero. Instead of a mixer, try using an AudioEffectEnvelope with delay,attack,hold and decay all set to zero milliseconds. Set the sustain level to 1 and try setting the release time to 5 milliseconds. When you call noteOff, the release phase will ramp the audio level down to zero over 5 milliseconds which should remove the click. Just remember that when you call noteOff, the audio is still going to be playing for another 5 milliseconds. You may have to play with length of the release time to get an optimal value - I haven't tried this.

    Pete

  3. #3
    Junior Member
    Join Date
    Dec 2018
    Posts
    7
    Thank you Pete.
    Envelope is certainly a good idea. I 'll try this and let you know.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •