Adding Sound

From Constructive Labs
Revision as of 17:06, 7 June 2022 by Gmeader (talk | contribs)
Jump to navigation Jump to search

See Audio Control Panel for how to configure audio devices.

We will add an object that plays an audio file and wire up controls to play and stop the audio.

AddSound.png

Choose the STORE/ADD menu item and then Spatial -> Sound -> Sound The sound object appears. It looks like a red ball.

SoundButtons.png

Select it to assign a sound file to it in the Property Editor. (there is already a default sound file provided)

SoundProperties.png

Two momentaryButtons have previously been placed in the scene and labeled Play and Stop. We are going to wire them up to control the sound.

WireSound1.png

Choose the WIRE/CODE menu item. Choose the WIRE/SELECT item. Click on the red Sound Object and a new dark green ball will appear floating over the menu. If you point at it, a label “Sound0” will appear. This is the wiring ball for the sound object.

Now we are going to connect the play momentaryButton to control the sound. Click the + (in a circle) menu item .Then click on the Play momentaryButton.

WireSound2.png

A second ball will appear hidden behind the first dark green ball. Grab a ball and move it a little ways away so you can see two dark green balls. Each will have a label you can see if you point at it.

WireSound3.png

Click on the + menu item again to allow you to choose messages. Point at the ball for the Play momentaryButton and a menu of messages will appear. Choose the output->events-> mouseDown message.

WireSound4.png

A red line will appear. You connect that red line to the dark green sound ball, by clicking on that ball.

WireSound5.png

A menu of messages for the sound ball will appear. Choose the input->control->play item

WireSound6.png

Now a green line shows that the two objects are wired together and when a mouseDown event happens on the playMomentaryButton it sends a message to the sound object to play.

WireSound7.png

Now click on the + menu item and then click on the Stop momentaryButton. Another dark green ball appears for that object.

WireSound8.png

Move the new ball a bit away from the others.

WireSound9.png

Click on the + menu item again and then click on the ball for the Stop momentaryButton to get the messages menu. Choose output->events->mouseDown

WireSound10.png

A red line appears. Click on the sound ball.

WireSound11.png

The message menu appears, Choose input->control->stop.

WireSound12.png

Now the Stop button is wired to tell the sound to stop playing.

The wiring is complete. Click on the PLAY menu item to “go live” and then you can use the Pay and Stop momentaryButtons in the scene to start and stop the audio playback.

Next: Wiring