Using hamlib to poll frequency data with Max/MSP

This Max patch connects to a radio transceiver and reads the frequency data using hamlib. Hamlib provides a common API for amateur radio devices. The hamllib server runs in the background using TCP/IP. This patch uses Jeremy Bernstein’s shell object. and the Sadam Library of externals, installed with the Max package manager.


hamlibtcptest1.maxpat : select radio, starts rigcltd dameon, poll frequency via tcp/ip : shell script to run rigctld


Max: Jeremy Bernstein’s shell external, and the sadam library from Max package manager.

hamlib can be installed using homebrew


There is some latency when using the Elecraft K4. Need to look into the internal CAT settings.

Also, look into communication latency of TCP/IP and associated libraries.

I’m exploring a version of this that uses node.js instead of the shell external and tcp/ip library in Max. Initial problem is that the rigctld daemon stays active after Max is closed and needs to get killed manually.

Video media converter ADVC-110

Bidirectional analog/digital conversion of composite, s-video, and firewire/ilink.

By Grass Valley


Using this device on Mac OS X 10.9, analog video input shows up as a system device. It also works as a firewire video output device.



Using Jitter you can get real time input from analog video devices like cameras and VCR’s. Here’s an example using jit.grab (Max help file) to get input from an analog camcorder.

Screen Shot 2015-04-22 at 8.48.35 PM



Sending output via firewire to a TV using jit.qt.videoout (Jitter tutorial 22):

Screen Shot 2015-04-22 at 9.53.39 PM

This is what it looks like on a TV:


Max Twitter client using ruby

Send and receive Tweets using Max via OSC to a background ruby server.

An advantage of this method is that both the patch and the server are  compact and easy to understand. The Max patch does things in a Max way. And likewise with the ruby scripts.


folder: twitter-ruby


  • twitter-client.maxpat
  • twitter-server-send.rb (for sending Tweets)
  • twitter-server-get.rb (for receiving Tweets)
ruby gems

The ruby script requires installation of the following gems

  • json
  • osc-ruby
  • twitter

For example:

# sudo gem install twitter

Twitter authorization

In addition to having a Twitter account, you will need to set up a Twitter application from the developer site here:

Good instructions on how to do this can be found in this post under this heading: So you want to use the Twitter v1.1 API?

When you get to step 5 – in the instructions – instead of writing your own code, just use a text editor to copy your access tokens into these ruby programs:

  • twitter-server-send.rb
  • twitter-server-get.rb

Replace the strings in this line of code by copying and pasting the appropriate ones from your Twitter application:

twitterClient = do |config|
  config.consumer_key = "mqQtoYh16343tDFG3BK7QQ"       
  config.consumer_secret = "X0KexjlK49fhhrnn9EztapZfATCQqWCc5fXVJH2pE"      
  config.oauth_token = "205589709-5krgh9FR3KkLGRDnewiU7GKKBMA6i2La84c"       
  config.oauth_token_secret = "LNARAeooN2vkklkF006GRdihQ5D8YYkm8dYvEs68M"  
Yeah – its cryptic, but trivial compared to writing the ouath code. Just a reminder, if even one letter or quote mark, or anything is out of place, the authorization will fail.


(note: currently running with ruby version 2.0) Display your ruby version by typing: ruby –version

Sending Tweets
  • Open the Max patch: twitter-client.maxpat
  • In a terminal window run the ruby script:
# ./twitter-server-send.rb

  • In the Max patch, type in a Tweet. Press the green button to send. 
  • When you have tweeted enough, end the ruby server program by typing <ctrl-c>
 Receiving Tweets
  • Open the Max patch: twitter-client.maxpat
  • In a terminal window run the ruby script:
  • From Twitter, send a Tweet to the user name embedded in the server
# ./twitter-server-get.rb

Both ruby servers can run at the same time.

What’s next?

  • Parse incoming Tweets into various components
  • Combine the 2 Ruby servers

revision history

  • 5/21/2014 – refactored app names. Added receive server
  • 5/19/2004 – moved to twitter-ruby folder
  • 1/18/2014 – minor fixes to ruby server for current ruby version 2.0
  • 9/7/2013 – uses oauth to communicate directly to Twitter from ruby

data recording

Thoughts on a streaming API project model with Max.

I’ve been trying to come up with generalized methods to handle the class of Max projects which read a stream of data from the Web, and use it to trigger events, for example, sound and graphics.

OSC is generally a good way to get data into Max from Web API’s. One issue with data streams, is that they do not always provide a constant flow. In some cases, this is what makes them musical. The rhythm of the flow becomes the rhythm of the music.

But in some cases we are vexed by too little flow or too much.

When the flow is too sparse, and the project requires a constant flow – the stream can be fattened up by using a [metro] object to output the current stream value at a higher frequency.

When the flow is too fast – you can use [speedlim] for numbers – but not for text data like tweets about cats, which seem to stream in like a flood. One solution is to use a data-recorder, like our modified CNMAT list recorder in the Irish Train project.

You would need separate access to the record and play ‘heads’ – so for example you could record in real time, but start playing back at a slower rate (while the recording continues). This is essentially a form of stream buffering. The data recorder approach would also allow you to use various algorithms to ‘thin’ the data – for example, to keep up with the real time rate, but by using less of the data.

[update] got this working with the modified CNMAT data recorder patch. It allows separate control of recording and playback, simultaneously.

patch is in tkzic/max teaching examples/ data-recorder-tester.maxpat


how to open, read, and write from a serial port in C (linux)

With applications for Raspberry Pi



C – programming example:

An R-Pi thread about connecting Arduino to R-Pi. R-Pi does TTL (3.3 v level and Arduino is rs-232 5v) so you need a level converter for them to communicate.

Another similar example, connecting Arduino and R-pi via USB

The WiringPi library for serial io:






using a WiFi router as a closed local network

I set up a WiFi router today at school, with no internet connection to use for ssh logins to Raspberry Pi and OSC experiments with Arduino. It has the same SSID as my home router so it will be interesting to see what happens when I go from one place to the other. 

Update: Actually this works great. Have been using it for any situation that requires OSC.