Skip to content

Instantly share code, notes, and snippets.

Created January 8, 2013 00:33
Show Gist options
  • Save anonymous/4479950 to your computer and use it in GitHub Desktop.
Save anonymous/4479950 to your computer and use it in GitHub Desktop.
Error when calling MIDIObjectGetStringProperty from RubyMotion
class AppDelegate
def application(application, didFinishLaunchingWithOptions:launchOptions)
# MIDIClientRef client = NULL;
client = Pointer.new(MIDIClientRef.type)
# MIDIClientCreate(CFSTR("Core MIDI to System Sounds Demo"), MyMIDINotifyProc, self, &client);
MIDIClientCreate("Core MIDI to System Sounds Demo", method(:myMIDINotifyProc), nil, client)
# MIDIPortRef inPort = NULL;
inPort = Pointer.new(MIDIPortRef.type)
# MIDIInputPortCreate(client, CFSTR("Input port"), MyMIDIReadProc, self, &inPort);
MIDIInputPortCreate(client[0], "Input port", method(:myMIDIReadProc), nil, inPort)
# MIDINetworkSession* session = [MIDINetworkSession defaultSession];
session = MIDINetworkSession.defaultSession
# session.enabled = YES;
session.enabled = true
# session.connectionPolicy = MIDINetworkConnectionPolicy_Anyone;
session.connectionPolicy = MIDINetworkConnectionPolicy_Anyone
# unsigned long sourceCount = MIDIGetNumberOfSources();
sourceCount = MIDIGetNumberOfSources()
# NSLog([NSString stringWithFormat:@"%ld sources\n", sourceCount]);
puts "#{sourceCount} sources"
# for (int i = 0; i < sourceCount; ++i) {
sourceCount.times do |i|
# MIDIEndpointRef src = MIDIGetSource(i);
src = MIDIGetSource(i)
# CFStringRef endpointName = NULL;
endpointName = Pointer.new(:string)
# OSStatus nameErr = MIDIObjectGetStringProperty(src, kMIDIPropertyName, &endpointName);
nameErr = MIDIObjectGetStringProperty(src, KMIDIPropertyName, endpointName);
# if (noErr == nameErr) {
if (nameErr == 0)
# NSLog([NSString stringWithFormat:@" source %d: %@\n", i, endpointName]);
puts " source #{i}: #{endpointName[0]}"
# }
end
# MIDIPortConnectSource(inPort, src, NULL);
MIDIPortConnectSource(inPort[0], src, nil);
# }
end
true
end
# static void MyMIDIReadProc(const MIDIPacketList *pktlist, void *refCon, void *connRefCon)
def myMIDIReadProc(pktlist, refCon, connRefCon)
# {
# MIDIPacket *packet = (MIDIPacket *)pktlist->packet;
packet = pktlist.packet
# Byte midiCommand = packet->data[0] >> 4;
midiCommand = packet.data[0] >> 4
# // is it a note-on
# if (midiCommand == 0x09) {
if (midiCommand == 0x09)
# Byte note = packet->data[1] & 0x7F;
note = packet.data[1] & 0x7F
# Byte veolocity = packet->data[2] & 0x7F;
veolocity = packet.data[2] & 0x7F
# NSLog([NSString stringWithFormat:
# @"Note ON. Note=%d, Velocity=%d", note, veolocity]);
puts "Note ON. Note=#{note}, Velocity=#{veolocity}"
# }
end
# }
end
# void MyMIDINotifyProc (const MIDINotification *message, void *refCon) {
def myMIDINotifyProc (message, refCon)
# NSLog([NSString stringWithFormat:
# @"MIDI Notify, messageId=%d,", message->messageID]);
puts "MIDI Notify, messageId=#{message.messageID},"
# }
end
end
** Invoke default (first_time)
** Invoke simulator (first_time)
** Invoke build:simulator (first_time)
** Execute build:simulator
/usr/bin/env VM_KERNEL_PATH="/Library/RubyMotion/data/6.0/iPhoneSimulator/kernel-i386.bc" VM_OPT_LEVEL="0" /Library/RubyMotion/bin/ruby --uses-bs "/Library/RubyMotion/data/6.0/BridgeSupport/RubyMotion.bridgesupport" --uses-bs "/Library/RubyMotion/data/6.0/BridgeSupport/UIKit.bridgesupport" --uses-bs "/Library/RubyMotion/data/6.0/BridgeSupport/CoreVideo.bridgesupport" --uses-bs "/Library/RubyMotion/data/6.0/BridgeSupport/CoreImage.bridgesupport" --uses-bs "/Library/RubyMotion/data/6.0/BridgeSupport/Security.bridgesupport" --uses-bs "/Library/RubyMotion/data/6.0/BridgeSupport/Foundation.bridgesupport" --uses-bs "/Library/RubyMotion/data/6.0/BridgeSupport/CoreGraphics.bridgesupport" --uses-bs "/Library/RubyMotion/data/6.0/BridgeSupport/CoreFoundation.bridgesupport" --uses-bs "/Library/RubyMotion/data/6.0/BridgeSupport/ImageIO.bridgesupport" --uses-bs "/Library/RubyMotion/data/6.0/BridgeSupport/QuartzCore.bridgesupport" --uses-bs "/Library/RubyMotion/data/6.0/BridgeSupport/CoreText.bridgesupport" --uses-bs "/Library/RubyMotion/data/6.0/BridgeSupport/MobileCoreServices.bridgesupport" --uses-bs "/Library/RubyMotion/data/6.0/BridgeSupport/CFNetwork.bridgesupport" --uses-bs "/Library/RubyMotion/data/6.0/BridgeSupport/Accelerate.bridgesupport" --uses-bs "/Library/RubyMotion/data/6.0/BridgeSupport/SystemConfiguration.bridgesupport" --uses-bs "/Library/RubyMotion/data/6.0/BridgeSupport/CoreMIDI.bridgesupport" --emit-llvm "./build/iPhoneSimulator-6.0-Development/objs/usr/local/src/core-midi-test/app/app_delegate.rb.i386.bc" MREP_0ED0A7DDC0694BB68B622E2C931892FA "/usr/local/src/core-midi-test/app/app_delegate.rb"
/Library/RubyMotion/bin/llc "./build/iPhoneSimulator-6.0-Development/objs/usr/local/src/core-midi-test/app/app_delegate.rb.i386.bc" -o="./build/iPhoneSimulator-6.0-Development/objs/usr/local/src/core-midi-test/app/app_delegate.rb.i386.s" -march=x86 -relocation-model=pic -disable-fp-elim -jit-enable-eh -disable-cfi
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc -fexceptions -c -arch i386 "./build/iPhoneSimulator-6.0-Development/objs/usr/local/src/core-midi-test/app/app_delegate.rb.i386.s" -o "./build/iPhoneSimulator-6.0-Development/objs/usr/local/src/core-midi-test/app/app_delegate.rb.i386.o"
/usr/bin/lipo -create "./build/iPhoneSimulator-6.0-Development/objs/usr/local/src/core-midi-test/app/app_delegate.rb.i386.o" -output "./build/iPhoneSimulator-6.0-Development/objs/usr/local/src/core-midi-test/app/app_delegate.rb.o"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ "./build/iPhoneSimulator-6.0-Development/objs/init.mm" -arch i386 -isysroot "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk" -miphoneos-version-min=6.0 -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/System/Library/Frameworks -fexceptions -fblocks -fobjc-legacy-dispatch -fobjc-abi-version=2 -c -o "./build/iPhoneSimulator-6.0-Development/objs/init.o"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ "./build/iPhoneSimulator-6.0-Development/objs/main.mm" -arch i386 -isysroot "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk" -miphoneos-version-min=6.0 -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/System/Library/Frameworks -fexceptions -fblocks -fobjc-legacy-dispatch -fobjc-abi-version=2 -c -o "./build/iPhoneSimulator-6.0-Development/objs/main.o"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -o "./build/iPhoneSimulator-6.0-Development/core-midi-test.app/core-midi-test" "./build/iPhoneSimulator-6.0-Development/objs/init.o" "./build/iPhoneSimulator-6.0-Development/objs/main.o" "/Library/RubyMotion/data/6.0/iPhoneSimulator/UIKit_stubs.o" "/Library/RubyMotion/data/6.0/iPhoneSimulator/Foundation_stubs.o" "/Library/RubyMotion/data/6.0/iPhoneSimulator/CoreGraphics_stubs.o" "/Library/RubyMotion/data/6.0/iPhoneSimulator/CoreFoundation_stubs.o" "/Library/RubyMotion/data/6.0/iPhoneSimulator/CFNetwork_stubs.o" "./build/iPhoneSimulator-6.0-Development/objs/usr/local/src/core-midi-test/app/app_delegate.rb.o" -arch i386 -isysroot "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk" -miphoneos-version-min=6.0 -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk/System/Library/Frameworks -L/Library/RubyMotion/data/6.0/iPhoneSimulator -lmacruby-static -lobjc -licucore -framework UIKit -framework CoreVideo -framework CoreImage -framework Security -framework Foundation -framework CoreGraphics -framework CoreFoundation -framework ImageIO -framework QuartzCore -framework CoreText -framework MobileCoreServices -framework CFNetwork -framework Accelerate -framework SystemConfiguration -framework CoreMIDI
/usr/bin/plutil -convert binary1 "./build/iPhoneSimulator-6.0-Development/core-midi-test.app/Info.plist"
/usr/bin/dsymutil "./build/iPhoneSimulator-6.0-Development/core-midi-test.app/core-midi-test" -o "./build/iPhoneSimulator-6.0-Development/core-midi-test.dSYM"
** Execute simulator
DYLD_FRAMEWORK_PATH="/Applications/Xcode.app/Contents/Developer/../Frameworks":"/Applications/Xcode.app/Contents/Developer/../OtherFrameworks" /Library/RubyMotion/bin/sim 2 1 6.0 "/Applications/Xcode.app/Contents/Developer" "./build/iPhoneSimulator-6.0-Development/core-midi-test.app"
(main)> 1 sources
2013-01-07 17:28:14.082 core-midi-test[20445:c07] app_delegate.r:in `block in application:didFinishLaunchingWithOptions:': expected instance of Pointer, got `#<MIDIEndpointRef:0x9564630>' (MIDIEndpointRef) (TypeError)
from app_delegate.rb:29:in `application:didFinishLaunchingWithOptions:'
2013-01-07 17:28:14.084 core-midi-test[20445:c07] *** Terminating app due to uncaught exception 'TypeError', reason: 'app_delegate.r:in `block in application:didFinishLaunchingWithOptions:': expected instance of Pointer, got `#<MIDIEndpointRef:0x9564630>' (MIDIEndpointRef) (TypeError)
from app_delegate.rb:29:in `application:didFinishLaunchingWithOptions:'
'
*** First throw call stack:
(0x1807012 0x17be7e 0xd8314 0x2a22 0x27d5)
libc++abi.dylib: terminate called throwing an exception
*** simulator session ended with error: Error Domain=DTiPhoneSimulatorErrorDomain Code=1 "The simulated application quit." UserInfo=0x100121440 {NSLocalizedDescription=The simulated application quit., DTiPhoneSimulatorUnderlyingErrorCodeKey=-1}
rake aborted!
Command failed with status (1): [DYLD_FRAMEWORK_PATH="/Applications/Xcode.a...]
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/file_utils.rb:45:in `call'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/file_utils.rb:45:in `sh'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/file_utils_ext.rb:40:in `sh'
/Library/RubyMotion/lib/motion/project.rb:101:in `block in <top (required)>'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/Users/jedidiah/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/task.rb:187:in `block in invoke_prerequisites'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/task.rb:185:in `each'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/task.rb:185:in `invoke_prerequisites'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/task.rb:165:in `block in invoke_with_call_chain'
/Users/jedidiah/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/bin/rake:19:in `load'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/bin/rake:19:in `<main>'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
/Users/jedidiah/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => default => simulator
# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project'
Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings.
app.name = 'core-midi-test'
app.frameworks << 'CoreMIDI'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment