Message Boards Message Boards

3 Replies
10 Total Likes
View groups...
Share this post:

Controlling sound player object's size

When I execute the following expression (just an example), Mathematica returns a UI object that allows me to play sound notes.
Sound[{SoundNote[0, 0.5, "Piano"]}]

I would like to control the size of the UI object returned from the expression. Is there any option to control the size? I am not interested in manually arranging the size. This also applies to embedding this expression in Manipulate.

3 Replies
Thanks a lot! This is a good enough solution for me.

A regular Sound object has size of 250 pixels. You could find that out by selecting Sound object cell and going Top menu >> Cell >> Show expression. You will see underlying box structure and can find ImageSize option there. To get back your sound object uncheck Show expression in the menu. You can tap directly into that box structure by running something like this. Define a function:
boXsizE[obj_, size_] := RawBoxes[ToBoxes[obj] /. (ImageSize -> _) -> (ImageSize -> size)]
And then apply it:
boXsizE[Sound[{SoundNote[0, 0.5, "Piano"]}], 400]
POSTED BY: Vitaliy Kaurov
The documentation for the Sound expression doesn't show any option that allows you to control the look and feel of the UI object.

Instead, what you will want to do is to work with UI elements that you make yourself. The function EmitSound can be used to play a sound expression, so you can combine this with Mathematica's GUI expressions such as Button:
Button["Keyboard C", EmitSound[Sound[SoundNote[]]]]
This makes a button that plays Sound[SoundNote[]] when you click it.  There are many different Control Objects you can use in your interface
POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract