PlayOrientedSound

From OxeyeWiki

(Difference between revisions)
Jump to: navigation, search
(Created page with '{{AudioMethod | audio.playOrientedSound(soundFilename, gain, modulation, x, y, z, [speedX, speedY, speedZ]) | Plays an audio file with a position in space. The volume and panning...')
m (Example)
Line 19: Line 19:
=== Example ===
=== Example ===
<pre>
<pre>
-
   audio.playOrientedSound("sfx/explosion.wav", 4, 1, bomb.x*myGameWorldResolution, bomb.y*myGameWorldResolution, 0)
+
  local bomb = {x = 120, y = 200}
 +
  local res = 1/32 -- 32 pixels is one meter.
 +
   audio.playOrientedSound("boom.wav", 4, 1, bomb.x*res, bomb.y*res, 0)
-
   audio.playOrientedSound("coin.wav", 1, 0.75+math.random()*0.5, 0, 0, 0) --at center of the world, randomly pitched coins dance
+
  --at center of the world, randomly pitched coins dance
 +
   audio.playOrientedSound("coin.wav", 1, 0.75+math.random()*0.5, 0, 0, 0)  
</pre>
</pre>

Revision as of 12:56, 18 January 2010

audio.playOrientedSound(soundFilename, gain, modulation, x, y, z, [speedX, speedY, speedZ])

Plays an audio file with a position in space. The volume and panning is then calculated based on the setSoundListenerPosition.

Parameter Expected Type Description
soundFilename A string The name of the audio file, relative to the source folder. The name is case sensitive on Mac OS X.
gain A number The power at which the sound is emitted.
modulation A number How pitch shifted the sound should be. Original pitch is 1.
x A number Position in space, in meters.
y A number Position in space, in meters.
z A number Position in space, in meters.
speedX A number The speed of the sound in space, for creation of doppler effects, in meters/second.
speedY A number The speed of the sound in space, for creation of doppler effects, in meters/second.
speedZ A number The speed of the sound in space, for creation of doppler effects, in meters/second.
Returns

Returns nothing.

Daisymoon Audio Lib

Example

   local bomb = {x = 120, y = 200}
   local res = 1/32 -- 32 pixels is one meter.
   audio.playOrientedSound("boom.wav", 4, 1, bomb.x*res, bomb.y*res, 0)

   --at center of the world, randomly pitched coins dance
   audio.playOrientedSound("coin.wav", 1, 0.75+math.random()*0.5, 0, 0, 0) 
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox