2016-05-25 02:00:22 +00:00
|
|
|
#import <AppKit/AppKit.h>
|
|
|
|
#import <AudioUnit/AudioUnit.h>
|
|
|
|
#import <CoreAudioKit/AUViewController.h>
|
|
|
|
#import "AudioUnitViewController.hpp"
|
|
|
|
|
2016-05-26 01:28:50 +00:00
|
|
|
@interface MainView : NSView
|
|
|
|
{
|
|
|
|
AudioUnitViewController* amuseVC;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation MainView
|
|
|
|
|
|
|
|
|
|
|
|
- (id)initWithFrame:(NSRect)frameRect
|
|
|
|
{
|
|
|
|
self = [super initWithFrame:frameRect];
|
|
|
|
if (!self)
|
|
|
|
return nil;
|
|
|
|
amuseVC = [[AudioUnitViewController alloc] initWithNibName:nil bundle:nil];
|
|
|
|
[self addSubview:amuseVC.view];
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)translatesAutoresizingMaskIntoConstraints
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2016-05-25 02:00:22 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface ViewController : NSViewController
|
|
|
|
{
|
2016-05-26 01:28:50 +00:00
|
|
|
NSWindow* _window;
|
2016-05-25 02:00:22 +00:00
|
|
|
NSButton* playButton;
|
|
|
|
}
|
2016-05-26 01:28:50 +00:00
|
|
|
@end
|
2016-05-25 02:00:22 +00:00
|
|
|
|
2016-05-26 01:28:50 +00:00
|
|
|
@interface AppDelegate : NSObject <NSApplicationDelegate>
|
|
|
|
{
|
|
|
|
NSWindow* mainWindow;
|
|
|
|
ViewController* containerVC;
|
|
|
|
}
|
2016-05-25 02:00:22 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation ViewController
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
2016-05-25 05:49:48 +00:00
|
|
|
[super viewDidLoad];
|
2016-05-25 02:00:22 +00:00
|
|
|
#if 0
|
2016-05-25 05:49:48 +00:00
|
|
|
AudioComponentDescription desc;
|
|
|
|
/* Supply the correct AudioComponentDescription based on your AudioUnit type, manufacturer and creator.
|
2016-05-26 01:28:50 +00:00
|
|
|
|
2016-05-25 05:49:48 +00:00
|
|
|
You need to supply matching settings in the AUAppExtension info.plist under:
|
2016-05-26 01:28:50 +00:00
|
|
|
|
2016-05-25 05:49:48 +00:00
|
|
|
NSExtension
|
|
|
|
NSExtensionAttributes
|
|
|
|
AudioComponents
|
|
|
|
Item 0
|
|
|
|
type
|
|
|
|
subtype
|
|
|
|
manufacturer
|
2016-05-26 01:28:50 +00:00
|
|
|
|
2016-05-25 05:49:48 +00:00
|
|
|
If you do not do this step, your AudioUnit will not work!!!
|
|
|
|
*/
|
|
|
|
desc.componentType = kAudioUnitType_MusicDevice;
|
|
|
|
desc.componentSubType = 'sin3';
|
|
|
|
desc.componentManufacturer = 'Demo';
|
|
|
|
desc.componentFlags = 0;
|
|
|
|
desc.componentFlagsMask = 0;
|
2016-05-26 01:28:50 +00:00
|
|
|
|
2016-05-25 05:49:48 +00:00
|
|
|
[AUAudioUnit registerSubclass: AUv3InstrumentDemo.class asComponentDescription:desc name:@"Local InstrumentDemo" version: UINT32_MAX];
|
2016-05-26 01:28:50 +00:00
|
|
|
|
2016-05-25 05:49:48 +00:00
|
|
|
playEngine = [[SimplePlayEngine alloc] initWithComponentType: desc.componentType componentsFoundCallback: nil];
|
|
|
|
[playEngine selectAudioUnitWithComponentDescription2:desc completionHandler:^{
|
|
|
|
[self connectParametersToControls];
|
|
|
|
}];
|
2016-05-25 02:00:22 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)loadView {
|
2016-05-26 01:28:50 +00:00
|
|
|
self.view = [[MainView alloc] initWithFrame:[_window contentRectForFrameRect:_window.frame]];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id)initWithWindow:(NSWindow*)window
|
|
|
|
{
|
|
|
|
self = [super initWithNibName:@"AmuseContainerMainMenu" bundle:nil];
|
|
|
|
if (!self)
|
|
|
|
return nil;
|
|
|
|
_window = window;
|
|
|
|
return self;
|
2016-05-25 02:00:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation AppDelegate
|
|
|
|
|
2016-05-26 01:28:50 +00:00
|
|
|
- (void)applicationDidFinishLaunching:(NSNotification*)notification
|
|
|
|
{
|
|
|
|
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints"];
|
|
|
|
|
|
|
|
/* App menu */
|
|
|
|
#if 0
|
|
|
|
[NSMenu alloc] ini
|
|
|
|
NSMenu* rootMenu = [[NSMenu alloc] initWithTitle:@"main"];
|
|
|
|
NSMenu* appMenu = [[NSMenu alloc] initWithTitle:@"Amuse"];
|
|
|
|
NSMenuItem* quitItem = [appMenu addItemWithTitle:@"Quit Amuse"
|
|
|
|
action:@selector(quitApp:)
|
|
|
|
keyEquivalent:@"q"];
|
|
|
|
[quitItem setKeyEquivalentModifierMask:NSCommandKeyMask];
|
|
|
|
[[rootMenu addItemWithTitle:@"Amuse"
|
|
|
|
action:nil keyEquivalent:@""] setSubmenu:appMenu];
|
|
|
|
[[NSApplication sharedApplication] setMainMenu:rootMenu];
|
|
|
|
|
|
|
|
NSRect mainScreenRect = [[NSScreen mainScreen] frame];
|
|
|
|
mainWindow = [[NSWindow alloc] initWithContentRect:NSMakeRect(mainScreenRect.size.width / 2 - 100,
|
|
|
|
mainScreenRect.size.height / 2 - 150, 200, 300)
|
|
|
|
styleMask:NSClosableWindowMask|NSTitledWindowMask
|
|
|
|
backing:NSBackingStoreBuffered
|
|
|
|
defer:YES];
|
|
|
|
[mainWindow setTitle:@"Amuse"];
|
|
|
|
[[mainWindow windowController] setShouldCascadeWindows:NO];
|
|
|
|
[mainWindow setFrameAutosaveName:@"AmuseDataWindow"];
|
|
|
|
containerVC = [[ViewController alloc] initWithWindow:mainWindow];
|
|
|
|
[mainWindow setContentViewController:containerVC];
|
|
|
|
[mainWindow makeKeyAndOrderFront:nil];
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (IBAction)quitApp:(id)sender
|
|
|
|
{
|
|
|
|
[NSApp terminate:sender];
|
|
|
|
}
|
2016-05-25 02:00:22 +00:00
|
|
|
|
2016-05-26 01:28:50 +00:00
|
|
|
@end
|
2016-05-25 02:00:22 +00:00
|
|
|
|
2016-05-26 01:28:50 +00:00
|
|
|
int main(int argc, const char * argv[])
|
|
|
|
{
|
|
|
|
NSApplicationMain(argc, argv);
|
2016-05-25 02:00:22 +00:00
|
|
|
}
|