NullReferenceException in Unity SampleApp


#1

Hello, I am interested in visualization of EEG data in VR but have very limited developer experience.

Baby Steps: I am trying to get Unity to run the LibMuse Unity Example Application. I have followed the directions here: http://developer.choosemuse.com/unity/getting-started

When I run the application I get:

NullReferenceException: Object reference not set to an instance of an object
SampleApp.Start () (at Assets/SampleApp.cs:68)

Drilling into MonoDevelop, the offending line is this:

    Debug.Log("Libmuse version = " + muse.getLibmuseVersion());

Any ideas on how to proceed or what I am doing wrong?

Thank you!


Wish List - App (Android, iOS, Win)
#2

Hey wise people, anyone can help @ggattis out please? Thanks!


#3

You’ll need to run the app on an Android or iOS device.

#if UNITY_IPHONE
    muse = new LibmuseBridgeIos();
#elif UNITY_ANDROID
    muse = new LibmuseBridgeAndroid();

This is the code in the sample app that only initializes the muse object if it detects that it’s running on an iOS/Android device.


#4

THANK YOU!

Is there any way to develop with Unity on the PC?


#5

I think developer.choosemuse.com is down right now, so I can’t check if the Windows SDK might allow that… But I do know that you can use an OSC library to receive data from the Muse when it’s connected to Muse Direct.

This is with the SharpOSC library (https://github.com/ValdemarOrn/SharpOSC)

void Start () {

	// Callback function for received OSC messages. 
	HandleOscPacket callback = delegate(OscPacket packet)
	{

		var messageReceived = (OscMessage)packet;
		var addr = messageReceived.Address;

		if (addr == "Person0/elements/gamma_absolute") {
			for (int argIdx = 0; argIdx < messageReceived.Arguments.Count; argIdx++) {
				Debug.Log("This is the gamma absolute power band from sensor #" + argIdx + ": " + System.Convert.ToSingle(messageReceived.Arguments[argIdx]);
			}
		}

	};

	// Create an OSC server.
	var listener = new UDPListener(7000, callback);
	Debug.Log("Listening at UDP 7000");
}

In Muse Direct, my connected Muse has “Person0” preprended to its OSC address. If yours is different, you’ll have to reflect that change in this code.


#6

Thanks folks, this gives me plenty to chew on :slight_smile:

Have a great day!