2017-08-11 23:11:53

Hi there. Yesterday That i was trying to do some simple stuff with libaudioverse, I found out if I use the += operater, Handling key presses will faile. I used pyglet to handle them and make the window. So does anyone know what is the reason and how can it be done?
I use C# to develop stuff but since i heard the libaudioverse's HRTF pannings and environment creater, I surprized and since i got some experiences in python i decided to give it try,

---
Co-founder of Sonorous Arts.
Check out Sonorous Arts on github: https://github.com/sonorous-arts/
my Discord: kianoosh.shakeri2#2988

2017-08-12 01:47:44

In what way are you using the += operator? Do you get error messages, or does it just not work?

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2017-08-12 07:58:41

I don't get any errors at all! Application runs correctly, Just if I have a += oprater in a key press if condition block, Other key press conditions won't work too. My code is here:
import pyglet
import libaudioverse
import time
import sys
import Tolk
libaudioverse.initialize()
from pyglet.window import key
Tolk.load()
window=pyglet.window.Window()
server=libaudioverse.Server()
#Let's have a buffer here
buffer=libaudioverse.Buffer(server)
#now we load a file to use later
buffer.load_from_file("sound.ogg")
#Now the buffernode
bp=libaudioverse.BufferNode(server)
#Now we tell our buffernode what is its buffer
bp.buffer=buffer
#Buffernode looping
bp.looping=True

#Now initialize a panner
e=libaudioverse.EnvironmentNode(server, "default")
e.panning_strategy=libaudioverse.PanningStrategies.hrtf
e.output_channels=2
e.connect(0, server)

o=libaudioverse.SourceNode(server, e)
bp.connect(0, o, 0)

server.set_output_device("default")
e.orientation = 0, 1, 0, 0, 0, 1
e.position.value=(0, 0, 0)
global x
global y
global z

@window.event
def on_key_press(symbol, modifiers):
    if symbol == key.C:
        Tolk.output("%d, %d, %d" %(x, y, z))
    elif symbol == key.w:
        x+=1
    elif symbol == key.Q:
        sys.exit()
@window.event
def on_draw():
    window.clear()

pyglet.app.run()

---
Co-founder of Sonorous Arts.
Check out Sonorous Arts on github: https://github.com/sonorous-arts/
my Discord: kianoosh.shakeri2#2988

2017-08-12 09:10:03 (edited by magurp244 2017-08-12 09:10:11)

The "W" in "elif symbol == key.w:" isn't capitalized, this is likely causing an error thats blocking any further if statements.

-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2017-08-12 13:18:19 (edited by kianoosh 2017-08-12 13:20:55)

Oh maybe i wrongly did that but anyways, last time it was correct spelled and capitalised but my problem was still there...

---
Co-founder of Sonorous Arts.
Check out Sonorous Arts on github: https://github.com/sonorous-arts/
my Discord: kianoosh.shakeri2#2988

2017-08-13 00:41:44 (edited by magurp244 2017-08-13 00:56:23)

You'd be surprised at just how often a typo or something stupid like that can trip up even the most experienced programmer for hours on end. Hm, another possibility might be your use of globals, you usually have to specify globals when using them inside functions because of the local/non-local way python handles variables, are you using python 2.x or 3.x?

server.set_output_device("default")
e.orientation = 0, 1, 0, 0, 0, 1
e.position.value=(0, 0, 0)

x = 0
y = 0
z = 0

@window.event
def on_key_press(symbol, modifiers):
    global x
    global y
    global z
    if symbol == key.C:
        Tolk.output("%d, %d, %d" %(x, y, z))
    elif symbol == key.W:
        x+=1
    if symbol == key.Q:
        sys.exit()
@window.event
def on_draw():
    window.clear()

pyglet.app.run()
-BrushTone v1.3.3: Accessible Paint Tool
-AudiMesh3D v1.0.0: Accessible 3D Model Viewer

2017-08-13 19:14:14 (edited by kianoosh 2017-08-13 19:14:34)

Fixed. Man that fixed! Oh yeh thanks maggerb sorry for my damn spelling but changing the global's position fixed my problem! Oh maaan!

---
Co-founder of Sonorous Arts.
Check out Sonorous Arts on github: https://github.com/sonorous-arts/
my Discord: kianoosh.shakeri2#2988

2017-08-13 19:44:06

do not use globals. They are bad, tigers will steal your children and your head will combust.