In [ ]:
%matplotlib inline
import numpy as np
import pandas as pd
import pylab as pl
from psi.controller.calibration.api import load_calibration
from psi.controller.calibration import chirp, tone
from psi.core.enaml.api import load_manifest_from_file
frequencies = [250, 500, 1000, 2000, 4000, 8000, 16000, 32000]
io_file = 'c:/psi-dev/io/pika_two_starship.enaml'
cal_file = 'c:/psi-dev/io/pika_two_starship/default.json'
io_manifest = load_manifest_from_file(io_file, 'IOManifest')
io = io_manifest()
st1 = io.find('NI_starship_1')
st2 = io.find('NI_starship_2')
channels = st1.get_channels(active=False) + st2.get_channels(active=False)
load_calibration(cal_file, channels)
In [ ]:
for channel in channels:
print(channel.name)
In [ ]:
tc1 = tone.tone_calibration(
st1,
frequencies,
ao_channel_name='speaker_1_1',
ai_channel_names=['microphone_1'],
gain=-30
)['microphone_1']
tc2 = tone.tone_calibration(
st2,
frequencies,
ao_channel_name='speaker_2_1',
ai_channel_names=['microphone_2'],
gain=-30
)['microphone_2']
In [ ]:
cc1 = chirp.chirp_calibration(
engine=st1,
ao_channel_name='speaker_1_1',
ai_channel_names=['microphone_1'],
gain=-30,
repetitions=8,
)['microphone_1']
cc2 = chirp.chirp_calibration(
engine=st2,
ao_channel_name='speaker_2_1',
ai_channel_names=['microphone_2'],
gain=-30,
repetitions=8,
)['microphone_2']
In [ ]:
for f in frequencies:
t = tc1.get_spl(f, 1)
c = cc1.get_spl(f, 1)
print(f'Tone: {t:0.2f}\tChirp: {c:0.2f}')
In [ ]:
for f in frequencies:
t = tc2.get_spl(f, 1)
c = cc2.get_spl(f, 1)
print(f'Tone: {t:0.2f}\tChirp: {c:0.2f}')
In [ ]: