va_example_simple.py 1.28 KB
Newer Older
1 2 3
# Add va module if it was not installed
import sys
sys.path.append( '../Lib/site-packages' )
4
sys.path.append( '../dist/Lib/site-packages' )
5

6
import os
7 8 9 10
current_exec_dir = os.getcwd()

import va

11
va.connect() # localhost
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
12
va.reset()
13 14
va.add_search_path( current_exec_dir ) # add current working path to find any file lying around here

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
15
signal_source_id = va.create_signal_source_buffer_from_file( 'Audiofiles/lang_short.wav' ) # Provide this file or modify file name and use your own
16

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
17
dir_id = va.create_directivity_from_file( '$(Trumpet)' )
18

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
19
sound_source_id = va.create_sound_source( 'PySoundSource' )
20
va.set_sound_source_signal_source( sound_source_id, signal_source_id )
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
21
va.set_sound_source_directivity( sound_source_id, dir_id )
22 23
va.set_sound_source_position( sound_source_id, ( 1, 1.2, -1 ) ) # OpenGL axes convention, direction is lower front-right from listener pos (s.b.)

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
24
hrir_id = va.create_directivity_from_file( '$(DefaultHRIR)' )
25

26
sound_receiver_id = va.create_sound_receiver( "PyListener" )
Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
27
va.set_sound_receiver_directivity( sound_receiver_id, hrir_id )
28
va.set_sound_receiver_position( sound_receiver_id, ( 0, 1.7, 0 ) ) # Ear height at 1.7m 
29

Dipl.-Ing. Jonas Stienen's avatar
Dipl.-Ing. Jonas Stienen committed
30 31
va.set_signal_source_buffer_looping( signal_source_id, True )
va.set_signal_source_buffer_playback_action_str( signal_source_id, 'play' )
32

33
va.disconnect()