Changes

Jump to navigation Jump to search
Line 21: Line 21:  
== The Zynthian code entry point ==
 
== The Zynthian code entry point ==
    +
=== zynthian.sh ===
 
/zynthian/zynthian-ui/zynthian.sh
 
/zynthian/zynthian-ui/zynthian.sh
    +
==== Defines ====
 
This file defines a few functions
 
This file defines a few functions
   Line 44: Line 46:  
Quite how a specific environment file is exposed to this process depends on the config, so mechanisms like MIDI configs define these states depending on whether or not a user has defined their own specific MIDI configuration or indeed several. Zynthian is basically a device for starting and stopping jack instruments and interacting with the engines once they are running.
 
Quite how a specific environment file is exposed to this process depends on the config, so mechanisms like MIDI configs define these states depending on whether or not a user has defined their own specific MIDI configuration or indeed several. Zynthian is basically a device for starting and stopping jack instruments and interacting with the engines once they are running.
 
The GUI controls those interactions.
 
The GUI controls those interactions.
 +
 +
==== Commands ====
 
So the lines in the zynthian.sh file that start up the python elements are :
 
So the lines in the zynthian.sh file that start up the python elements are :
   Line 56: Line 60:     
We then start up the python file zynthian_main.py
 
We then start up the python file zynthian_main.py
 +
 +
=== zynthian_main.py ===
 +
 
This is a small file that acts as an entry point to the zyngui object that is the base of all gui zynthian objects.
 
This is a small file that acts as an entry point to the zyngui object that is the base of all gui zynthian objects.
   −
 
+
==== imports ====
 
  # Zynthian specific modules
 
  # Zynthian specific modules
 
  from zyngui import zynthian_gui_config
 
  from zyngui import zynthian_gui_config
Line 65: Line 72:  
  from zyngui import zynthian_gui_keybinding
 
  from zyngui import zynthian_gui_keybinding
    +
And then start up the zynth.
 +
 +
==== Starting ====
 +
 +
logging.info("STARTING ZYNTHIAN-UI ...")
 +
zynthian_gui_config.zyngui = zyngui = zynthian_gui()
 +
zyngui.create_screens()
 +
zyngui.run_start_thread()
 +
 +
The zynthian configuration data is imported as zyngui, zynthian_gui and zynthian_gui_config.zyngui. They are all the same global python object. You keep the number of globals down to an absolute minimum and restrict yourself to objects. zyngui as it will hence forth be known is the Global Python object that the Zynthians GUI hangs off.
 +
 +
== Zynthian Objects ==
 +
 +
{| class="wikitable"
 +
|+ Caption text
 +
|-
 +
! Zynthian Object !! Object Definition File !! Object Name
 +
|-
 +
| zyngui || zyngui.zynthian_gui || zynthian_gui
 +
|-
 +
| Example || Example || Example
 +
|-
 +
| Example || Example || Example
 +
|}
 +
 +
=== zyngui ===
 +
 +
Defined in the module zyngui/zynthian_gui.py as zynthian_gui but used as the global variable zyngui.
 +
 +
Firstly, virtually the entire zynthian universe is imported in about the first one hundred lines defining 80 or so base python namespaces.
 +
 +
Everything from the zynseq to brightness_config including the links to the C libraries that actually do the work as lib_zyncore, the zynengine objects that wrap the audio and MIDI devices and the many components used by the GUI screen.
    +
It also defines the threads that respond to the various events that occur within  the GUI environment and the various devices connected to the zynthian like Keyboards both musical and QWERTY, mice and all manner of MIDI paraphernalia.
    +
Then the zynthian_gui Object is defined.
 +
==== Functions ====
 +
===== create_screens =====
 +
The zynautoconnector is started which establishes the jack client connection to the Jack Server that does all the actual audio and midi processing, and runs this in it's own thread and handles the locking to ensure components play nice.
   −
/zynthian/zynthian-ui/zynthian_gui.py
+
The global references for the audio recorder, the mixer and the sequencer are instantiated from there modules
 +
{| class="wikitable"
 +
|+ Caption text
 +
|-
 +
! object !! module !! function
 +
|-
 +
| self.audio_recorder || zyngui/zynthian_audio_recorder || Audio Recorder
 +
|-
 +
| self.zynmixer || zynthian_engine_audio_mixer || Mixer
 +
|-
 +
| self.zynseq || zynlibs/zynseq || Sequencer
 +
|}
   −
This module primarily defines the zynthian_gui class object with a few tkinter helper functions
+
A dictionary called screens is defined and this has string keys that points to the individually defined screen objects that display the appropriate screens is defined and the value of the dictionary si set to the instantiated object from the .zyngui modules.
and this is what actually handles all the GUI interaction and functionality.
     −
It's about 2000 lines of code and after all this definition
+
# Create Core UI Screens
 +
self.screens['info'] = zynthian_gui_info()
 +
self.screens['splash'] = zynthian_gui_splash()
 +
self.screens['loading'] = zynthian_gui_loading()
 +
self.screens['confirm'] = zynthian_gui_confirm()
 +
....
   −
At line 1775 or there abouts we get
+
The main menu is set depending on the zynthian kit...
 
  −
* logging.info("STARTING ZYNTHIAN-UI ...")
  −
Always good to log and use the python logging infrastructure.
  −
* zynthian_gui_config.zyngui=zyngui=zynthian_gui()
     −
Some name binding for maintaining different names spaces or some possibly more nefereous purpose, before running
+
and the zynthian device manager is instantiated.
* zyngui.start()
     −
This method of the zynthian_gui class configures the GUI environment ready to start.
+
Then the threads and polling mechanisms are started .
584

edits

Navigation menu