A question/problem

17 views
Skip to first unread message

mason armstrong

unread,
Sep 9, 2016, 9:37:38 PM9/9/16
to libaud...@camlorn.net
Hi,

Forgive me for the weird sounding question here, I'm a beginner with
libaudioverse, and I was trying to experiment with it. My problem is
this. When I've created my sound and node and all that, when I set my
position, the environment moves instead of the sound. Here is my code

I have two attachments, if you'd rather read them here I've included the
code below.


Lib.py

import time
import sound
import libaudioverse
libaudioverse.initialize()
sim = libaudioverse.Simulation()
sim.set_output_device(-1)
world = libaudioverse.EnvironmentNode(sim, "default")
world.panning_strategy = libaudioverse.PanningStrategies.hrtf
world.orientation = 0, 1, 0, 0, 0, 1
sl=sound.SoundLoader(sim,world)
reverb = libaudioverse.FdnReverbNode(sim)
send = world.add_effect_send(channels = 4, is_reverb = True,
connect_by_default = True)
reverb.connect_simulation(0)
world.connect(send, reverb, 0)
snd=sl.load_sound("sound")
snd.play(True)
time.sleep(1)
snd.source.position=3, 0, 0
time.sleep(1)
libaudioverse.shutdown()

sound.py

import os

import libaudioverse
import platform_utils.paths

sound_dir = os.path.join(platform_utils.paths.embedded_data_path(),
'sounds')

class SoundLoader(object):

def __init__(self, simulation, world):
self.simulation = simulation
self.world = world
self.cache=dict()

def load_sound(self, key):
if key not in self.cache:
source = libaudioverse.SourceNode(self.simulation, self.world)
b = libaudioverse.Buffer(self.simulation)
b.load_from_file(os.path.join(sound_dir, key+".ogg"))
self.cache[key] = b
b = self.cache[key]
n = libaudioverse.BufferNode(self.simulation)
n.buffer.value =b
n.connect(0, source, 0)
return Sound(n,source)

class Sound(object):

def __init__(self, buffer_node,source):
self.buffer_node = buffer_node
self.source = source

def stop(self):
self.buffer_node.state = libaudioverse.NodeStates.stop

def is_playing(self):
return self.buffer_node.state == libaudioverse.NodeStates.playing

def play(self,loop=False):
self.buffer_node.connect_simulation(0)
self.buffer_node.position=0
self.buffer_node.looping=loop
self.buffer_node.state = libaudioverse.NodeStates.playing
lib.py
sound.py

Austin Hicks

unread,
Sep 12, 2016, 1:43:59 PM9/12/16
to libaud...@camlorn.net
Judging by some stuff you said on Twitter, I got the impression that you
managed to figure this out. Is this the case?

mason armstrong

unread,
Sep 12, 2016, 2:09:52 PM9/12/16
to libaud...@camlorn.net
Indeed it is. Thanks.
Reply all
Reply to author
Forward
0 new messages