2022年3月2日 星期三

SigmaDsp Agents - Object Hierarchy


A top-level view of object hierarchy

Items in yellow color below are the main object classes in my package.
  • Dsp hardware-related:
    • ADAU1401: represents the hardware chip. We operate hardware functions through this object. 
    • Messages: data in EEPROM is organized in "Message" format, which can be operated through this object.
  • SigmaStudio related:
    • IC: there will be a *.xml file when you export your SigmaStudio project, which contains the following data, we can operate with the "IC" object.
      • parameter RAM data 
      • program RAM data
      • control registers data
    • Cell: represents SigmaStudio cells, like SineTone, VolumeControl, Filters..., we can operate DSP functions in real-time through the "Cell" object.
  • Factory: this object gets whatever you need for you. Start here. 

Top-level view of object hierarchy



Object hierarchy of ADAU1401

class ADAU1401 actually contains several sub-classes, most importantly are Control, RAM, and EEPROM. 
Object hierarchy of ADAU1401



class ADAU1401

Object ADAU1401 holds a copy of registers data in memory and synchronizes with hardware registers when needed. 

Important methods:
  • enable/toggle/mute: enable/disable output.
  • start/stop/close/pause/resume: actually equvilant with enable/disable/mute.
  • read/write_accress_bytes: I2C read/write data from and to any address of ADAU1401 address space. 
  • read/write_parameter: "Parameter" is a data wrapper object. These two functions operate Parameter and call "read/write_accress_bytes" functions to access hardware. 
  • load_registers: load registers configuration data from a list to PC's memory.
  • registers_values: current registers values held in PC's memory.
  • write_all_registers/update: write registers value from PC's memory to hardware.
  • read_all_registers: read registers value from hardware to PC's memory.
  • print: print a report of all registers' values.

Important methods of class ADAU1401



class Control

Important methods:
  • "Message" related:
    • messages_from_bytes: parse data bytes into a collection of "Message" objects. 
    • write_message: write a "Message" to hardware.
  • XML related:
    • write_xml_ic: read SigmaStudio project XML file and re-write the whole configuration (program, parameters).
  • Text file related:
    • load_SigmStudio_files: load SigmaStudio files and re-write the whole configuration (program, parameters).
  • EEPROM related:
    • load_eeprom_from_file: load data of EEPROM from a binary file.
    • dump_eeprom_to_file: dump data of EEPROM to a binary file.
    • reload_from_eeprom: re-write the whole configuration (program, parameters, control registers), equivalent to software reset.
Important methods of class Control




Important methods:    

    "RAM" is the base class, which has:
  • read/write: read/write data from and to any address of ADAU1401's memory space. 
  • to_file/from_file: dump to and load from binary files.
    Program RAM (inherit RAM):
  • read/write: inherit RAM's function.
   Parameter RAM (inherit RAM):
  • read/write_parameter: actually delegate to ADAU1401's functions.
  • safe_load: safe load a single 4 bytes parameter.
  • safe_loads: safe load up to five parameters at once.
  • read/write: inherit RAM's function.
   EEROM (inherit RAM):
  • messages: pack the data of EEPROM into "Messages".
  • read/write: inherit RAM's function.
Important methods of class RAM and EEPROM




"Messages" is just a collection of many "Message".

Important methods:  
  • from_bytes: parse data bytes into a "Message".
  • messages_from_bytes:
  • messages_from_SigmStudio_files: load SigmaStudio text data files into "Messages".
Important methods of class Message and Messages




The project's XML file you export from SigmaStudio contains descriptions of :
  • IC: hardware's part number...
  • Module: corresponds to SigmaStudio's Cell (like SineTone...), contains one or many Algorithms.
  • Algorithm: descript which algorithm should be used.
  • Parameter: contains parameters' value/type/address. parameters are stored in hardware's parameter RAM space and are used to manipulate DSP hardware's behavior.

Top view of  XML-related object hierarchy

Important methods and properties:  
  • df: a Pandas DataFrame report of parameters configuration. You need Pandas installed to show the report.
  • Parameter:
    • set_value: set a value, if the parameter is a 4 bytes parameter.
    • set_numbers: set a list of values at once. if the parameter contains n values, in turn, has 4 x n bytes.
    • numbers: get a list of values from a parameter, which contains n values, in turn, has 4 x n bytes.
    • to_integer: force into integer.
    • to_float: force into float.

Important methods of XML-related classes



SigmaStudio Toolbox Cell related classes

Important methods and properties:  
  • df: a Pandas DataFrame report of parameters configuration. You need Pandas installed to show the report.:
  • get_param/set_param: read/write and synchronize a parameter's data with hardware.
  • get_parameters_values/set_parameters_values: synchronize many parameters' data at once.
  • read_parameter/write_parameter: read/write a "Parameter" object data from/to hardware (delegated to ADAU1401 object).
  • show_methods: show a report of a Cell's methods signature.
Important methods of Cell-related classes


class Factory

Important methods and properties:  
  • get_ic: read and wrap project XML file into an "IC" object.
  • get_cells: get all the "Cell" objects of a SigmaStudio project. A "Cell" has methods (like set_frequency...) with which we can control Dsp behavior.
  • get_cell_by_name: get a "Cell" object by name.
  • get_cells_manifest: generate a script for embodying Cell objects 
  • show_methods: show a report of every Cell's methods signature in a SigmaStudio project.
  • save_parameters_to_eeprom: save current parameters' value to EEPROM.
Important methods of class Factory