Ejemplo n.º 1
0
 def set_mixer_balance(self, output, input, ch, balance):
     req = Hinawa.FwReq()
     gains = self._get_mixer_gains(req, output, input, ch)
     total = gains[0]['val'] + gains[1]['val']
     gains[0]['val'] = int(total * (100 - balance) // 100)
     gains[1]['val'] = total - gains[0]['val']
     for gain in gains:
         ExtMixerSpace.write_gain(self._protocol, req, gain['dst-ch'],
                                  gain['src-ch'], gain['val'])
Ejemplo n.º 2
0
 def set_mixer_balance(self, output, input, ch, balance):
     req = Hinawa.FwReq()
     gains = self._get_mixer_gains(req, output, input)
     total = gains[ch]['val'] + gainc[ch + 2]['val']
     left = total * (100 - balance) // 100
     right = total - left
     gains[ch]['val'] = left
     gains[ch + 2]['val'] = right
     for gain in gains:
         dst_ch = gain['dst-ch']
         src_ch = gain['src-ch']
         val = gain['val']
         ExtMixerSpace.write_gain(self._protocol, req, dst_ch, src_ch, val)
Ejemplo n.º 3
0
 def set_mixer_gain(self, output, input, ch, db):
     req = Hinawa.FwReq()
     gains = self._get_mixer_gains(req, output, input, ch)
     total = gains[0]['val'] + gains[1]['val']
     val = ExtMixerSpace.build_val_from_db(db)
     if total == 0:
         gains[ch] = val
         gains[(ch + 1) % 2] = 0
     else:
         gains[0]['val'] = gains[0]['val'] * val // total
         gains[1]['val'] = gains[1]['val'] * val // total
     for gain in gains:
         ExtMixerSpace.write_gain(self._protocol, req, gain['dst-ch'],
                                  gain['src-ch'], gain['val'])
Ejemplo n.º 4
0
    def _get_mixer_gains(self, req, output, input):
        if self.get_mixer_source(input) == 'None':
            raise ValueError('This input to mixer has no source.')
        if output not in self.get_mixer_output_labels():
            raise ValueError('Invalid argument for mixer stereo pair.')
        if input not in self.get_mixer_input_labels():
            raise ValueError('Invalid argument for mixer input stereo pair.')

        for dst in self._dsts:
            if dst[0] == output:
                break
        for src in self._srcs:
            if src[0] == input:
                break

        gains = []
        for dst_ch in dst[2]:
            for src_ch in src[2]:
                val = ExtMixerSpace.read_gain(self._protocol, req, dst_ch,
                                              src_ch)
                gain = {
                    'dst-ch': dst_ch,
                    'src-ch': src_ch,
                    'val': val,
                }
                gains.append(gain)

        return gains
Ejemplo n.º 5
0
 def set_mixer_gain(self, output, input, ch, db):
     req = Hinawa.FwReq()
     gains = self._get_mixer_gains(req, output, input)
     left = gains[ch]['val']
     right = gains[ch + 2]['val']
     total = left + right
     val = ExtMixerSpace.build_val_from_db(db)
     if total == 0:
         if ch == 0:
             left = val
         else:
             right = val
     else:
         left = int(val * left / total)
         right = int(val * right / total)
     gains[ch]['val'] = left
     gains[ch + 2]['val'] = right
     for gain in gains:
         dst_ch = gain['dst-ch']
         src_ch = gain['src-ch']
         val = gain['val']
         ExtMixerSpace.write_gain(self._protocol, req, dst_ch, src_ch, val)
Ejemplo n.º 6
0
    def get_mixer_saturations(self):
        outputs = self.get_mixer_output_labels()

        req = Hinawa.FwReq()
        rate = self._protocol.read_sampling_rate(req)
        mode = self._get_rate_mode(rate)
        saturations = ExtMixerSpace.read_saturation(self._protocol, req, mode)

        mixer_saturations = {}
        for i, saturation in enumerate(saturations):
            index = i // 2
            label = outputs[index]
            if label not in mixer_saturations:
                mixer_saturations[label] = [False, False]
            mixer_saturations[label][i % 2] = saturation
        return mixer_saturations
Ejemplo n.º 7
0
    def _get_mixer_gains(self, req, output, input, ch):
        if self.get_mixer_source(input) == 'None':
            raise ValueError('This input to mixer has no source.')
        if output not in self.get_mixer_output_labels():
            raise ValueError('Invalid argument for mixer stereo pair.')
        if input not in self.get_mixer_input_labels():
            raise ValueError('Invalid argument for mixer input stereo pair.')
        if ch not in (0, 1):
            raise ValueError('Invalid argument for channel in stereo pair.')

        for dst in self._dsts:
            if dst[0] == output:
                break
        for src in self._srcs:
            if src[0] == input:
                break

        gains = []
        total = 0
        src_ch = src[2][ch]
        for dst_ch in dst[2]:
            val = ExtMixerSpace.read_gain(self._protocol, req, dst_ch, src_ch)
            gain = {
                'dst-ch': dst_ch,
                'src-ch': src_ch,
                'val': val,
            }
            gains.append(gain)
            total += val

        # normalize.
        if total > ExtMixerSpace.MAX_COEFF:
            gains[0]['val'] = gains[0]['val'] * \
                ExtMixerSpace.MAX_COEFF // total
            gains[1]['val'] = gains[1]['val'] * \
                ExtMixerSpace.MAX_COEFF // total

        return gains
Ejemplo n.º 8
0
 def get_mixer_gain(self, output, input, ch):
     req = Hinawa.FwReq()
     gains = self._get_mixer_gains(req, output, input)
     left = gains[ch]['val']
     right = gains[ch + 2]['val']
     return ExtMixerSpace.parse_val_to_db(left + right)
Ejemplo n.º 9
0
 def get_mixer_gain(self, output, input, ch):
     req = Hinawa.FwReq()
     gains = self._get_mixer_gains(req, output, input, ch)
     total = gains[0]['val'] + gains[1]['val']
     return ExtMixerSpace.parse_val_to_db(total)