Example #1
0
    def prim_voltage(self, channel=0):
        if not self.hw in [XO1, XO15, XO175, XO30, XO4] or not self._status:
            return 0

        if not self._voltage_init:
            mode, bias, gain, boost = self.PARAMETERS[SENSOR_DC_NO_BIAS]
            self.audiograb = AudioGrab(self.new_buffer, self,
                                       mode, bias, gain, boost)
            self._channels = self.audiograb.channels
            for i in range(self._channels):
                self.ringbuffer.append(RingBuffer1d(self.max_samples,
                                                    dtype='int16'))
            self.audiograb.start_grabbing()
            self.audio_started = True
            self._voltage_init = True

        if self.hw in [XO1, XO4]:
            self._prim_voltage(0)
            return self._voltage[0]
        elif self.hw == XO15:
            self._prim_voltage(channel)
            return self._voltage[channel]
        # FIXME: For XO175: channel assignment is seemingly random
        # (#3675), one of them will be 0
        else:
            self._prim_voltage(0)
            if self._voltage[0] != 0:
                return self._voltage[0]
            else:
                self._prim_voltage(1)
                return self._voltage[1]
 def start(self):
     ''' Start grabbing audio if there is an audio block in use '''
     if not self._status:
         return
     self._sound = [0, 0]
     self._volume = [0, 0]
     self._pitch = [0, 0]
     self._resistance = [0, 0]
     self._voltage = [0, 0]
     if self.audio_started:
         self.audiograb.stop_grabbing()
     if len(
             self._parent.block_list.get_similar_blocks(
                 'block', ['volume', 'sound', 'pitch'])) > 0:
         mode, bias, gain, boost = self.PARAMETERS[SENSOR_AC_BIAS]
     elif len(
             self._parent.block_list.get_similar_blocks(
                 'block', ['resistance', 'resistance2'])) > 0:
         mode, bias, gain, boost = self.PARAMETERS[SENSOR_DC_BIAS]
     elif len(
             self._parent.block_list.get_similar_blocks(
                 'block', ['voltage', 'voltage2'])) > 0:
         mode, bias, gain, boost = self.PARAMETERS[SENSOR_DC_NO_BIAS]
     else:
         return  # No audio blocks in use.
     self.audiograb = AudioGrab(self.new_buffer, self, mode, bias, gain,
                                boost)
     self._channels = self.audiograb.channels
     for i in range(self._channels):
         self.ringbuffer.append(
             RingBuffer1d(self.max_samples, dtype='int16'))
     self.audiograb.start_grabbing()
     self.audio_started = True
Example #3
0
 def _init_sound(self):
     if not self._sound_init:
         mode, bias, gain, boost = self.PARAMETERS[SENSOR_AC_BIAS]
         self.audiograb = AudioGrab(self.new_buffer, self,
                                    mode, bias, gain, boost)
         self._channels = self.audiograb.channels
         for i in range(self._channels):
             self.ringbuffer.append(RingBuffer1d(self.max_samples,
                                                 dtype='int16'))
         self.audiograb.start_grabbing()
         self.audio_started = True
         self._sound_init = True