exercise4.py sample code¶
The exercise4.py
script is a PyQt5 application for live performance of a set
of stepper-motor driven sculptures. This iteration features an example
scripting interface for running a performance sequencer as separate thread. It
can also use simulated or physical MIDI input as events to drive an
Arduino-based stepper system connected via a serial port. It includes a basic
interface to a four-channel DMX controller. It includes hooks for MIDI and OSC
output for extending the performance across the network.
The script and libraries are packaged as exercise4.zip.
The script is capable of driving up to 16 motors, four per driver, up to four drivers. The example user interfaces allows driving eight motors at a time from the MPD218 4x4 pad interface, with the second set available on Pad Bank B. Two pads each send forward/backward step commands.
Design Documentation¶
The specific implementation is an attempt to satisfy a number of design constraints:
support offline simulated operation for code debugging
support scripting commands over OSC networking
provide hooks for state machine motion generators
provide hooks for procedural motion primitives
provide hooks for data-driven choreography
A few features of note:
The
MotionPrimitives
class provides a prototype for state-machine generators; it is instantiated in MainApp as self.primitives.The
script.ex4demo
module provides a prototype for procedural scripting; the script is instantiated in MainApp as self.script.
Motion Primitives¶
The movement notation is encoded as operator messages expressed as Python tuples in which the first value is a keyword. These are essentially function calls with no return values (i.e purely for side-effects) which may be passed in message queues or over network messages.
Motion primitives |
|
(‘pose’, name) |
Move to named pose. |
(‘random’, boolean) |
Enable or disable the random movement generator. |
Parametric primitives |
|
(‘gains’, freq, damping) |
Set all channels to the given parameters. |
(‘tempo’, bpm) |
Set the global tempo in beats per minute. |
(‘magnitude’, factor) |
Set the global scaling factor. |
Code Documentation¶
A show control system with GUI.
-
class
exercise4.
AppWindow
(main)[source]¶ A custom main window which provides all GUI controls. This generally follows a model-view-controller convention in which this window provides the views, passing events to the application controller via callbacks.
-
apply_user_configuration
(config)[source]¶ Apply the persistent configuration values from a configparser section proxy object.
-
connect_callbacks
()[source]¶ Finish initializing the GUI by connecting all callbacks from GUI elements to application controller methods. This allows the log window to be set up early to capture any messages from the initialization of other object.
-
gather_configuration
(config)[source]¶ Update the persistent configuration values in a configparser section proxy object.
-
scriptCommandEntered
()[source]¶ Callback invoked whenever command line text is entered on the script tab.
-
-
class
exercise4.
MainApp
[source]¶ Main application controller object holding any non-GUI related state.
-
app_has_started
()[source]¶ Callback to be invoked right after the main event loop begins. This may be extended in child classes to implement startup behaviors which require a running event loop.
-
app_is_exiting
()[source]¶ Callback invoked right before the program ends, either from a keyboard interrupt window close. This may be extended in child classes to clean up external resources, e.g., close any serial ports to remove associated lock files.
-
dmx_slider_change
(channel, value)[source]¶ Callback invoked when a DMX channel strip slider is moved.
-
-
class
exercise4.
MotionPrimitives
(main)[source]¶ Class to encapsulate the set of motion primitives available for this performance. This also abstracts the basic interface to both motor and simulation and supports periodic execution.