Adam's Blog
×

myo.js Explorations

Sunday November 20, 2016
Category: uncategorized

In the past I have endeavored to work with things that I like. Right now my two favourites are flocking.js, MYO. In particular, I have been very happy to get back into node.js and taking a look at the myo.js bindings.

The basic demos work well but I have two myos, so it would be great to address each separately. The API provides a Myo object that keeps an array of all of the myos connected at the time. Most of the demo code uses the Myo.on('connect, function(){}; to check the array and then keep track of the left and right arm (which is how I want to use them and how I expect most people to use them too).

The problem is that when you check the myo objects once they have connected a lot of their parameters are not set:

 [ { macAddress: 'f3-c6-21-d0-98-b3',
name: 'Adam Tindale\'s Myo',
connectIndex: 0,
locked: true,
connected: true,
synced: false,
batteryLevel: 0,
lastIMU: undefined,
arm: undefined,
direction: undefined,
warmupState: undefined,
orientationOffset: { x: 0, y: 0, z: 0, w: 1 },
events: [],
connectVersion: '1.5.1970.2' } ]

In order to get these parameters I waited for the unlock event and then checked the calling object for its arm parameter. I have two references for specific myos leftMyo and rightMyo that I check to see if they are undefined. If they aren't then I check the calling object using this in order find its arm parameter. I assign the object to my references and then inititialize the listeners at that point. If you do it before you define the objects then javascript rightly complains that you are trying to put listeners on undefined objects (because they obviously aren't yet defined).

Here is an example I whipped up of a basic two handed myo.js that sends OSC messages using osc.js.

Day 6

Friday May 06, 2016
Category: Creative Pact 2016

Another simple test today. A button. Are buttons in iOS really this bad? Is there no UIControlAction that deals with touch releases being both inside and outside of a button? Odd.

Screenshot of software.

Day 5

Thursday May 05, 2016
Category: Creative Pact 2016

Today was a tooling day. I've been building the apps in the simulator but what about launching it on actual hardware. So, because I am running 9.3 on my phone I had to finally upgrade to 10.11. Then it was updating XCode to the latest version and reinstalling C4. Fun times. The result was great to be able to walk around with the results on my phone. Hoorah!

To make things more fun I checked out Dringend, an app that connects to your mac and lets you code on your device and then launch the result on your device. No more plugging in the phone just to upload. Even better I can do a bit of hacking on the go. Awesome. Just awesome. I had a bit of a problem getting started and emailed the developer who had me up and running in less than an hour. Amazing.

A screenshot of software

Day 4

Wednesday May 04, 2016
Category: Creative Pact 2016

A simple one today, but importantly a variant of the flocking sketch. This is a stereo envelope that can be modulated with a single slider. Enjoy.

Day 3

Tuesday May 03, 2016
Category: Creative Pact 2016

Today I made a simple sketch using UIWebView.stringByEvaluatingJavaScriptFromString(string:string) to send UISlider values from C4 to Flocking. It worked! There is simple synth that has a frequency and amplitude control and I used the flock.ugen.scope in order to display the output in the UIWebView. A few simple tricks together makes for a great demo.

Next trick will be to start to make something that sounds interesting. I'm starting to get confident enough to attempt it.

Screenshot of software. Screenshot of software.

older   →