6
$\begingroup$

Apologies if this has been asked before, but I can't seem to find a solution. I have a little track - eg:

With[{li = {0, 4, 7, 12}}, With[{aa = (Flatten@
Join[(li + 12 #) & /@ Range@2, (li - 12 #) & /@ Range@2])}, 
Sound[(SoundNote[#, 1/2, "Cello"] & /@ Transpose@{RandomSample[#, 4] &@aa, 
RandomSample[#, 4] &@aa}) & /@ Range@8]]]

but I would like to slightly randomize the length each note plays (it used to be called humanising the sound as far as I recall!), ie, so that each note/ chord plays for $\dfrac{1}{2}\pm \epsilon$ seconds as opposed to each being equal.

$\endgroup$

2 Answers 2

5
$\begingroup$

Simply replace the 1/2 with 1/2 plus a RandomReal, and I think you get the desired effect:

eps = 1/10;
With[{li = {0, 4, 7, 12}}, 
  With[{aa = (Flatten@Join[(li + 12 #) & /@ Range@2, (li - 12 #) & /@ Range@2])},
  Sound[(SoundNote[#, 1/2 + RandomReal[{-eps, eps}], "Cello"] & /@ 
   Transpose@{RandomSample[#, 4] &@aa, RandomSample[#, 4] &@aa}) & /@ Range@8]]]

This sounds like it does the right thing, but I won't necessarily guarantee it, since I'm having trouble disentangling exactly what each piece of your code does.

$\endgroup$
0
3
$\begingroup$
With[{li = {0, 4, 7, 12}, eps = 0.25},
 With[{aa = (Flatten@Join[(li + 12 #) & /@ Range@2, (li - 12 #) & /@ Range@2])},
  Sound[(SoundNote[#, 1/2 + RandomReal[{-eps, eps}], "Cello"] & /@
       Transpose@{RandomSample[#, 4] &@aa, RandomSample[#, 4] &@aa}) & /@ Range@8]]]
$\endgroup$
1
  • 1
    $\begingroup$ Nice decision :) $\endgroup$
    – eldo
    Nov 30, 2015 at 21:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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