Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit be00fcda2a324d21770a7dc1e41c1b7a806ee55e @ryanb committed Apr 25, 2010
Showing with 3,421 additions and 0 deletions.
  1. +5 −0 .gitignore
  2. BIN English.lproj/InfoPlist.strings
  3. +2,679 −0 English.lproj/MainMenu.xib
  4. +28 −0 Info.plist
  5. +11 −0 MIDIUtility.h
  6. +86 −0 MIDIUtility.m
  7. +510 −0 Maestro.xcodeproj/project.pbxproj
  8. +1 −0 Tests/run_suite.rb
  9. +17 −0 Tests/stub_test.rb
  10. +15 −0 main.m
  11. +25 −0 main_controller.rb
  12. +21 −0 main_view.rb
  13. +23 −0 rb_main.rb
@@ -0,0 +1,5 @@
+pkg/*
+build/*
+*.pbxuser
+*.mode1v3
+*.mode2v3
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>English</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIconFile</key>
+ <string></string>
+ <key>CFBundleIdentifier</key>
+ <string>com.yourcompany.Maestro</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>NSMainNibFile</key>
+ <string>MainMenu</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+</dict>
+</plist>
@@ -0,0 +1,11 @@
+#import <Cocoa/Cocoa.h>
+#import <CoreMIDI/MIDIServices.h>
+
+@interface MIDIUtility : NSObject {
+
+}
+
++ (void)setup;
++ (BOOL)isKeyPressed:(int)key;
+
+@end
@@ -0,0 +1,86 @@
+#import "MIDIUtility.h"
+
+BOOL keys[200];
+
+void readProc(const MIDIPacketList *pktlist, void *refCon, void *connRefCon)
+{
+ NSAutoreleasePool *pool;
+ int j, i;
+
+ objc_registerThreadWithCollector(); // quiet warning about GC starting on thread, 10.6 SDK only
+
+ pool = [[NSAutoreleasePool alloc] init];
+
+ MIDIPacket *packet = (MIDIPacket *)pktlist->packet;
+ for (j=0; j < pktlist->numPackets; j++) {
+
+ // only treat note information, ignore cntrol mode info
+ if (packet->data[0] < 0xB0) {
+
+ // Loop through the notes. Could use some cleaning up
+ for (i=0; i < packet->length; i+=3) {
+ BOOL keyDown;
+ int key;
+
+ if (packet->data[i] == 144) {
+ keyDown = YES;
+ } else {
+ keyDown = NO;
+ }
+
+ key = packet->data[i+1];
+ keys[key] = keyDown;
+
+ if (keyDown) {
+ // Notify with MIDIKeyDownNotification
+ [[NSNotificationCenter defaultCenter]
+ postNotificationName:@"MIDIKeyDownNotification"
+ object:[NSNumber numberWithInt:key]];
+ // NSLog(@"Down: %d", key);
+ } else {
+ // Notify with MIDIKeyUpNotification
+ [[NSNotificationCenter defaultCenter]
+ postNotificationName:@"MIDIKeyUpNotification"
+ object:[NSNumber numberWithInt:key]];
+ // NSLog(@"Up: %d", key);
+ }
+ }
+ }
+
+ packet = MIDIPacketNext(packet);
+ }
+
+ [pool release];
+}
+
+
+@implementation MIDIUtility
+
++ (void)setup
+{
+ int i, sourceCount;
+ MIDIPortRef inPort;
+ MIDIClientRef client;
+
+ // create client and input port
+ // Inputs will be sent to "readProc" method
+ MIDIClientCreate(CFSTR("MIDI Echo"), NULL, NULL, &client);
+ MIDIInputPortCreate(client, CFSTR("Input port"), readProc, NULL, &inPort);
+
+ // open connections from all sources
+ sourceCount = MIDIGetNumberOfSources();
+ for (i = 0; i < sourceCount; ++i) {
+ MIDIPortConnectSource(inPort, MIDIGetSource(i), NULL);
+ }
+
+ // Report the number of sources
+ NSLog(@"%d sources\n", sourceCount);
+}
+
+
++ (BOOL)isKeyPressed:(int)key
+{
+ return keys[key];
+}
+
+@end
Oops, something went wrong.

0 comments on commit be00fcd

Please sign in to comment.