Wednesday, February 12, 2014

Script: Play a song - Basic Edition

:: BLACK TULIP PLAY A SONG - BASIC EDITION ::
:: Play one song from several sound clips in the object ::


Basic Play Song Script at Marketplace
By Auryn Beorn (2011)

TABLE OF CONTENTS




PURPOSE AND FEATURES


This box contains four full permissions scripts, separated in two blocks:

  • [Black Tulip] Play a Song - Basic Edition (AU)
  • [Black Tulip] Play a Song - Basic Edition (OO)

Both scripts perform the same action: On touch, it starts playing a song/stops playing a song. The difference between them is:

AU All Users - Everybody will be able to start/stop playing the song by clicking the object.
OO Owner Only - Only the owner of the object will be able to start/stop playing the song by clicking the object.

  • [Black Tulip] Play a Song - Basic Edition/Loop Song (AU)
  • [Black Tulip] Play a Song - Basic Edition/Loop Song (OO)

Both scripts perform the same action: On touch, it starts playing a song/stops playing a song. The song is played repeteadly performing a loop unless stopped.

The difference between them is:

AU All Users - Everybody will be able to start/stop playing the song by clicking the object.
OO Owner Only - Only the owner of the object will be able to start/stop playing the song by clicking the object.

These scripts are already prepared for sound clips that are 9.5 seconds length. If your sound clips have a different length, check the "Common Questions" section to know how to edit the script to change this to the length of your samples.

INSTALL AND USE YOUR PLAY SONG SCRIPT


In order to have any of these scripts working in your object, you have to:

  • Drop in the object all the sound clips that compose your song.
  • Drop the one script you want to use, from the four scripts available in the box.

Use only ONE script from the four in the box!
The description in the previous section should help you decide which to use depending of your application.

NOTE: The scripts order the sound clips to be played in the same order you see them in the "Contents" tab of the object.

IMPORTANT: Don't forget to change permissions of these scripts AND your sound samples! Refer to the license of use for instructions to change the permissions of the script you use.

COMMON QUESTIONS


Q: My sound clips are not 9.5 seconds length, but 9.7 seconds length. What should I do?

Edit the script you will use and look for the following line:

float   timerTime = 9.5;    // For samples cut to 9.5 seconds

then change it to:

float   timerTime = 9.7;

and save the script. From now on, it will be adapted to play a song composed of 9.7 seconds length samples.

Q: The volume is too loud. May I change it? How?

Edit the script you will use and look for the following line:

float   volumeSound = 1.0;  // Ranges from 0.0 to 1.0

then change it to (an example):

float   volumeSound = 0.75;  // Ranges from 0.0 to 1.0

and save the script. From now on, the music will be played by using a volume of 75% of the total it can get.

NOTE: If you don't know how to create sound clips to compose a song, you may either look for resources inworld, or learn to create them yourself. My "Music!" book covers this topic in detail and also points you to public domain resources to get songs and sounds legally.

"Music!" book in Marketplace.