コード例 #1
0
    def set_attenuations(self, att1, att2):
        '''
        Set attenuators for Out-1 and Out-2 on the RZ6.  If either attenuation
        is None, then that attenuation is not changed.  For example, to change
        the attenuation only for Out-2:

        >>> self.set_attenuations(None, 60)

        Note that this only sets the hardware attenuation in valid steps (e.g.
        0, 20, 40 and 60 dB).  The remaining attenuation must be realized via
        scaling of the waveform before it is uploaded to the signal buffer.

        Returns the remaining attenuation that needs to be achieved via scaling
        the waveform.
        '''
        # Again, we hide the import so people can launch the GUI without being
        # able to run the experiment.
        from tdt.device import RZ6

        # TDT's built-in attenuators for the RZ6 function in 20 dB steps, so we
        # need to determine the next greater step size for the attenuator.  The
        # maximum hardware attenuation is 60 dB.
        log.debug('Attempting to change attenuation to %r and %r', att1, att2)

        if att1 is None:
            att1 = self.hw_att1
        if att2 is None:
            att2 = self.hw_att2
        hw1, sw1 = RZ6.split_attenuation(att1)
        hw2, sw2 = RZ6.split_attenuation(att2)

        if hw1 != self.hw_att1:
            self.hw_att1 = hw1
            log.debug('Updated primary attenuation to %.2f', hw1)
        if hw2 != self.hw_att2:
            self.hw_att2 = hw2
            log.debug('Updated secondary attenuation to %.2f', hw2)

        # For efficiency reasons, we prefer to do most of the computation for
        # the RZ6 attenuator values in software rather than hardware.
        att_bits = RZ6.atten_to_bits(att1, att2)
        self.iface_behavior.set_tag('att_bits', att_bits)

        # This is the remaining
        return sw1, sw2
コード例 #2
0
ファイル: positive_cmr.py プロジェクト: bburan/NeuroBehavior
 def set_hw_att(self, atten):
     # The RPvds circuit has a toggle to send the waveform to one speaker or
     # the other (the inactive speaker essentially recieves a string of 0's),
     # so we will simply set both speakers to the same attenuation to avoid
     # the "click" in between every trial that occurs when the hardware
     # attenuators are set.
     att_bits = RZ6.atten_to_bits(atten, atten)
     self.iface_behavior.set_tag('att_bits', att_bits)
     self._update_masker_sf()