Files
sizzletracker-android/ios/app/Host/SizzleMidi.h
T
ReactorcoremeltdownandClaude Opus 5.5 64e21e0bcc iOS 0.6.0: milestone 5 (recording, MIDI, input bindings, themes, bundles, backups)
- Master recording (MasterSink ring + writer thread) and the sample recorder
- CoreMIDI in/out: sound module, clock send/follow, virtual "Sizzle" ports;
  platform-free parser/module/clock in core (midi_test)
- Hardware keyboard and gamepads via GameController; rebindable keyboard,
  gamepad and MIDI CC actions; per-parameter MIDI learn
- Colour themes (.szt), project bundles (.szgz), backup & restore;
  ZIP in core with zlib (zip_test against jar and unzip)
- Persistent app settings; audio pauses in the background unless sound module

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 14:26:01 +01:00

64 lines
2.6 KiB
Objective-C

// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
#import <Foundation/Foundation.h>
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<NSString *> *)disabled;
@property (nonatomic, readonly) NSArray<SizzleMidiSource *> *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