1
$\begingroup$

When I consider this simple code:

ListPlay[RandomReal[1, {2000}], SampleRate -> 1000]

I hear a click at the beginning of the sound sample and at the end of the sound sample. When I play couple of notes, click sound can be heard easier between notes.

a = Play[Sin[440 2^(1/12)  4 π x], {x, 0, 0.5}];
b = Play[Sin[440 2^(1/6) 4 π x], {x, 0, 0.5}];
c = Play[Sin[440 2^(1/4) 4 π x], {x, 0, 0.5}];
Sound[{a, b, c}]

Can that click sound be eliminated? Why does that happen?

I hear the same click sound when I play the sound at different laptops.

$\endgroup$
  • $\begingroup$ What version and OS are on your laptops? $\endgroup$ – J. M. will be back soon Apr 2 '16 at 8:31
  • $\begingroup$ Windows and Linux (Ubuntu). $\endgroup$ – gurluk Apr 2 '16 at 15:15
1
$\begingroup$

You can remove the clicks by fading the sound in and fading it out. One possibility is:

a = Play[CosineWindow[x - 0.5, 0.4] Sin[440 2^(1/12) 4 π x], {x, 0, 1}];
b = Play[CosineWindow[x - 0.5, 0.4] Sin[440 2^(1/6) 4 π x], {x, 0, 1}];
c = Play[CosineWindow[x - 0.5, 0.4] Sin[440 2^(1/4) 4 π x], {x, 0, 1}];
Sound[{a, b, c}]

Now the transitions are smooth. You can play with the coefficient (0.4 above) to adjust the duration of the fades or use other windowing functions.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.