demo1.py sample code

The demo1.py script is derived from exercise5.py with additional support for output to a DXM interface over a serial port. The script and libraries are packaged as demo1.zip. The individual files can be browsed at demo1.py and kf.

The notable differences from exercise5.py are the DMX functions in demo1.ControlLogic and the kf.dmx.QtDMXUSBPro.

The user interface is much the same as we’ve been using, except switching the knobs to bank C will allow direct control of the first six color channels.

A show control system with GUI.

class demo1.ControlLogic[source]

Core performance logic for processing MIDI input into winch commands.

channel_pressure(channel, pressure)[source]

Process a MIDI Channel Pressure event.

connect_display(display)[source]

Attach a console status output device to the performance logic.

connect_dmx(dmx)[source]

Attach a dmx output device to the performance logic.

connect_osc_sender(sender)[source]

Attach a OSC sender port to the performance logic.

connect_winches(winches)[source]

Attach a winch output device to the performance logic, either physical or simulated.

control_change(channel, cc, value)[source]

Process a MIDI Control Change event.

dmx_remote_update(fixture, color)[source]
dmx_slider_change(channel, value)[source]
metronome_tick()[source]

Callback invoked at regular intervals governed by the metronome timer. In this particular example, the metronome can trigger a regular series of alternating forward and back movements to excite the path generator oscillators.

mpd218_knob_bank_a(knob, value)[source]
mpd218_knob_bank_c(knob, value)[source]
note_off(channel, key, velocity)[source]

Process a MIDI Note Off event.

note_on(channel, key, velocity)[source]

Process a MIDI Note On event.

set_metronome_tempo(tempo)[source]

Adjust the metronome timer rate. N.B. the underlying Qt QTimer accepts intervals in milliseconds, so this is fairly precise for beats but will be approximate for small subdivisions. E.g. a 120 BPM timer at 500 ms is precise, but the 32nd note subdivision at 62.5 ms would be rounded to 62 ms and run about 1% slow.

Parameters:tempo – tempo in BPM
update_DMX_color_display(channel, value)[source]

Map a DMX channel update to a specific simulated fixture based on the current hardware.

class demo1.MainApp[source]

Main application controller object holding any non-GUI related state.

class demo1.OutputPatcher[source]

This object routes winch output commands to one or more streams. E.g. it can duplicate outputs to both a serial port winch and a simulation.

add_output(output)[source]
increment_target(axis, offset)[source]
set_freq_damping(axis, freq, ratio)[source]
set_target(axis, position)[source]
set_velocity(axis, velocity)[source]
class demo1.SimWindow[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.

closeEvent(event)[source]

Qt callback received before windows closes.

connect_close_handler(handler)[source]

Connect a callback to be invoked when the window is about to close.

connect_control_logic(logic)[source]

Connect an object to receive synthetic MIDI events; the object is assumed to have MIDIProcessor methods.

connect_dmx(dmx)[source]

Connect a serial dmx output to the port configuration control.

connect_midi_listener(listener)[source]

Connect a MIDI input listener to the port configuration control.

connect_osc_listener(listener)[source]

Connect an OSC network listener to the port configuration control.

connect_osc_sender(sender)[source]

Connect an OSC network sender to the port configuration control.

connect_winch(winch)[source]

Connect a serial winch output to the port configuration control.

set_status(string)[source]

Update the status bar at the bottom of the display to show the provided string.