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

aximx51v
Member
 
Posts: 60
Joined: Fri Dec 07, 2012 03:47

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

by aximx51v » Thu Feb 21, 2013 01:18

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.
 

lkjoel
Member
 
Posts: 778
Joined: Wed Feb 29, 2012 19:27

by lkjoel » Thu Feb 21, 2013 01:29

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?
My mods: The Nether | Doctor Who (WIP)

I have quit minetest ... again. I am heavily unimpressed by both the game and the community.
 

User avatar
RealBadAngel
Member
 
Posts: 556
Joined: Wed Jul 18, 2012 16:30

by RealBadAngel » Thu Feb 21, 2013 02:15

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
 

aximx51v
Member
 
Posts: 60
Joined: Fri Dec 07, 2012 03:47

by aximx51v » Thu Feb 21, 2013 03:34

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.
Last edited by aximx51v on Thu Feb 21, 2013 03:39, edited 1 time in total.
 

lkjoel
Member
 
Posts: 778
Joined: Wed Feb 29, 2012 19:27

by lkjoel » Thu Feb 21, 2013 03:38

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
My mods: The Nether | Doctor Who (WIP)

I have quit minetest ... again. I am heavily unimpressed by both the game and the community.
 

aximx51v
Member
 
Posts: 60
Joined: Fri Dec 07, 2012 03:47

by aximx51v » Thu Feb 21, 2013 03:42

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...
 

User avatar
RealBadAngel
Member
 
Posts: 556
Joined: Wed Jul 18, 2012 16:30

by RealBadAngel » Thu Feb 21, 2013 04:02

https://github.com/RealBadAngel/technic/blob/master/technic/music_player.lua#L65
this code works ok
use pos to play sound in certain area
 

aximx51v
Member
 
Posts: 60
Joined: Fri Dec 07, 2012 03:47

by aximx51v » Thu Feb 21, 2013 04:25

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!
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 3 guests

cron