Skip to content

Metronome

MetronomeIn

MetronomeIn(
    name_or_bpm: str | float,
    bpm: float = 60,
    *,
    msg_to_send: Msg = Msg("Click")
)

Bases: Input

The input port that sends messages with set interval

Notes

Metronome sets extra bpm and number attributes to any message it sends

Overloads:

MetronomeIn(name: str, bpm: float = 60, msg_to_send: Msg = Msg('Click'))
MetronomeIn(bpm: float, *, msg_to_send: Msg = Msg('Click'))

Parameters:

  • name (str) –

    Metronome name

  • bpm (float, default: 60 ) –

    Message sending interval in beats per minute

  • msg_to_send (Msg, default: Msg('Click') ) –

    Message the port will send

is_enabled

is_enabled: bool

True if port is listening and generating messages

calls

calls: list[None | tuple[tuple, dict], list[SubscribedCall]]

Message match arguments and callables that will be called with matching incoming messages. None conditions matches any message.

bpm

bpm: float

Message sending interval in beats per minute.

subscribe

subscribe(
    *msg_matches_args: None | Container[Any] | Any,
    **msg_matches_kwargs: (str, None | Container[Any] | Any)
) -> Callable

Decorator to subscribe a callable to the input's messages.

Decorator without arguments subscribes a callable to all the input's messages.

Decorator with arguments subscribes a callable to the input's messages that match conditions set by arguments. It works the same way as message's matches method:

  1. If condition is None or omitted it matches anything.

  2. If condition equals attribute it matches the attribute.

  3. If condition is a container and contains the attribute it matches the attribute.

Examples
  1. Calls function for all MIDI port's messages:
    @midi_input_instance.subscribe
    def function(msg: MidiMsg) -> None:
        pass
    
  2. Calls function for OSC messages from specific address:
    @osc_input_instance.subscribe(address='/live/song/get/track_data')
    def function(msg: OscMsg) -> None:
        pass
    
  3. Call object instance method for MIDI port's "note on" and "note off" messages:
    midi_input_instance.subscribe((MidiType.NOTE_ON, MidiType.NOTE_OFF))(object.method)
    

Returns:

  • Callable

    Subscribed callable.