コード例 #1
0
 def testConversion(self):
     return
     for mul in [-2, -1, -.8, -.3, 0.1, 0.3, 0.331, 0.6, 0.9, 1, 1.2]:
         for d in [
                 0.0001, 0.1234, 0.5, 0.51, 0.52, 0.53, 0.7, 1, 1.1, 1.2,
                 1.22, 2.9, 0
         ]:
             val = mul * d
             print(val)
             print(Adau145x.decimal_repr(val))
             self.assertAlmostEqual(
                 val, Adau145x.decimal_val(Adau145x.decimal_repr(val)), 5)
コード例 #2
0
 def __init__( self, filename=None ):
     self.dsp = Adau145x()
     self.doc = None
     self.filename = filename
     self.eeprom = DummyEepromWriter( self.dsp )
     if filename is not None:
         self.read_from_file( filename )
コード例 #3
0
ファイル: xmlprofile.py プロジェクト: hifiberry/hifiberry-dsp
def replace_in_memory_block(data, startaddr, replace_dict):
    """
    Replace memory cells in memory write commands in an XML profile
    This function won't be applied to EEPROM write commands!
    """
    cell_len = Adau145x.cell_len(startaddr)

    assert len(data) % cell_len == 0

    endaddr = startaddr + len(data) / cell_len

    for repl_addr in replace_dict.keys():
        if repl_addr >= startaddr and repl_addr <= endaddr:
            content = replace_dict[repl_addr]

            if len(content) != cell_len:
                logging.error(
                    "Cell %s: content len is %s but cell len is %s, ignoring",
                    repl_addr, len(content), cell_len)
                continue

            assert len(content) == cell_len

            address_offset = (repl_addr - startaddr) * cell_len
            logging.debug("replacing memory at address {} by {}", repl_addr,
                          content)

            data[address_offset:address_offset + len(content)] = content
コード例 #4
0
def main():
    global sigmatcp

    if len(sys.argv) > 1:
        if "-v" in sys.argv:
            logging.basicConfig(format='%(levelname)s: %(name)s - %(message)s',
                                level=logging.DEBUG,
                                force=True)
    else:
        logging.basicConfig(format='%(levelname)s: %(name)s - %(message)s',
                            level=logging.INFO,
                            force=True)

    signal.signal(signal.SIGUSR1, stop_playback)

    sigmatcp = SigmaTCPClient(Adau145x(), "127.0.0.1")

    while True:
        time.sleep(1)

        if stopped:
            logging.debug("stopped")
            continue

        if (spdifactive()):
            silenceloop()
        else:
            logging.debug("no SPDIF lock, sleeping")
コード例 #5
0
 def __init__(self,
              ip="127.0.0.1",
              dsp=Adau145x()):
     self.dsp = dsp
     self.ip = ip
     self.sigmatcp = SigmaTCPClient(self.dsp, self.ip)
     self.resetgpio = None
コード例 #6
0
    def testValues(self):
        # Known good representations (calculated in SigmaStudio)
        known_good = {
            0x80000000: -128,
            0xFF000000: -1,
            0: 0,
            0x40000000: 64,
            0x1000000: 1,
            0x10000: 0.00390625,
        }

        for b in known_good:
            f = known_good[b]
            self.assertEqual(b, Adau145x.decimal_repr(f),
                             "float -> int failed for {}/{}".format(b, f))
            self.assertEqual(f, Adau145x.decimal_val(b),
                             "int -> float failed for {}/{}".format(b, f))
コード例 #7
0
ファイル: settings.py プロジェクト: qerub/hifiberry-dsp
    def __init__(self, filename, fs=48000, dsp=Adau145x()):
        self.values = {}
        self.fs = fs
        self.dsp = dsp
        with open(filename) as settingsfile:
            for line in settingsfile:
                if len(line.strip()) == 0 or line.startswith("#"):
                    continue

                try:
                    (attrib, value) = line.split(":", maxsplit=1)
                except:
                    logging.error("can't parse line %s", line)
                    continue

                attrib = attrib.strip()
                if attrib.lower().startswith("iir"):
                    value = self.parse_biquad(value)
                else:
                    value = self.parse_value(value.strip())
                self.values[attrib] = value
コード例 #8
0
ファイル: settings.py プロジェクト: ssalonen/hifiberry-dsp
    def get_updates(self, xmlprofile):

        replace = {}

        for attribute in self.values:
            (addr, length) = xmlprofile.get_addr_length(attribute)

            if addr is None and attribute.startswith("0x"):
                # if it's not a setting form the profile, it might be
                # a memory address
                try:
                    addr = int(attribute, 16)
                    length = 1
                except:
                    logging.error("can't parse address %s", addr)
                    addr = None

            if addr is None:
                continue

            val = self.values[attribute]

            word_length = Adau145x.cell_len(addr)
            memory = self.param_to_bytes(val, length, word_length=word_length)

            if len(memory) <= self.dsp.cell_len(addr):
                replace[addr] = memory
            else:
                # Split long replaced into single words
                assert len(memory) % word_length == 0

                while len(memory) > 0:
                    cellvalue = memory[0:word_length]
                    replace[addr] = cellvalue
                    addr += 1
                    memory = memory[word_length:]

        return replace