Skip to content

Commit

Permalink
chore: refactor injecting midiController
Browse files Browse the repository at this point in the history
  • Loading branch information
tillt committed Dec 9, 2023
1 parent 51401d1 commit 7adc34e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
4 changes: 4 additions & 0 deletions KompleteSynthesia/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ @interface AppDelegate ()
@property (nonatomic, strong) MIDI2HIDController* midi2hidController;
@property (nonatomic, strong) VideoController* videoController;
@property (nonatomic, strong) HIDController* hidController;
@property (nonatomic, strong) MIDIController* midiController;
@property (nonatomic, strong) LogViewController* log;
@property (nonatomic, strong) SynthesiaController* synthesia;
@property (nonatomic, strong) PreferencesWindowController* preferences;
Expand Down Expand Up @@ -158,9 +159,12 @@ - (void)applicationDidFinishInitializingWithSynthesiaRunning
NSError* error = nil;

_hidController = [[HIDController alloc] init];

_midiController = [[MIDIController alloc] init];

_midi2hidController = [[MIDI2HIDController alloc] initWithLogController:_log
hidController:_hidController
midiController:_midiController
delegate:self];
if (_midi2hidController == nil) {
[[NSAlert alertWithError:error] runModal];
Expand Down
1 change: 1 addition & 0 deletions KompleteSynthesia/MIDI2HIDController.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ typedef enum colorMapState {

- (id)initWithLogController:(LogViewController*)lc
hidController:(HIDController*)hc
midiController:(MIDIController*)mc
delegate:(id)delegate;

- (BOOL)resetWithError:(NSError**)error;
Expand Down
7 changes: 4 additions & 3 deletions KompleteSynthesia/MIDI2HIDController.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ @implementation MIDI2HIDController {
unsigned char colorMap[kColorMapSize];
}

- (id)initWithLogController:(LogViewController*)lc hidController:(HIDController*)hc delegate:(id)delegate
- (id)initWithLogController:(LogViewController*)lc hidController:(HIDController*)hc midiController:(MIDIController*)mc delegate:(id)delegate
{
self = [super init];
if (self) {
Expand Down Expand Up @@ -90,8 +90,9 @@ - (id)initWithLogController:(LogViewController*)lc hidController:(HIDController*

hid = hc;
hid.delegate = self;

midi = [[MIDIController alloc] initWithDelegate:self];

midi = mc;
midi.delegate = self;
}

return self;
Expand Down
1 change: 0 additions & 1 deletion KompleteSynthesia/MIDIController.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ extern const int kMIDIConnectionInterfaceKeyboard;
@property (nonatomic, copy) NSString* status;

+ (NSString*)readableNote:(unsigned char)note;
- (id)initWithDelegate:delegate;
- (BOOL)setupWithError:(NSError**)error;
@end

Expand Down
9 changes: 0 additions & 9 deletions KompleteSynthesia/MIDIController.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@ + (NSString*)OSStatusString:(int)status
return message;
}

- (id)initWithDelegate:(id)delegate
{
self = [super init];
if (self) {
_delegate = delegate;
}
return self;
}

- (BOOL)setupWithError:(NSError**)error
{
__weak MIDIController* weakSelf = self;
Expand Down

0 comments on commit 7adc34e

Please sign in to comment.