For midi sounds, the bottom box in the DisplayForm is always blank, I'd like to be able to remove it:

Sound[{SoundNote["C"], SoundNote["G"]}]

enter image description here


1 Answer 1


Ok, just a quick hack:

customSound[s_] := Module[{playCode, boxForm, skin,notes},
    boxForm = ToBoxes @ s;
    playCode[] := Cases[boxForm, _EventHandlerTag, {0, \[Infinity]}, Heads -> True][[1, 1, 1, 2]];
    skin = boxForm[[1, 1, 2, 1, 1]];
    , Left]
customSound[Sound@{SoundNote["C"], SoundNote["G"]}]

enter image description here

  • $\begingroup$ Nasty hack. The functional pieces are the elements inside the BoxForm, it would be great to have a direct way of generate that without resorting to parsing the boxes! $\endgroup$
    – M.R.
    Mar 15, 2016 at 22:51
  • $\begingroup$ You may be interested in taking a look at the InputForm of the composite output; click on the graphics output by Sound, copy it and paste it to a new input cell, then wrap it in InputForm. Notice that you have to go through the copy/paste step, otherwise InputForm will simply return your Sound expression. See here for a sample of the results: image. I'm afraid that it's probably not that much better than the box expressions, but perhaps it's more readable! $\endgroup$
    – MarcoB
    Mar 16, 2016 at 5:30
  • $\begingroup$ @MarcoB thanks for the feedback :) $\endgroup$
    – M.R.
    Mar 16, 2016 at 6:30

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.