Exemplo n.º 1
0
 def get_aux_volume(self, ch):
     if ch > 2:
         raise ValueError('Invalid argument for master channel')
     fb = self.__aux_output
     data = AvcAudio.get_feature_volume_state(self.unit.fcp, 0, 'current',
                                              fb, ch)
     return AvcAudio.parse_data_to_db(data)
Exemplo n.º 2
0
 def set_aux_volume(self, ch, db):
     if ch > 2:
         raise ValueError('Invalid argument for master channel')
     fb = self.__aux_output
     data = AvcAudio.build_data_from_db(db)
     AvcAudio.set_feature_volume_state(self.unit.fcp, 0, 'current', fb, ch,
                                       data)
Exemplo n.º 3
0
    def set_headphone_source(self, target, source):
        if target not in self.get_headphone_labels():
            raise ValueError('Invalid argument for headphone')
        if source not in self.get_headphone_source_labels(target):
            raise ValueError('Invalid argument for headphone source')

        if source == 'aux-1/2':
            value = 0x01
        else:
            value = 0x00
        AvcAudio.set_selector_state(self._unit.fcp, 0, 'current',
                                    self._SELECTOR_FB, value)

        if source != 'aux-1/2':
            for i, elems in enumerate(self._mixers):
                if self._labels['mixers'][i] == source:
                    data = (0x00, 0x00)
                else:
                    data = (0x80, 0x00)

                in_ch = elems[1][0]
                AvcAudio.set_processing_mixer_state(
                    self._unit.fcp, 0, 'current', self._PROCESSING_OUT_FB,
                    self._PROCESSING_IN_FB, in_ch, self._PROCESSING_OUT_CH,
                    data)
Exemplo n.º 4
0
 def set_analog_input_level(self, level):
     if level not in self._ANALOG_INPUT_LEVELS:
         raise ValueError('Invalid argument for input level.')
     data = self._ANALOG_INPUT_LEVELS[level]
     AvcAudio.set_feature_volume_state(self._fcp, 0, 'current',
                             self._ANALOG_INPUT_FB, self._ANALOG_INPUT_FB_PN,
                             data)
Exemplo n.º 5
0
 def get_mixer_input_gain(self, target, ch):
     if target not in self._fbs:
         raise ValueError('Invalid argument for input.')
     fb = self._fbs.index(target) + 1
     data = AvcAudio.get_feature_volume_state(
         self.fcp, 0, 'current', fb, ch)
     return AvcAudio.parse_data_to_db(data)
Exemplo n.º 6
0
 def set_mixer_routing(self, target, source, enable):
     in_fb, in_ch, out_fb, out_ch = self._refer_mixer_data(target, source)
     if enable:
         data = (0x00, 0x00)
     else:
         data = (0x80, 0x00)
     AvcAudio.set_processing_mixer_state(self.unit.fcp, 0, 'current',
                                         out_fb, in_fb, in_ch, out_ch, data)
Exemplo n.º 7
0
 def set_aux_balance(self, ch, balance):
     if ch > 2:
         raise ValueError('Invalid argument for master channel')
     fb = self.__aux_output
     data = AvcAudio.build_data_from_db(balance)
     ch += 1
     AvcAudio.set_feature_lr_state(self.unit.fcp, 0, 'current', fb, ch,
                                   data)
Exemplo n.º 8
0
 def set_output_source(self, target, source):
     if target not in self.__output_labels:
         raise ValueError('Invalid argumetn for output')
     if source not in self.__OUTPUT_SOURCES:
         raise ValueError('Invalid argumetn for output source')
     fb = self.__output_labels[target]
     ch = self.__OUTPUT_SOURCES[source]
     AvcAudio.set_selector_state(self.fcp, 0, 'current', fb, ch)
Exemplo n.º 9
0
 def set_output_source(self, target, source):
     index = self._refer_out_data(target)
     if source in self.labels['mixers'][index]:
         value = 0
     elif source.find('aux') == 0:
         value = 1
     else:
         raise ValueError('Invalid argument for output target')
     fb = self.__output_sources[index]
     AvcAudio.set_selector_state(self.unit.fcp, 0, 'current', fb, value)
