Skip to content

Commit

Permalink
include batch files
Browse files Browse the repository at this point in the history
  • Loading branch information
davircarvalho committed Apr 17, 2023
1 parent d611747 commit 624502b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
4 changes: 4 additions & 0 deletions env_setup.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
call conda create -n auralizaeac python=3.10 -y
call conda activate auralizaeac

call pip install -r requirements.txt --user
26 changes: 9 additions & 17 deletions renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import warnings
import threading
import numpy as np
import librosa as lb
import soundfile as sf
from copy import deepcopy
from FIRconv import FIRfilter
from EACheadtracker import HeadTracker
Expand Down Expand Up @@ -52,7 +52,7 @@
elevação=90: topo
azimute negativo: esquerda
'''
src_azim = 30 # azimute
src_azim = 0 # azimute
src_elev = 0 # elevação

# ##################################################################################33
Expand All @@ -75,20 +75,12 @@


# %% Audio Input
def mono2stereo(audio):
if np.size(audio.shape) < 2:
audio = np.expand_dims(audio, 0)
audio = np.append(audio, audio, axis=0)
return audio.T


# Audio input
audio_in, _ = lb.load(audioPath,
sr=fs,
mono=True,
duration=None,
audio_in, _ = sf.read(audioPath,
samplerate=None,
always_2d=True,
dtype=np.float32) # input signal
audio_in = mono2stereo(audio_in)
audio_in = np.mean(audio_in, axis=1, keepdims=True)
N_ch = audio_in.shape[-1]


Expand All @@ -110,7 +102,7 @@ def sph2cart(posArray):

def closestPosIdx(posArray, azi, ele, src_azim=src_azim, src_elev=src_elev):
aparent_azi = azi - src_azim
aparent_ele = ele - src_elev
aparent_ele = src_elev - ele
pErr = np.sqrt((posArray[:, 0] - aparent_azi)**2 +
(posArray[:, 1] - aparent_ele)**2)
return np.argmin(pErr)
Expand All @@ -129,15 +121,15 @@ def closestPosIdx(posArray, azi, ele, src_azim=src_azim, src_elev=src_elev):
p = pyaudio.PyAudio()
# open stream (2)
stream = p.open(format=pyaudio.paFloat32,
channels=N_ch,
channels=2,
rate=fs,
output=True,
frames_per_buffer=buffer_sz)

# play stream (3)
sigLen = audio_in.shape[0]

data_out = np.zeros((buffer_sz, N_ch))
data_out = np.zeros((buffer_sz, 2))
frame_start = 0
frame_end = frame_start + buffer_sz
while True:
Expand Down
2 changes: 2 additions & 0 deletions start_spyder.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
call conda activate auralizaeac
call spyder

0 comments on commit 624502b

Please sign in to comment.