Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed cc bug #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

**/.DS_Store
build/*
DerivedData/*
.DS_Store
build/.DS_Store
build/Development/.DS_Store
English.lproj/.DS_Store
.DS_Store
Binary file removed English.lproj/.DS_Store
Binary file not shown.
4 changes: 3 additions & 1 deletion KeyStroke.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ - (void)midiProcess:(MIDIPacketList *)pktlist endpoint:(MIDIPortRef *)connRefCon
if ((packetStart>>4) == 0x0e) { type = @"pb"; } // pitchbend
if ((packetStart) == 0xfe) { type = @"as"; } // activeSensing
if ((packetStart>>4) == 0x0c) { type = @"pgm"; } // program change


printf("the type is: %s \n", [type UTF8String]);

if ((type == @"nOn" && packet->data[2] != 0) || type == @"cc" || type == @"pgm") {
[convert midiConvert:(MIDIPacket *)packet endpoint:(MIDIPortRef *)connRefCon];
}
Expand Down
17 changes: 14 additions & 3 deletions MyController.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,23 +116,34 @@ - (void) midiConvert: (MIDIPacket *)packet endpoint:(MIDIPortRef *)ep {
int packetStart = packet->data[0]; // remembers original type and channel of message before altering
if ((packetStart>>4) == 0x0b) { cc = true; }

//printf("the channel is: %i \n", channel);
//printf("the note is: %i \n", packet->data[1]);
printf("the channel is: %i \n", channel);
printf("the note is: %i \n", packet->data[1]);
printf("cc is: %i \n", cc);

for (i=0; i<[_startNotes count]; i++) {
StartNote *sn = [_startNotes objectAtIndex:i]; // creates a startNote object for each item in list
NSDictionary *sp = [sn properties]; // creates a dictionary of startNote properties
NSMutableArray *se = [sn endNotes];
if ([[sp objectForKey:@"number"] intValue] == packet->data[1]) { // if note / pgm / or cc number is the same as the received midi message
if ([[sp objectForKey:@"channel"] intValue] == channel || [[sp objectForKey:@"channel"] intValue] ==0) { // if channel is the same or we're looking for all channels
if (cc == false || packet->data[2] == [[sp objectForKey:@"ccValue"] intValue] || [[sp objectForKey:@"ccValue"] intValue] == -1) { // optionally looking for specific cc values

int ccValue = [[sp objectForKey:@"ccValue"] intValue];
printf("ccValue is: %i \n", ccValue);
printf("received cc: %i \n", packet->data[2]);

// fixup to avoid non-cc messages to always fire
if ((cc == true && (packet->data[2] == ccValue || ccValue == -1)) ||
(cc == false && ccValue == -1) ) { // optionally looking for specific cc values
for (j=0; j<[se count]; j++) {
dispatch_async(dispatch_get_main_queue(), ^{
EndNote *en = [se objectAtIndex:j];
NSDictionary *eprop = [en properties];

char *charString = [(NSString *)[eprop objectForKey: @"keystroke"] UTF8String];
int theLetter = [self keyCodeForKeyString:charString];

printf("charString: %s \n", charString);
printf("sending keystroke %i \n", theLetter);

CGEventFlags flags = 0;
CGEventRef down = CGEventCreateKeyboardEvent( NULL, (CGKeyCode)theLetter, true);
Expand Down
Binary file modified build/.DS_Store
Binary file not shown.
Binary file removed build/Deployment/.DS_Store
Binary file not shown.
Binary file removed build/Development/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions midiStroke.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@
hasScannedForEncodings = 1;
knownRegions = (
en,
English,
);
mainGroup = 2A37F4AAFDCFA73011CA2CEA /* keystroke_v32 */;
projectDirPath = "";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>