mason armstrong
unread,Sep 9, 2016, 9:37:38 PM9/9/16Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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