File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ # -*- coding: utf-8 -*-
2
+ import time
3
+ from math import sin , cos
4
+
5
+ from pyrilla import core
6
+
7
+ from base import main
8
+
9
+
10
+ def pan_voices (lvoice , rvoice , t ):
11
+ # use two sounds like two independent channels
12
+ # its not as good as HRTF but can fake that
13
+ # sound source moves if you really want to believe :)
14
+ lvoice .gain = ((sin (t ) + 1. ) / 2. )
15
+ rvoice .gain = ((cos (t ) + 1. ) / 2. )
16
+
17
+
18
+ def file_handle (filename , ext ):
19
+ sound = core .Sound (filename , ext )
20
+ lvoice = core .Voice (sound , loop = True )
21
+ rvoice = core .Voice (sound , loop = True )
22
+
23
+ lvoice .play ()
24
+ rvoice .play ()
25
+
26
+ lvoice .pan = - 1.
27
+ rvoice .pan = 1.
28
+
29
+ try :
30
+ while True :
31
+ pan_voices (lvoice , rvoice , time .time ())
32
+ core .update ()
33
+ time .sleep (0.001 )
34
+
35
+
36
+ except KeyboardInterrupt :
37
+ print ("interrupted" )
38
+
39
+ if __name__ == "__main__" :
40
+ main (file_handle )
You can’t perform that action at this time.
0 commit comments