Page 1 of 1

how do i create a looping sound that is only played locally?

PostPosted: Thu Feb 21, 2013 01:18
by aximx51v
ok, the title says it all. I've tried
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.sound_play("grav_gen",{object = noise.object, gain = 0.3, max_hear_distance = 1, loop = true})

and it plays the sound. but i can hear it no matter where i go!
what's the proper way to do this? anybody know?
thanks in advance.

PostPosted: Thu Feb 21, 2013 01:29
by lkjoel
aximx51v wrote:ok, the title says it all. I've tried
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.sound_play("grav_gen",{object = noise.object, gain = 0.3, max_hear_distance = 1, loop = true})

and it plays the sound. but i can hear it no matter where i go!
what's the proper way to do this? anybody know?
thanks in advance.

Just making sure, noise.object is NOT the player, right?

PostPosted: Thu Feb 21, 2013 02:15
by RealBadAngel
aximx51v wrote:ok, the title says it all. I've tried
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.sound_play("grav_gen",{object = noise.object, gain = 0.3, max_hear_distance = 1, loop = true})

and it plays the sound. but i can hear it no matter where i go!
what's the proper way to do this? anybody know?
thanks in advance.


make sure ogg is mono, not stereo one
only mono files can be played with positioning

PostPosted: Thu Feb 21, 2013 03:34
by aximx51v
well, the noise.object is not the player,
that'd be a funny conundrum though. lol
my ogg file wasn't mono, but converting it to mono didn't change anything.. :P

i just found out though, it has something to do with it being played in association with an object.
if i play the sound at a position (without the loop) the sound is localized like it should be.

PostPosted: Thu Feb 21, 2013 03:38
by lkjoel
aximx51v wrote:well, the noise.object is not the player,
that'd be a funny conundrum though. lol
my ogg file wasn't mono, but converting it to mono didn't change anything.. :P

Try dumping the position of noise.object at globalstep, and see if it moves

PostPosted: Thu Feb 21, 2013 03:42
by aximx51v
anybody know is the abm interval setting set in seconds, or can it be variable?
i could make my sound life play at a pos (non looped) and have the sound length so it ends just when the abm starts it again...

PostPosted: Thu Feb 21, 2013 04:02
by RealBadAngel
https://github.com/RealBadAngel/technic/blob/master/technic/music_player.lua#L65
this code works ok
use pos to play sound in certain area

PostPosted: Thu Feb 21, 2013 04:25
by aximx51v
got it. i call:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
noise = minetest.sound_play("grav_gen",{pos = pos, gain = 0.5, loop = true, max_hear_distance = 15})

to start the sound, and then i call
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.sound_stop(noise)

to stop it.
i'm using a mono channel ogg file, btw..
thanks for the input guys, it's working!