stft.analysis(audio) stft.process() # Send audio back to the browser audio[:, 0] = np.sum(stft.synthesis(), axis=1) audio[:, 1] = audio[:, 0] audio[:, 2:] = 0 browserinterface.send_audio(audio) else: # continue estimating covariance matrix bf.estimate_cov(audio) """Interface features""" browserinterface.register_when_new_config(init) browserinterface.register_handle_data(beamform_audio) polar_chart = browserinterface.add_handler(name="Beam pattern", type='base:polar:line', parameters={ 'title': 'Beam pattern', 'series': ['Intensity'], 'numPoints': num_angles }) """START""" browserinterface.start() browserinterface.change_config(buffer_frames=buffer_size, channels=num_channels, rate=sampling_freq, volume=80) browserinterface.loop_callbacks()
# create the folder to save all the recordings os.mkdir(RECORD_FOLDER) # init turntable if not args.simulate: table = TurnTable(args.turntable) # setup sounddevice # init the browser interface browserinterface.inform_browser = False browserinterface.bi_board_ip = args.ip browserinterface.start() browserinterface.change_config(rate=SAMPLING_FREQUENCY, channels=channels, buffer_frames=BUFFER_SIZE, volume=MIC_VOLUME) # open the audio file filename = '/'.join([SAMPLES_FOLDER, SAMPLES_FILENAME]) rate, audio = wavfile.read(filename) audio = np.concatenate([np.zeros(rate // 2), audio]) # set interface rate sd.default.samplerate = rate # now loop for all the angles for angle in range(*angle_range): # position turntable