Exemplo n.º 10
0
 def set_headphone_source(self, target, source):
     index = self._refer_hp_data(target)
     if source in self.labels['mixers']:
         ch = self.labels['mixers'].index(source)
     elif source.find('aux') == 0:
         ch = len(self.labels['mixers'])
     else:
         raise ValueError('Invalid argument for output target')
     fb = self.__hp_sources[index][0]
     value = self.__hp_sources[index][1][ch]
     AvcAudio.set_selector_state(self.unit.fcp, 0, 'current', fb, value)
Exemplo n.º 11
0
 def get_output_source(self, target):
     index = self._refer_out_data(target)
     fb = self.__output_sources[index]
     value = AvcAudio.get_selector_state(self.unit.fcp, 0, 'current', fb)
     if value == 1 and self.__aux_output:
         return 'aux-1/2'
     return self.labels['mixers'][index]
Exemplo n.º 12
0
 def get_headphone_source(self, target):
     index = self._refer_hp_data(target)
     fb = self.__hp_sources[index][0]
     value = AvcAudio.get_selector_state(self.unit.fcp, 0, 'current', fb)
     ch = self.__hp_sources[index][1][value]
     if ch < len(self.labels['mixers']):
         return self.labels['mixers'][ch]
     return 'aux-1/2'
Exemplo n.º 13
0
 def get_analog_input_level(self):
     result = AvcAudio.get_feature_volume_state(self._fcp, 0, 'current',
                         self._ANALOG_INPUT_FB, self._ANALOG_INPUT_FB_PN)
     for name, data in self._ANALOG_INPUT_LEVELS.items():
         if data == result:
             return name
     else:
         raise OSError('Unexpected data for input level')
Exemplo n.º 14
0
 def get_mixer_input_gain(self, target, ch):
     if target not in self._INPUTS:
         raise ValueError('Invalid value for input target.')
     offset = self._MIXER_INPUT_OFFSETS[target]
     quads = self._read_quads(offset, 4)
     pos = ch - 1
     total = quads[pos] + quads[pos + 2]
     data = pack('>H', total)
     return AvcAudio.parse_data_to_db(data)
Exemplo n.º 15
0
 def get_output_source(self, target):
     if target not in self.__output_labels:
         raise ValueError('Invalid argumetn for output')
     fb = self.__output_labels[target]
     idx = AvcAudio.get_selector_state(self.fcp, 0, 'current', fb)
     for key, val in self.__OUTPUT_SOURCES.items():
         if val == idx:
             return key
     else:
         raise ValueError('Unexpected value for output source.')
Exemplo n.º 16
0
    def get_headphone_source(self, target):
        if target not in self.get_headphone_labels():
            raise ValueError('Invalid argument for headphone')

        state = AvcAudio.get_selector_state(self.unit.fcp, 0, 'current',
                                            self.__SELECTOR_FB)
        if state == 0x01:
            return 'aux-1/2'
        elif state == 0x00:
            for i, elems in enumerate(self.mixers):
                in_ch = elems[1][0]
                data = AvcAudio.get_processing_mixer_state(
                    self.unit.fcp, 0, 'current', self.__PROCESSING_OUT_FB,
                    self.__PROCESSING_IN_FB, in_ch, self.__PROCESSING_OUT_CH)
                if data[0] == 0x00 and data[1] == 0x00:
                    return self.labels['mixers'][i]

        # No sources are set. For convenience, set 'mixer-1/2'.
        self.set_headphone_source('headphone-1/2', 'mixer-1/2')
        return 'mixer-1/2'
