I’ve been working on trying to bring MIDI to ASObjC, trying different frameworks (objC Wrappers)
learning about protocols, subclassing, delegates, callbacks and more.
It’s been a great learning experience and I’ve tried to hammer my way thru it myself.
Eventually I’d love to build a library to share with everyone.
The main problem started with trying to get a value from the array
that’s being sent to me via a callback with “me” as the delegate.
The data received is pointer data (i think)
The main values (method instance values) I want are:
channel, data1, data2 and type
No problems getting those values via instance method’s using:
msgPtr's channel
msgPtr's data1
msgPtr's data2
msgPtr's type -- problems here, think scripting additions has claimed it 1st
msgPtr's type() -- based on posts you've made and your book, still no
msgPtr's |type| -- nope
msgPtr's |type|() -- nope
-- there is another method i can call on the instance, that returns a string
msgPtr's lengthyDescription
-- returns "Ctrl, ch.0, ctrl.5, val.55"
-- I split the string to a list via lengthyList -> (NSString's string......seperated by as list)
set end of myDescList to lengthyList's item 1
-- repeat with the rest of the list and split each substring with "." delimiter
set subValue to subList's item 2 -- but it's a string (raw format shows as ctxt)
set subValue to subValue as integer -- crash
set subValue to subValue as real -- crash
set theEnd of myDescList to subValue
I think it may have something to do with threading.
As there is constant MIDI being captured by the framework and it is probably
making calls to my callback function, which seems to be ok while I’m in another
function in my script. But anytime I ask for the bridging it crashes.
Question am I still dealing with pointer Data at this point?
The string I’ve received would have gone thru a couple of NSString’s with string,
separated by processes on it. When I’ve checked the class of the string at various
points in the code is always returning _CFTEXT.
I’ve Figured Out a Solution Around It
to get the type, I just use item 1 from myDescList
and use the values from the framework Class for the others.
so the REAL ISSUE is getting around the instance method named “type”
any insight on the issue?
I’ve had thoughts about going thru the framework and changing it myself.
adding in my own named instance method that won’t conflict.
- (Byte) type; --from the header file
- (Byte) type { --from the .m file
return type;
}
- (Byte) channel { --example of the instance method I can call easy
return channel;
-- WOULD THIS WORK to solve the |type| conflict?
-- edit the .h and .m file and add my own method
- (Byte) midiType; -- add to the header
- (Byte) midiType { -- add to the .m file
return type;
}