It would be nice if, at each step in ListAnimate, there could be a clicking sound to draw attention to the new step.

I hope to use the single click sound sample available at: https://www.fesliyanstudios.com/royalty-free-sound-effects-download/mouse-click-2

Below is some to work on. Most of the code in Graphics[...] is not relevant so I displayed it on a single line. But you will need to use it for the example to show the proper context, namely, that of a short line segment, b, being used to pace off along the length of segment a.

ListAnimate[Range[10], AnimationRunning -> False, AnimationRepetitions -> 1.0]

A similar question was asked at:

Clickable clock making sound

However, the present case arises within Manipulate, which has its own constraints and affordances.

  • $\begingroup$ your code posted does not run. it has syntax error. An improperly formatted option head (Plus) was encountered while reading a GraphicsBox. The head of the option must be Rule or RuleDelayed. did you check it before posting? btw, since you say there could be a clicking sound to draw attention to the new step, would it not be better to make a small MWE to use for this? As all the other stuff is not relevant to the sound being generated at each click. The simpler the MWE, the more answer you will get. $\endgroup$ – Nasser Sep 27 '19 at 16:43
  • $\begingroup$ @Nasser, I posted a MWE, as suggested. $\endgroup$ – DavidC Sep 27 '19 at 23:15

there could be a clicking sound to draw attention to the new step.

You could do this with Manipulate?

I also do not know if this does what you want. Will delete this if not.

The issue is, when making a sound, is how long do you want to pause before the next step? Else the clicks will all merge together, and what sound to make? I use a C tone. You can change this.


 If[i < max,
  tick = Not[tick];
  EmitSound@SoundNote["C",pause]; (*play the "click" sound*)


 (*controls below*)

 Grid[{{"Max steps?", 
     Dynamic[max, {max = #; i = 0; tick = Not[tick]} &], {1, 10, 1}, 
     ImageSize -> Small, ContinuousAction -> False], Dynamic[max]}}

 {{pause, 0.03, "Pause time?"}, 0, 2, 0.01, Appearance -> "Labeled",ImageSize -> Small},

 {{tick, False}, None},
 {{i, 0}, None},
 {{max, 1}, None},
 TrackedSymbols :> {tick}

The above will play a short sound each time the number is incremented. You can change the pause amount all the way to zero.

enter image description here

  • $\begingroup$ Wonderful! You appear to be using the inherent looping of Mathematica in a way that emulates more explicit looping functions such as Do, While, or For. This gives considerable control over the internal workings of the loop. $\endgroup$ – DavidC Sep 28 '19 at 4:54

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.