SOUND EFFECTS

Sound is very important. A killer shot, a baby laughting, an old Xmas song (Merry Xmas, friends!). Sound is important for the creation of a nice Croquet space. Could be an ambient sound or a sound played when something happens, a collision , by example.

Squeak-Croquet has the Class StreamingMP3Sound. To use it you need to create an object-reference , a "prefix", writing something like:

 
sg1:= StreamingMP3Sound onFileNamed:  
 (FileDirectory pathFrom:
           {FileDirectory default pathName.  'Content'. 'columnLogo4x6x4' .'aSound.mp3'}) .

And the more used method is:

sg1 play.

But here, for you, a " quick reference" of the Class:

 
StreamingMP3Sound 

onFileNamed:filepath+name       Look the sample...


duration                       Returns the duration of this sound in seconds.

repeat                          Returns the repeat flag.

repeat:true | false            Set the repeat flag. If true, this sound will 
                                loop back to the beginning when it gets to the end.

soundPosition                   Returns  the relative position of sound playback as a 
                                number between 0.0 and 1.0.

soundPosition:n                Jump to the position the given fraction through the sound 
                                 file. The argument is a number between 0.0 and 1.0.

volume                          Returns the volume.

volume:n                       Set the volume to the given number between 0.0 and 1.0.
 
closeFile                      Close the .MP3  file.

millisecondsSinceStart          Returns the number of milliseconds since this sound 

                                started playing.

play                            Plays...

reset                            Reset the internal state for a replay.  

The exercice you will do is: when the car kicks the column, in the exercice of the previous lesson, play a sound. You need to download:

babylaughting.mp3 - in the folder columnLogo4x6x4

You need only to change the method:

verifycL4x6x4a 
| onetime dist sg1 |
onetime:=0.
dist:=(bC distanceTo:cL4x6x4a).
(dist<8 & onetime=0) ifTrue: [
 cL4x6x4afly:=1.

 sg1:=StreamingMP3Sound onFileNamed:  
  (FileDirectory pathFrom:
           {FileDirectory default pathName.  'Content'. 'columnLogo4x6x4' .'babylaughting.mp3'}) . 
 sg1 play.

 onetime:=1.
].  

Like this method is executed in the moment of the collision, you will hear the sound.

And now, some selected .MP3 sound effects you can download and use (from the internet - I think that they don't have copyright).Clicking you can hear (you need to have a sound player plugin).Rightclick to save.:

TIP: Sometimes you can use only part of a sound using the methods of the Class.

applause1.mp3

applause2.mp3

atmospherebirds1.mp3

atmospherebirds2.mp3

atmospherebar.mp3

atmosphereforest.mp3

atmospheretennis.mp3

atmospheresea1.mp3

atmospherestreet.mp3

beep1.mp3

bell1.mp3

cararriving.mp3

click1.mp3

cock.mp3

cornet.mp3

dialtone.mp3

doorclosing1.mp3

dooropening1.mp3

drumloop1.mp3

drumloop2.mp3

electricmotor.mp3

evillaught.mp3

explosion1.mp3

explosion2.mp3

fanonoff.mp3

footsteps1.mp3

gunshot1.mp3

gunshot2.mp3

gunshot3.mp3

gunshot4.mp3

gunshot5.mp3

gunshot6.mp3

gunshot7.mp3

gunshotlaser1.mp3

gunrecharging.mp3

harpgliss.mp3

helicopter.mp3

jumbojet.mp3

kick&applause.mp3

lift1.mp3

machinegun.mp3

phoneringing.mp3

rain1.mp3

rain2.mp3

rocket&bang1.mp3

rocket&bang2.mp3

siren1.mp3

siren2.mp3

switch1.mp3

train.mp3

typing.mp3

water1.mp3

water2.mp3

waterdrops.mp3

weddingbells.mp3

wind.mp3

ziiip.mp3

You can download all the collection (4.7 MB):

sounds.zip



PREVIOUS LESSON NEXT LESSON
T. CONTENTS HOMEPAGE

DISCLAIMER: This material can be translated for any language, and reproduced total or partially by anybody using any type of media. But, please, don't put your name like author. And let me know if it was useful (americo@dmu.com).The use of any code, 3D model or technique published is free and doesn't need to have any reference about this source.The author is not responsible for any damage that the material can cause to your professional or sexual life.