Exemplo n.º 17
0
 def set_mixer_input_gain(self, target, ch, db):
     if target not in self._INPUTS:
         raise ValueError('Invalid value for input target.')
     offset = self._MIXER_INPUT_OFFSETS[target]
     quads = self._read_quads(offset, 4)
     pos = ch - 1
     total = quads[pos] + quads[pos + 2]
     data = AvcAudio.build_data_from_db(db)
     value = unpack('>H', data)[0]
     quads[pos] = int(value * quads[pos] // total)
     quads[pos + 2] = int(value * quads[pos + 2] // total)
     self._write_quads(offset, quads)
Exemplo n.º 18
0
 def __get_volume(self, offset):
     if offset > len(self._cache):
         raise ValueError('Invalid argument for offset on address space')
     return AvcAudio.parse_data_to_db(self._cache[offset:offset + 2])
Exemplo n.º 19
0
 def __set_volume(self, offset, db):
     if offset > len(self._cache):
         raise ValueError('Invalid argument for offset on address space')
     data = AvcAudio.build_data_from_db(db)
     self.__write_data(offset, data)
Exemplo n.º 20
0
 def get_analog_output_mute(self, target, ch):
     fb, ch = self.__check_analog_output_channel(target, ch)
     return AvcAudio.get_feature_mute_state(self.fcp, 0, 'current', fb, ch)
Exemplo n.º 21
0
 def set_analog_output_mute(self, target, ch, enable):
     fb, ch = self.__check_analog_output_channel(target, ch)
     AvcAudio.set_feature_mute_state(self.fcp, 0, 'current', fb, ch, enable)
Exemplo n.º 22
0
 def get_analog_output_volume(self, target, ch):
     fb, ch = self.__check_analog_output_channel(target, ch)
     data = AvcAudio.get_feature_volume_state(self.fcp, 0, 'current', fb,
                                              ch)
     return AvcAudio.parse_data_to_db(data)
Exemplo n.º 23
0
 def set_analog_output_volume(self, target, ch, db):
     fb, ch = self.__check_analog_output_channel(target, ch)
     data = AvcAudio.build_data_from_db(db)
     AvcAudio.set_feature_volume_state(self.fcp, 0, 'current', fb, ch, data)
Exemplo n.º 24
0
 def get_input_balance(self, target, ch):
     index = self._refer_input_data(target)
     fb, ch = self._refer_fb_data(self.__inputs, index, ch)
     data = AvcAudio.get_feature_lr_state(self.unit.fcp, 0, 'current', fb,
                                          ch)
     return AvcAudio.parse_data_to_db(data)
Exemplo n.º 25
0
 def get_output_volume(self, target):
     quads = self._read_output_quad(target)
     data = pack('>I', quads[0])
     return AvcAudio.parse_data_to_db(data[2:])
Exemplo n.º 26
0
 def set_output_volume(self, target, db):
     quads = self._read_output_quad(target)
     data = AvcAudio.build_data_from_db(db)
     quads[0] &= ~0x0000ffff
     quads[0] |= unpack('>H', data)[0]
     self._write_output_quad(target, quads)
Exemplo n.º 27
0
 def get_mixer_routing(self, target, source):
     in_fb, in_ch, out_fb, out_ch = self._refer_mixer_data(target, source)
     data = AvcAudio.get_processing_mixer_state(self.unit.fcp, 0, 'current',
                                                out_fb, in_fb, in_ch,
                                                out_ch)
     return data[0] == 0x00 and data[1] == 0x00
Exemplo n.º 28
0
 def set_input_balance(self, target, ch, balance):
     if target not in self.__INPUT_LABELS:
         raise ValueError('invalid argument for input stereo pair')
     offset = (self.__INPUT_LABELS.index(target) - 2 + 16) * 4 + ch * 2
     data = AvcAudio.build_data_from_db(balance)
     self.__write_data(offset, data)
Exemplo n.º 29
0
 def get_input_balance(self, target, ch):
     if target not in self.__INPUT_LABELS:
         raise ValueError('invalid argument for input stereo pair')
     offset = (self.__INPUT_LABELS.index(target) - 2 + 16) * 4 + ch * 2
     data = self._cache[offset:offset + 2]
     return AvcAudio.parse_data_to_db(data)
Exemplo n.º 30
0
 def set_mixer_input_balance(self, target, ch, balance):
     if target not in self._fbs:
         raise ValueError('Invalid argument for input.')
     fb = self._fbs.index(target) + 1
     data = AvcAudio.build_data_from_db(balance)
     AvcAudio.set_feature_lr_state(self.fcp, 0, 'current', fb, ch, data)