Playing sound files

If you have a module that you'd like comments on or would like to know how to create your very own module, post here

Moderator: Moderator

Post Reply
Message
Author
Grey
Loremaster
Posts: 3517
Joined: Thu Sep 23, 2010 10:18 pm
Location: London, England
Contact:

Playing sound files

#1 Post by Grey »

DarkGod, you said before that you can get a file to play at different pitches by calling on a lua sound file for the game with certain settings. Would you mind explaining that thoroughly? I'd like to play about with this a lot.
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

tiger_eye
Perspiring Physicist
Posts: 889
Joined: Thu Feb 17, 2011 5:20 am

Re: Playing sound files

#2 Post by tiger_eye »

DGrey, instead of playing the sound as such:

Code: Select all

game:playSound("the_sound_name")
do it instead as:

Code: Select all

game:playSound({"the_sound_name", pitch=1, vol=0.5})
Note that the sound file is specified as a table, not a string. I think "pitch" is a scale value, such as if the initial sound was middle C, 2.0 would be an octave higher, and 0.5 would cause it to be an octave lower.

If you want to play one of many sound files randomly (such as "many_sounds5", "many_sounds6", "many_sounds7"), you can do:

Code: Select all

game:playSound({"many_sounds%d", 5, 7, pitch=1, vol=0.5})
OpenAL offers more ways to tweak sounds, and I'm sure extra functionality could be added to t-engine if you request it.
darkgod wrote:OMFG tiger eye you are my hero!

Grey
Loremaster
Posts: 3517
Joined: Thu Sep 23, 2010 10:18 pm
Location: London, England
Contact:

Re: Playing sound files

#3 Post by Grey »

Thanks, tiger_eye! Got this implemented in Mosaic now and it sounds way better :D
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

Grey
Loremaster
Posts: 3517
Joined: Thu Sep 23, 2010 10:18 pm
Location: London, England
Contact:

Re: Playing sound files

#4 Post by Grey »

tiger_eye wrote: OpenAL offers more ways to tweak sounds, and I'm sure extra functionality could be added to t-engine if you request it.
What about echo and reverb? Do you think those could be implemented in-engine?
http://www.gamesofgrey.com - My own T-Engine games!
Roguelike Radio - A podcast about roguelikes

Post Reply