humatic - htools - TouchDAW

Connecting via WebSockets

This mode is hidden by default in TouchDAW 1.6 and larger. If you do want to use it, go to Setup / Global / MIDI System, touch the 'Optional Transports' menu and check the box behind 'WebSockets'

WebSockets are a new feature in TouchDAW 1.5.1. At the time being it is best described as "experimental". The mnet driver provides a native implementation and WebSockets can be used to make a regular Android to PC MIDI connection, but the concept is probably more interesting for those interested in HTML5 / javascript and things like the WebMIDI and -Audio APIs (see demo at the bottom of this page).

WebSockets for normal TouchDAW use

Much like RTP channels, WebSocket channels primarily work over WIFI and can either be local servers or clients to remote servers. Equally they make themselves known to other peers via DNS. TouchDAW is preconfigured with two device local WebSocket sessions. If WebSocket servers are enabled in mnet / MIDIHub the Android device will pick them up and let you connect to them.

Connecting from PC to Android device
  1. To enable the app's local server channels, change TouchDAW's MIDI connection(s) to WIFI / WebSockets / Local Server.
  2. You should then see new channels appear in MIDIHub, following the same naming scheme used with RTP, namely: "tdaw (and_XX) WS 1 & 2". The XX will again be replaced with the last octet of the device's IP address.
  3. Drag a patchline to the MIDI port you want to receive MIDI on and the connection will be made.

The upper patched channel in the following screenshot shows such a channel. It represents TouchDAW's ("tdaw") first MIDI connection running on WebSockets ("WS 1") on an Android device with an IP address ending in .29 ("and_29").

Connecting from Android device to PC

The second patched channel in the above screenshot is the result of TouchDAW connecting to a WebSocket server run by the PC. To learn how to enable servers in mnet / MIDIHub see the mnet documentation. Same as with PC-side RTP sessions TouchDAW will detect such servers and let you select them for connection. On the right is a TouchDAW MIDI connection dialog showing a MIDIHub ("mhb") WebSocket session linked to port 3 ("WS 3") on a PC of mine. The computer's IP address is ending in .21 ("nilsi7_21"). After selecting it and confirming the selection the channel with the green name string will pop up in MIDIHub, readily linked to the MIDI port associated with the server (ie: 3).

Javascript / HTML5 usage

WebSockets are part of the HTML5 specification. The goal is to provide realtime bi-directional communication channels for the web that avoid the overhead of long-polling and AJAX / XmlHttpRequests. As such they are supported by most modern browsers today and there are numerous implementations for frameworks like node.js. Together with other HTML5 APIs like the WebMIDI and -Audio (see Chris Wilson's increasingly impressive WebAudio demos for example) this opens up interesting possibilities for browser based controllers, MIDI routers, instruments or node based MIDI chats / online collaboration setups etc. Going into more detail here would leave the scope of this manual, but if you are interested in these kinds of things you probably get the idea. Below is a quick demo showing how to receive TouchDAW's data in a browser that you can test right here and now. TouchDAW in the end is just a demo for nmj. In case this inspires you to try something more meaningful, you are welcome to download the library.

WebSocket browser demo

Set TouchDAW's first (DAW Controller) MIDI connection to WIFI / WebSockets / Local Server, then enter the Android device's IP address in the second textfield below (Leave the protocol - ws:// - and the port number as they are), click "Connect" and move controls in TouchDAW. Input should be shown in the textfield. The slider underneath the textarea will control the fader of TouchDAW's first channel.

You can of course also do this with the second connection, but the port number would need to be changed to 8026 then.
(The slider would not do anything in that case).

This is browser based and of course - what would web development be without it - there are browser specific differences in terms of API support, performance etc. The best performing WebSocket implementation seems to be in - you guessed it, or maybe not - IE 11. Firefox, Chrome and Safari all have problems with messages coming in in rapid succession and may loose some on the way.
If one wanted to go on MIDI wise from here, Chrome would be the only browser with WebMIDI support at the time being. Mozilla seem to be working on it, but Microsoft have just made clear that they are not considering to add WebMIDI support (I must admit that giving a browser access to hardware MIDI ports always seemed to be pretty retro to me, so I can well understand that).
But if for example Bitwig's javascript controller API had support for websockets...

humatic - htools Product names referred to in the manual are trademarks of their respective copyright owners. Humatic is not affiliated with any of them. Find a listing of mentioned trademarks here