.. _playing-music-tuto: Playing music ------------- In the Box Library, you can find the **Audio > Sound > Play Sound** box which allows you to play music on NAO. .. image:: /medias/dev/tutos/choregraphe/chore_music_box.png .. warning:: Make sure you are connected to a real NAO before realizing this tutorial. #. Drag and drop the **Audio > Sound > Play Sound** box onto the Flow Diagram and double-click on it. .. image:: /medias/dev/tutos/choregraphe/chore_music_box_struct.png Two boxes are enclosed in the Play Sound box as shown in the above diagram. #. Click on the wrench of the Get File Path box. #. Click on the button to browse and open the music file you want to listen to. The project file chooser dialog box is displayed. Select an audio file. #. Click on OK. The file is stored. You will not have to upload it again. #. Click on the button to launch your behavior. The music file you have selected is played on NAO. .. COMMENT: Use the SetSpeaker Vol. box under Audio of the Box Library to set the volume of the music you listen to. To do so: 1. Drag and drop the SetSpeaker Vol. box onto the flow diagram and connect it to the onStart entry and to the Play Sound box. 2. Click on the wrench of the Edit SetSpeaker Vol. box and set the % of volume. .. COMMENT: pas encore au point - 21.01.2010 .. COMMENT: Associating an audio file with the timeline Choose the box you want to associate the audio file with, double-click on it then open the timeline window. > The following window is displayed: Click on the "+" icon located on the right of the Multimedia menu. > You should see all the data included in your project. > It the audio file you want to display is already imported into your project, select it then click on OK. > If the audio file is not already imported, click on Audio Resources, select Add audio resource, choose the audio file you want to import then click on OK. > Your audio file is now displayed in the timeline window. The timeline and the display of the sound are synchronized. If you want to delete the audio file, click on the red cross located on the left. Go back to the main window of your project and click on the Play button. > The audio file is played with your behavior. .. COMMENT: dans une doc séparée Creating a simple behavior When you start Choregraphe, the interface will display an empty diagram. On the left hand side, a box library is there for you. All the boxes of this library have been created with Choregraphe. You should realize that once you are familiarized with this software, you will be able to add your own boxes to this library and create more complex behaviors from them. When you click on the button, the entry of your behavior is stimulated. This is the top left entry of your diagram. If nothing is connected to it, nothing should happen (well, in fact we have already explained that this is not completely true, but let's say for now that it is). If you drag and drop a box onto your diagram, it would be useless. It would be loaded as soon as the behavior is started, but it needs stimulation on its input to really do something. Making NAO dance For instance, drag and drop the "Dance" box. Now, this box is in your diagram but there is no connection to it yet. Click on the behavior entry and hold down the mouse button to drag it onto your box input. > A link appears between the entry and your box. Click on your box output and drag it onto the behavior output. > You have built your first behavior. Your diagram should look like this: Dance box Click on the button to test the behavior. > Your NAO or its 3D representation is now dancing. When you click on Play to test a behavior, the green signal on the diagram screen indicates the events and boxes that are stimulated in real time. Making NAO dance and talk The 3D NAO model can only simulate movements and not speech or Leds functions. However, if you are connected to a real NAO robot, you will be able to test all the behaviors you want and see the result for real. Drag and drop the Say box from the library onto the flow diagram. Connect the box onStart and onStopped entries to the input and output of the main behavior. Click on the button and watch. You may have to connect to a NAOqi if you have not already done it. > If you are connected to a real NAO robot, you should see NAO come to life, say "Hello" and dance at the same time. > If you are connected to a simulator, the 3D NAO will start dancing but will not say anything: the Say box becomes red. This is normal as a 3D NAO can only reproduce movements (see the Note just above). If you want NAO to first say "Hello" and then to start dancing, you simply need to link the 2 boxes like as shown below. Dance and Say boxes If you want NAO to say something different than "Hello", click on the box wrench to edit parameters. You can also edit the voice in this box.