Code structure - loudifier/chirplab GitHub Wiki
Chirplab Code Structure
This section of the wiki is not intended as an API reference or docstring dumping ground, rather as a high level overview of the Chirplab codebase, explaining how the various files are split up and where a particular piece of functionality lives if you would like to make a modification or add a new measurement type.
The main blocks that make up Chirplab are:
chirplab.py
chirplab.py
serves as the entry point into both the GUI and command-line interfaces for Chirplab. It initializes global state, loading or creating a new project, initializing measurement objects, and calculating initial measurement results. If command-line parameters are passed into chirplab.py
(or the bundled .exe or equivalent), chirplab.py
processes commands, generating stimulus files, or saving measurement data as specified. If no parameters (or only a project file) are passed in, chirplab.py
launches the MainWindow
GUI.
CLProject
CLProject
is a module primarily for defining and sharing global constants and state throughout Chirplab. Actual code execution is minimal and limited to managing (loading from/saving to file, or creating a new) project
dict that contains the main chirp signal and analysis parameters, calibration values, measurements list and parameters, etc.
CLMeasurements
The CLMeasurements
module includes the CLMeasurement
base class and individual measurement subclasses that are available for processing with Chirplab. CLMeasurement
defines the methods that are required for all measurements (and default behaviors, where possible). Measurement subclasses override and add methods as needed to initialize measurement parameters, implement the actual measurement calculations, save data outputs, and define elements that are used for configuring measurement parameters in the GUI.
CLAnalysis
The CLAnalysis
module is a general collection of helper functions, ranging from reading and writing audio files, generating logchirps, finding the time alignment between two signals (for detecting and aligning response to stimulus), converting logchirp times to frequencies and vice versa, etc.
CLGui
The CLGui
module contains almost all code that defines GUI elements and functionality in Chirplab, excluding measurement-specific elements.