1
$\begingroup$

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

$\endgroup$
2
$\begingroup$

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]];
    Panel@Labeled[ToExpression[skin],
        Grid[{{Button["play",playCode[]]},
        {Button["stop",Sound`StopMIDI[]]}}]
    , Left]
]

enter image description here

| improve this answer | |
$\endgroup$
  • $\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 '16 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 '16 at 5:30
  • $\begingroup$ @MarcoB thanks for the feedback :) $\endgroup$ – M.R. Mar 16 '16 at 6:30

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.