3
$\begingroup$

I am attempting to build a private stylesheet. One feature I would like to add is sound feedback when students move their mouse over a "Section" style cell. For example, on an Apple TV, as you move past different movies, you hear an audible click giving the user audio feedback (in addition to visual). I find this extra feedback pleasing.

If I can figure out how to do this in a regular notebook cell, then I think I can figure out how to add it to a stylesheet. I see a function called EmitSound[], which seems like it will help. I also see Sound Entities, which may already contain a click sound (or something close).

Also, I don't know how to emit the sound of a sound entity. Forgive me, I'm having a hard time figuring out how entities work.

Would anyone be able to point me in the right direction?

$\endgroup$
2
  • 1
    $\begingroup$ related: mathematica.stackexchange.com/questions/9657/… $\endgroup$
    – B flat
    Commented Aug 28 at 1:58
  • 1
    $\begingroup$ I don't think Sound Entities contain any actual sound (making them quite useless, actually ...). Anyhow, you just need to find somewhere (on the internet) a click sound that you like. Download it as a file and use it inside EmitSound. Since the other question already answers how to do this on a hover, I don't see any Mathematica-related question left :) $\endgroup$
    – Domen
    Commented Aug 28 at 21:26

1 Answer 1

1
$\begingroup$

Yes that related post has the real answer, but here's what the OP wants:

Cell[StyleData["Section"],
 CellMargins->{{27, Inherited}, {10, 30}},
 FontFamily->"Helvetica",
 FontSize->36,
 CellEventActions :>
  {"MouseEntered" :> EmitSound[Sound@SoundNote["C", 10*^10, "Flute"]],
    "MouseExited" :> EmitSound[Sound@SoundNote[SoundVolume -> 0]] },
 MenuSortingValue->10000]

You can get a click sound with an mp3 or do it from scratch like this:

Cell[StyleData["Section"],
 CellEventActions:>{"MouseEntered" :> EmitSound[
     Sound[
      Play[Sin[500 Pi t] Exp[(-5) t^2], {t, 0, 1}]]], "MouseExited" :> EmitSound[
     Sound[
      SoundNote[SoundVolume -> 0]]]}]

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ Exactly! Awesome. $\endgroup$
    – B flat
    Commented Aug 29 at 4:47
  • 1
    $\begingroup$ If anyone is interested... I posted a quick video of how it looks and sounds here: share.cleanshot.com/N7nvWDY1 $\endgroup$
    – B flat
    Commented Aug 29 at 5:25

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.