-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathtest2.py
More file actions
31 lines (26 loc) · 709 Bytes
/
test2.py
File metadata and controls
31 lines (26 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import sys
import time
import math
import random
import os
import openal
device = openal.Device()
contextlistener = device.ContextListener()
source = contextlistener.get_source()
buffer = openal.Buffer(os.path.join('sounds', '440.wav'))
contextlistener.position = 0, 0, 0
contextlistener.velocity = 0, 0, 0
contextlistener.orientation = 0, 1, 0, 0, 0, 1
source.buffer = buffer
source.looping = True
source.gain = 1
source.play()
t = 0
amplitude = 1
freq = 1
while True:
source.position = amplitude*math.sin(t*freq), amplitude*math.cos(t*freq), 0
source.velocity = amplitude*freq*math.cos(t*freq), -amplitude*freq*math.sin(t*freq), 0
print (t*180/math.pi)%360
time.sleep(.01)
t += .01