hardware control of webaudio API

programming

This is a tweak of a demo program by Boris Smus from http://webaudioapi.com

The audio is generated in the web browser using the webaudio API. Oscillator frequency is being controlled by an iPod touch running touchOSC.

A ruby program is running in the background. It starts 2 servers, one to handle Osc messages from the iPod. and a websockets server which passes Osc messages to the web client in the browser, which parses the data and sets oscillator frequency.

local source files in tkzic/web-audio-api/webaudioapi/content/posts/oscillator-ws

instructions

(these are for my local files – source has not been published yet) Please contact me directly for more information about this code. Or have a look at a very similar example at: https://github.com/tkzic/WebAudio

1. run the node webserver in tkzic/

node nodeserver.js

(it will run on localhost port 8081 – for example http://127.0.0.1:8081)

2. In Chrome web browser, run: http://192.168.1.104:8081/web-audio-api/webaudioapi/content/posts/oscillator-ws/index.html

The following screen will appear:

3. From a terminal prompt run this ruby script (in tkzic/web-audio-api/webaudioapi/content/posts/oscillator-ws)

./wapOSCserver.rb

4. In webpage in Chrome, click the sockets button – the ruby server should open a socket connection, also click the play/pause button to start the oscillator

5. In touchOSC point the host to the ip address of the laptop (ie., 192.168.1.104) running on default ports, (out 8000, in 9000)

6. In touchOSC run the ‘simple’ layout and move fader1 to change the pitch of the oscillator

Note: You will probably also want to open the developer javascript console in Chrome to see what is going on.

next step

Need to clean up the ruby server code to handle error conditions, ie., network interruptions, missing files, browser incompatibility, etc.,

 

ipadOscMidi app with Max patch

Have set up a Github repository for the ipadOscMidi simulator app: https://github.com/tkzic/ipadoscmidi

There is also a companion Max patch for testing

Here is the README file for the project:

ipadMidiOsc
-----------
March 4, 2013
version 1.0

This program is a simulator to test Midi and Osc communication in iOS. There is a companion Max/MSP patch in the archive (oscmiditest3.maxpat). The Max patch lets you control the user interface on the iPad. And it well display incoming messages from the iPad.

I have only tested the default iOS midi networking devices via Mac OS, and an iRig Midi interface. 

This is the only documentation right now - but there are big plans, yeah, for a programming guide, and a free app store app, along the lines of audioGraph.

I wanted to get this initial version out before the spacecraft lands in the backyard.

Acknowledgements:

The Midi code was derived from PGMidi by Pete Goodliffe
The Osc code was derived from OscPack by Ross Bencina

Thank you.

Tom Zicarelli
[email protected]

Notes:

Local Project files are in: tkzic/oscapps/ipadmiditest4

I made the update described here for iOS 6 compatibility:

http://stackoverflow.com/questions/12548856/coremidi-pgmidi-virtual-midi-error-in-ios6

 

 

 

Installing pycurl on Mac Os

notes

update: 11/1/2014 installed version 7.19.5 using easy_install

Here’s the website: http://pycurl.sourceforge.net

It worked. Because xCode was installed?

sudo env ARCHFLAGS="-arch x86_64" /usr/bin/easy_install setuptools pycurl==7.19.0

Here are instructions, but really all I needed was the above command

http://blog.carlotorniai.net/lion-and-pycurl/

Pycurl examples: http://www.angryobjects.com/2011/10/15/http-with-python-pycurl-by-example/

Local file examples in tkzic/python-api/

There are other Python libs like request, human curl, urllib….

phantomJS

phantomJS runs outside the browser but implements enough of the DOM that you can use it for testing, rendering screenshots, running http: requests, etc.,

http://phantomjs.org/index.html

Have installed locally in: tkzic/phantomjs (binary is in the bin/ folder)

Osc in php

The Osc code from the stock market music project https://reactivemusic.net/?p=12029 is not really doing Osc.

But… it works well going from php->max. In the other direction its using a kluge of nc and an alarm clock shell program – to receive messages from Max in UDP, but its really kind of horrible – so I’m going to look again for an OSC library in php.

update 2/2013 This is hard to believe, but I haven’t yet found a real OSC libraries for php. Apparently php is so uncool, that nobody wants to write for it anymore. Anyway, the code above, works unidirectionally, so its of some use for existing php code.

Local files are max-php-osc-tester.maxpat and max-osc-play.php in tkzic/api

Analysis that might help with parsing:

from Captain Caveman

http://forum.cockos.com/showthread.php?t=99076