iOS milestone 3 groundwork: SizzleSession bridge, app shell with tabs, slot-backed editors, screen snapshots
SizzleSession owns the song, engine (192-frame chunks, try-lock on the audio thread), samples and audio output; AppModel/RootView give the four tabs; DeviceModel now works on toolbox slots too; make screen-snapshots renders the app's tabs on the Mac. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7bc54e6466
commit
29650b88d7
@@ -0,0 +1,165 @@
|
||||
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// Posted on the main thread after anything in the song changed (edits, loads,
|
||||
/// transport). The Swift AppModel turns it into a SwiftUI refresh.
|
||||
extern NSNotificationName const SizzleSessionDidChange;
|
||||
|
||||
/// One tracker cell (model::Cell): note (0..127, -1 empty, -2 note-off),
|
||||
/// velocity (0..127), MIDI channel (0..16).
|
||||
typedef struct {
|
||||
int note;
|
||||
int velocity;
|
||||
int channel;
|
||||
} SizzleCell;
|
||||
|
||||
/// A device type the toolbox offers (from the generated specs).
|
||||
@interface SizzleDeviceType : NSObject
|
||||
@property (nonatomic, readonly) NSString *type; // ToolboxType name, "WAVETABLE"
|
||||
@property (nonatomic, readonly) NSString *displayName; // "Wavetable"
|
||||
@property (nonatomic, readonly) BOOL isInstrument;
|
||||
/// MIDI effects (arpeggiator, transposer, LFO) act on notes, not audio.
|
||||
@property (nonatomic, readonly) BOOL isMidiEffect;
|
||||
@end
|
||||
|
||||
/// One parameter of a device type (Android's ParamSpec).
|
||||
@interface SizzleParamSpec : NSObject
|
||||
@property (nonatomic, readonly) NSString *key;
|
||||
@property (nonatomic, readonly) NSString *label;
|
||||
@property (nonatomic, readonly) float defaultValue; // a choice index for lists
|
||||
@property (nonatomic, readonly) float minValue;
|
||||
@property (nonatomic, readonly) float maxValue;
|
||||
@property (nonatomic, readonly) BOOL isInt;
|
||||
@property (nonatomic, readonly) NSArray<NSString *> *choices; // empty for numbers
|
||||
@end
|
||||
|
||||
/**
|
||||
* The open song and the engine playing it: the iOS counterpart of the Android
|
||||
* app's Project + AudioEngine as AppViewModel holds them. Owns the C++ model
|
||||
* (core/include/sizzle/Model.hpp), the engine (Engine.hpp), the sample store and
|
||||
* the audio output (AVAudioEngine, rendering in 192-frame chunks like Android).
|
||||
*
|
||||
* Call from the main thread. Every change takes the song lock; the audio thread
|
||||
* only try-locks it (a block that meets an edit in progress plays silence instead
|
||||
* of waiting), so edits are always safe while playing.
|
||||
*/
|
||||
NS_SWIFT_UI_ACTOR
|
||||
@interface SizzleSession : NSObject
|
||||
|
||||
@property (class, nonatomic, readonly) SizzleSession *shared;
|
||||
|
||||
/// Bumped on every change (also announced with SizzleSessionDidChange).
|
||||
@property (nonatomic, readonly) NSUInteger revision;
|
||||
|
||||
#pragma mark - Song settings
|
||||
@property (nonatomic, copy) NSString *songName;
|
||||
@property (nonatomic) float tempo; // BPM
|
||||
@property (nonatomic) NSInteger signature; // index into signatureLabels
|
||||
@property (nonatomic) NSInteger scale; // index into scaleLabels
|
||||
@property (nonatomic) NSInteger rootNote; // 0..11
|
||||
@property (nonatomic) NSInteger activePattern; // pattern id 0..7
|
||||
@property (class, nonatomic, readonly) NSArray<NSString *> *signatureLabels; // "3/4", "4/4", "5/4"
|
||||
@property (class, nonatomic, readonly) NSArray<NSString *> *scaleLabels; // "Chromatic", …
|
||||
@property (nonatomic, readonly) NSInteger linesPerBeat;
|
||||
@property (nonatomic, readonly) NSInteger beatsPerBar;
|
||||
/// Pattern lengths the signature allows (lines), e.g. 16, 32, 64.
|
||||
@property (nonatomic, readonly) NSArray<NSNumber *> *lengthOptions;
|
||||
/// Pitch classes (0..11) in the song's scale and root.
|
||||
@property (nonatomic, readonly) NSArray<NSNumber *> *scalePitchClasses;
|
||||
|
||||
#pragma mark - Patterns (ids 0..7, 4 tracks)
|
||||
- (NSInteger)lengthOfPattern:(NSInteger)pattern;
|
||||
- (void)setLength:(NSInteger)lines ofPattern:(NSInteger)pattern;
|
||||
- (NSString *)nameOfPattern:(NSInteger)pattern;
|
||||
- (SizzleCell)cellInPattern:(NSInteger)pattern track:(NSInteger)track line:(NSInteger)line;
|
||||
- (void)setCell:(SizzleCell)cell inPattern:(NSInteger)pattern track:(NSInteger)track line:(NSInteger)line;
|
||||
|
||||
#pragma mark - Arrangement (8 lanes; a slot holds a pattern id, -1 empty, -2 note-off)
|
||||
- (NSInteger)arrangementLane:(NSInteger)lane beat:(NSInteger)beat;
|
||||
- (void)setArrangementLane:(NSInteger)lane beat:(NSInteger)beat pattern:(NSInteger)pattern;
|
||||
- (BOOL)isLaneMuted:(NSInteger)lane;
|
||||
- (void)setLane:(NSInteger)lane muted:(BOOL)muted;
|
||||
@property (nonatomic) BOOL arrangementLoop;
|
||||
@property (nonatomic) NSInteger arrangementBars;
|
||||
@property (nonatomic, readonly) NSInteger lastFilledBeat;
|
||||
/// Loop regions A (0) and B (1): enabled, start beat, end beat, repeats.
|
||||
- (BOOL)regionEnabled:(NSInteger)region;
|
||||
- (NSInteger)regionStart:(NSInteger)region;
|
||||
- (NSInteger)regionEnd:(NSInteger)region;
|
||||
- (NSInteger)regionRepeats:(NSInteger)region;
|
||||
- (void)setRegion:(NSInteger)region enabled:(BOOL)enabled start:(NSInteger)start end:(NSInteger)end repeats:(NSInteger)repeats;
|
||||
|
||||
#pragma mark - Transport (readable at display rate without the lock)
|
||||
- (void)play;
|
||||
- (void)playFromBeat:(NSInteger)beat;
|
||||
- (void)pause;
|
||||
- (void)stop;
|
||||
- (void)panic;
|
||||
@property (nonatomic, readonly) BOOL isPlaying;
|
||||
@property (nonatomic, readonly) NSInteger currentLine;
|
||||
@property (nonatomic, readonly) NSInteger currentBeat;
|
||||
|
||||
#pragma mark - Mixer (4 channels)
|
||||
- (NSInteger)instrumentSlotOfChannel:(NSInteger)ch;
|
||||
- (void)setInstrumentSlot:(NSInteger)slot ofChannel:(NSInteger)ch; // -1 none
|
||||
- (NSInteger)fxSlot:(NSInteger)i ofChannel:(NSInteger)ch;
|
||||
- (void)setFxSlot:(NSInteger)i to:(NSInteger)slot ofChannel:(NSInteger)ch; // -1 none
|
||||
- (NSInteger)midiChannelOfChannel:(NSInteger)ch;
|
||||
- (void)setMidiChannel:(NSInteger)midi ofChannel:(NSInteger)ch;
|
||||
- (float)volumeOfChannel:(NSInteger)ch;
|
||||
- (void)setVolume:(float)volume ofChannel:(NSInteger)ch;
|
||||
- (BOOL)isMuted:(NSInteger)ch;
|
||||
- (void)setChannel:(NSInteger)ch muted:(BOOL)muted;
|
||||
- (BOOL)isSolo:(NSInteger)ch;
|
||||
- (void)setChannel:(NSInteger)ch solo:(BOOL)solo;
|
||||
- (BOOL)hasLimiter:(NSInteger)ch;
|
||||
- (void)setChannel:(NSInteger)ch limiter:(BOOL)limiter;
|
||||
- (float)meterOfChannel:(NSInteger)ch;
|
||||
- (BOOL)clippedChannel:(NSInteger)ch;
|
||||
|
||||
#pragma mark - Toolbox (16 slots)
|
||||
@property (class, nonatomic, readonly) NSArray<SizzleDeviceType *> *deviceTypes;
|
||||
/// The slot's ToolboxType name, or "" when empty.
|
||||
- (NSString *)typeOfSlot:(NSInteger)slot;
|
||||
- (NSString *)nameOfSlot:(NSInteger)slot;
|
||||
- (void)fillSlot:(NSInteger)slot withType:(NSString *)type;
|
||||
- (void)clearSlot:(NSInteger)slot;
|
||||
- (NSString *)valueOfSlot:(NSInteger)slot key:(NSString *)key;
|
||||
- (void)setValue:(NSString *)value ofSlot:(NSInteger)slot key:(NSString *)key;
|
||||
/// A number, stored as Android stores it (Kotlin's Float.toString text).
|
||||
- (void)setNumber:(float)value ofSlot:(NSInteger)slot key:(NSString *)key;
|
||||
+ (NSArray<SizzleParamSpec *> *)paramSpecsForType:(NSString *)type;
|
||||
/// Factory preset names for a device type (Android's PresetLibrary set).
|
||||
- (NSArray<NSString *> *)factoryPresetsForType:(NSString *)type;
|
||||
- (void)applyFactoryPreset:(NSString *)name toSlot:(NSInteger)slot;
|
||||
|
||||
#pragma mark - Live notes (keyboard, MIDI): queued to the audio thread
|
||||
- (void)noteOn:(NSInteger)note velocity:(NSInteger)velocity midiChannel:(NSInteger)channel;
|
||||
- (void)noteOff:(NSInteger)note midiChannel:(NSInteger)channel;
|
||||
- (void)auditionSlot:(NSInteger)slot note:(NSInteger)note on:(BOOL)on;
|
||||
|
||||
#pragma mark - Songs (Documents/songs/*.szg, the Android project format)
|
||||
@property (nonatomic, readonly) NSArray<NSString *> *songNames;
|
||||
- (BOOL)saveSongNamed:(NSString *)name error:(NSError **)error;
|
||||
- (BOOL)loadSongNamed:(NSString *)name error:(NSError **)error;
|
||||
- (BOOL)deleteSongNamed:(NSString *)name error:(NSError **)error;
|
||||
- (void)newSong;
|
||||
/// The song in the Android project format (.szg) / desktop format (.sng).
|
||||
- (NSString *)projectText;
|
||||
- (NSString *)sngText;
|
||||
- (BOOL)loadProjectText:(NSString *)text error:(NSError **)error;
|
||||
- (BOOL)importSngText:(NSString *)text error:(NSError **)error;
|
||||
/// Saved on backgrounding and restored at launch (Documents/autosave.szg).
|
||||
- (void)autosave;
|
||||
|
||||
#pragma mark - Samples
|
||||
/// A WAV into a Sampler pad / an SF2, XI or WAV into the SF2/XI loader.
|
||||
- (BOOL)loadSampleData:(NSData *)data name:(NSString *)name intoSlot:(NSInteger)slot pad:(NSInteger)pad error:(NSError **)error;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Reference in New Issue
Block a user