// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown // SPDX-License-Identifier: GPL-3.0-or-later #import NS_ASSUME_NONNULL_BEGIN /// One MIDI source as Setup lists it. [key] is stable across launches (what the /// device says about itself), so the on/off choice can be saved. @interface SizzleMidiSource : NSObject @property (nonatomic, readonly) NSString *key; @property (nonatomic, readonly) NSString *name; @property (nonatomic, readonly) BOOL enabled; @property (nonatomic, readonly) BOOL connected; @end /** * CoreMIDI for Sizzle (Android's MidiInput + MidiSoundModule + MidiClock): * * IN: every MIDI source (USB, Bluetooth, network, other apps) is listened to unless * switched off, plus Sizzle's own virtual destination ("Sizzle") that other apps * can send to. Each source has its own byte parser. Notes play the mixer tracks * listening on their channel straight from the MIDI thread (queued to the audio * thread, no UI in the path); CC 123/120 release a channel. Real-time bytes follow * an external clock (tempo, Start/Stop) while [receiveClock] is on. * * OUT: while [sendClock] is on and the song plays, a thread sends the clock (24 * PPQN), Start/Stop, and the sequenced notes to every destination and through * Sizzle's virtual source. * * The blocks are called on the main thread. */ NS_SWIFT_UI_ACTOR @interface SizzleMidi : NSObject @property (class, nonatomic, readonly) SizzleMidi *shared; /// Create the client and ports and connect the enabled sources. Idempotent. - (void)startWithDisabledKeys:(NSSet *)disabled; @property (nonatomic, readonly) NSArray *sources; - (void)setSourceKey:(NSString *)key enabled:(BOOL)enabled; /// Disconnect and connect every enabled source again. - (void)reconnect; /// Release every note the sources hold (panic). - (void)releaseAll; @property (nonatomic) BOOL sendClock; @property (nonatomic) BOOL receiveClock; /// Sound-module mode: an external clock's Start/Stop no longer start or stop the song. @property (nonatomic) BOOL soundModule; /// A note the module played or released (channel 1..16), for held keys and punch-in. @property (nonatomic, copy, nullable) void (^onNote)(BOOL on, NSInteger channel, NSInteger note, NSInteger velocity); /// A Control Change the module didn't consume (bindings, MIDI learn): value 0..127. @property (nonatomic, copy, nullable) void (^onControl)(NSInteger cc, NSInteger value); /// The source list changed. @property (nonatomic, copy, nullable) void (^onSourcesChanged)(void); /// A tempo taken from an external clock was applied. @property (nonatomic, copy, nullable) void (^onTempoFollowed)(float bpm); @end NS_ASSUME_NONNULL_END