Week 4: Sounds and Lingo

Check my simple sound tutorial for how to import and attach sounds to mouse events and how to create background sounds.

Controlling a sound with Ling is done in pretty much the same way as the changing a sprite's properties (our experiments in week 2)
Sound in lingo is an object. The sound object is like a sprite, but it relates to the sound channels in the Score rather than the sprite
channels. There are a total of eight sound channels that you can use. To play sound member "mysound1" in channel 1 you would use the following command (download a .wav here if you don't have one):

sound(1).play([#member: member("mysound1")])

 

1 How to change the volume (example .dir /.html)
If you have a sound playing in channel 2 - you can turn up the volume using a button script like this:

on mouseUp me
    sound(2).volume = sound(2).volume +40
end

or turn it down by attaching a the following to a sprite

on mouseUp me
    sound(2).volume = sound(2).volume - 40
end

 

2 How to change the pitch (example .html / dir):
By using the rateShift property of a sound, you are basically playing back the sound faster or slower than the original.

-- this makes the sound play normally
on mouseUp me
    sound(1).play([#member: member("com_0009"), #rateShift:0])
end

-- this makes the sound play slow
on mouseUp me
    sound(1).play([#member: member("com_0009"), #rateShift:-5])
end

-- this makes the sound play fast
on mouseUp me
    sound(1).play([#member: member("com_0009"), #rateShift: 5])
end

 

3 Director can talk (example) - How to use text-to-speech in Director
Director can access the synthetic voices (text-to-speech) on your computer. Try typing the following in the Message panel

voiceSpeak("hello world")

In a mouse event script, you would start with VoiceInitialize() to intialize the speech engine

on beginSprite me
    VoiceInitialize()
end

on mouseUp me
    voiceSpeak("hello world")
end

If you type the following into the message window, you will get a list of voices

put voiceGetAll()

You can use the #index number of the voice to set the voice to a different voice:

voiceSet(16)
voiceSpeak("hello")

 

Streaming an MP3 file:
http://livedocs.macromedia.com/director/mx2004/release_update_en/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Director_MX_2004_Documentation&file=12_sou15.htm