Пример #1
0
    def init_trial(self, trial):
        """Set signal for variable."""

        noise_dur = 0.3         # duration of noise
        pause_dur = 0.03        # pause between noise and sine
        sine_dur = 0.015        # duration of test signal
        ramp_dur = 0.0075       # ramp of hann window

        sine_freq = 1600        # freq of test signal
        noise_freq = 1600       # midfreq of noise
        noise_band_width = 300  # bandwidth of noise

        # trial.test_signal = test_tone (matlab)
        sine_ampl = np.sqrt(2)*10**(trial.variable/20)
        m_test = gensin(sine_freq, sine_ampl, sine_dur, 0,
                                   trial.sample_rate)
        m_test = hanwin(m_test, np.round(
            ramp_dur*trial.sample_rate))

        # generate new instance of running noise
        m_ref = np.random.randn(np.round(noise_dur*trial.sample_rate))
        m_ref = fft_rect_filt(m_ref, noise_freq-noise_band_width/2,
                              noise_freq+noise_band_width/2, trial.sample_rate)

        # adjust its level
        m_ref = m_ref/rms(m_ref)*10**(trial.noise_level/20)
        # apply onset/offset ramps
        m_ref = hanwin(m_ref, np.round(ramp_dur*trial.sample_rate))


        pause_zeros = np.zeros(np.round(pause_dur*trial.sample_rate))
        sine_zeros = np.zeros(np.round(sine_dur*trial.sample_rate))
        trial.reference_signal = np.concatenate((m_ref, pause_zeros, sine_zeros))
        trial.test_signal = np.concatenate((m_ref, pause_zeros, m_test))
Пример #2
0
 def init_trial(self, trial):
     """Set signal for variable."""
     trial.test_signal = np.random.randn(0.6*trial.sample_rate)
     trial.test_signal = fft_rect_filt(trial.test_signal,
                                       trial.frequency-50,
                                       trial.frequency+50,
                                       trial.sample_rate)
     
     trial.test_signal = trial.test_signal/rms(trial.test_signal)*10**(trial.variable/20)
     trial.test_signal = hanwin(trial.test_signal, 0.05)
     return trial
Пример #3
0
    def init_experiment(self, exp):
        exp.add_parameter("frequency",[100, 200, 500, 1000, 2000, 4000], "Hz")
        exp.set_variable("gain", -30, "dB")
        exp.add_adapt_setting("1up2down", 3, 8, 1)
        exp.task = "loudness of the noise should go (u)p/(d)own? "
        exp.debug = False
        exp.discard_unfinished_runs = False
        exp.description = """This is the description of matching experiment"""

        ref = gensin(1000, 1, 0.6, 0, exp.sample_rate)
        srms = rms(ref)
        exp.reference_signal = ref/srms*10**(-30/20)
        exp.reference_signal = hanwin(exp.reference_signal, 0.05)
        exp.pre_signal = 0.1
        exp.between_signal = 0.2
        exp.post_signal = 0.3
Пример #4
0
 def init_run(self, run):
     ref = np.random.randn(np.round(0.3*run.sample_rate))
     ref = ref/rms(ref)*10**(run.noise_level/20)
     run.reference_signal = ref