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

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

  1. #1

    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,249
    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
    Thank you Pete.
    Envelope is certainly a good idea. I 'll try this and let you know.

  4. #4
    Hi Pete,
    Your solution works. 2ms release+3ms delay do the trick.
    I noticed there is a releaseNoteOn(milliseconds) function that is designed for this, but I didn't manage to make it work. Do you have any idea ?
    Thanks
    Emmanuel

  5. #5
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,249
    Glad the envelope worked out.
    I haven't used releaseNoteOn. I did a quick scan through the code and couldn't figure out how/what it really does. I'll try to have a more detailed look and maybe play with it soon.

    Petee

Posting Permissions

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