keyboard_input¶
Keyboard input.
Let’s play live with either a MIDI keyboard or our QWERTY keyboard.
Invoke with:
josephine@laptop:~/supriya$ python -m examples.keyboard_input --help
usage: __main__.py [-h] (--list-midi-inputs | --use-midi PORT_NUMBER |
--use-qwerty)
Play notes via your QWERTY or MIDI keyboards
options:
-h, --help show this help message and exit
--list-midi-inputs list available MIDI inputs
--use-midi PORT_NUMBER
play via MIDI keyboard
--use-qwerty play via QWERTY keyboard
… to see complete options.
See the example documentation for a complete explanation.
- class MidiHandler(port: int | str)¶
Bases:
InputHandler
A MIDI input handler.
- class NoteOff(note_number: int)¶
Bases:
object
A note off event.
- class PolyphonyManager(server: ~supriya.contexts.core.Context, notes: dict[int, ~supriya.contexts.entities.Synth] = <factory>, synthdef: ~supriya.ugens.core.SynthDef = <SynthDef: supriya:default>, target_node: ~supriya.contexts.entities.Node | None = None, add_action: ~supriya.enums.AddAction = AddAction.ADD_TO_HEAD)¶
Bases:
object
A polyphony manager.
Translates
NoteOn
orNoteOff
events into actions against aContext
.
- class QwertyHandler(octave: int = 5, presses_to_note_numbers: dict[str, int] = <factory>)¶
Bases:
InputHandler
A QWERTY input handler.
- listen(callback: Callable[[NoteOn | NoteOff], None]) Generator[None, None, None] ¶
Context manager for listening to QWERTY input events.
- on_press(callback: Callable[[NoteOn | NoteOff], None], key: Key | KeyCode | None) None ¶
Handle a QWERTY key press.
- run(input_handler: InputHandler) None ¶
Run the script.