1
$\begingroup$

The following correctly produces a click sound:

samples = 8000;
half = 4000;
timeconstant = 100;
list = RotateRight[Table[Exp[-t/timeconstant], {t, 0, samples - 1}], half] // N;
ListPlay[list, PlayRange -> {-1, 1}]

But any of the three following variations on PlayRange produce three clicks.

ListPlay[list, PlayRange -> All]

ListPlay[list, PlayRange -> Automatic]

ListPlay[list]

This is incorrect.

I could just use the working variant, but if I use it inside a Manipulate,

Manipulate[
 ListPlay[list, PlayRange -> {-1., 1.}]
 , {x, 0, 1}]

I get the obviously incorrect error message:

"Value of PlayRange -> {-1.,1.} is not a list of two machine-sized real numbers."

I realize these are probably bugs, and I have notified Wolfram, but I wonder if any experts here have any insight or workarounds. My need is urgent.

$\endgroup$
1
$\begingroup$

Wrapping ListPlay with Evaluate we get the expected output (v 9.0.1.0 Windows 8 x64):

Manipulate[Evaluate@ListPlay[list, PlayRange -> {-1., 1.}], {x, 0, 1}]

enter image description here

Update: Based on OP's comment below, the following "did it":

Manipulate[ControlActive[x,
             EmitSound[Sound[SampledSoundList[Clip[list, {-1., 1}], 8000]]]; x], 
 {x, 0, 1}]
| improve this answer | |
$\endgroup$
  • $\begingroup$ That is excellent, but I need to emit the sound. Neither of these works: Manipulate[ EmitSound[Evaluate@ListPlay[list, PlayRange -> {-1., 1.}]], {x, 0, 1}] Manipulate[ Evaluate@EmitSound[ListPlay[list, PlayRange -> {-1., 1.}]], {x, 0, 1} , TrackedSymbols :> {x}] $\endgroup$ – abwatson Feb 22 '15 at 11:26
  • $\begingroup$ @abwatson, why not use Play button in the content area of Manipulate[Evaluate@ListPlay[list, PlayRange -> {-1., 1.}], {x, 0, 1}] to emit the click sound? How is x related to the content displayed? $\endgroup$ – kglr Feb 22 '15 at 11:58
  • $\begingroup$ I would rather that the user not have to do anything extra (click on play) to produce the sound. Manipulate does not usually require such extra steps. The x has no effect in this example. It was just there to cause evaluation after user action. In my real use, I am presenting two clicks with a variable delay between them, to illustrate sound localization.The user varies the delay and listens to the result. $\endgroup$ – abwatson Feb 22 '15 at 12:44
  • $\begingroup$ @abwatson, does this give something close to what you need Manipulate[ControlActive[x, EmitSound[ Sound[ SampledSoundList[Clip[list, {-1., 1}], 8000]]]; x], {x, 0, 1}]? $\endgroup$ – kglr Feb 22 '15 at 13:12
  • $\begingroup$ Thanks! That did it, though I confess I do not understand why. I will have to study ControlActive. $\endgroup$ – abwatson Feb 23 '15 at 6:18

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.