Sonification of Mass Ave buses, from Harvard to Dudley.
This patch sends requests to the MBTA developer portal to get the current location of buses – using the Max js object. Latitude and Longitude data is mapped to oscillator pitch. Data is polled every 10 seconds, but it seems like the results might be more interesting to poll at a slower rate, because the updates don’t seem that frequent. And buses tend to stop a lot.
You will not need authentication to run run this patch. It uses the default developer API-key for testing. Please read the terms of service at the MBTA developer portal. Data should not be polled more often than 10 seconds. You can also request your own developer API key from MBTA.
instructions
Open mbta.maxpat
Toggle the metro (at the top of the patch) to start polling
Turn on the audio (at the bottom of the patch) and turn up the gain
Note: there will be more buses running during rush hours in Boston. Try experimenting with the polling rate and ramp length in the poly-oscillator patch. Also, you can experiment with the pitch range.
I was able to receive mp3 files from a server in Max 6.18. using oggrx~. There doesn’t appear to be transport control – so this would need to be built in for synchronization.
Unexpected find: The external uses “secret rabbit code” for resampling. So it works in Max. And we have the source code but not the i386 libs that were used to compile it.
There is no binary for v.7 of oggrx~.mxo, but there is one for v.6
Original c74 post by umma08:
i managed to get Robin Gareus’ externals. They are available here, though they are unmaintained.
It’s been more than 3 years (OSX 10.5) since I last looked at it, it
should still work, but I don’t know. Please let me know if you encounter
any problems, so that I can warn others.
I don’t maintain this external anymore. I neither have a MAX/MSP
license, nor do I own any Apple devices. On the upside, complete
source-code is available from
The Max patch is based on a tutorial by dude837 called “Automatic Silly Video Generator”
download
The patch at the download link in the video is broken – but the javascript code for the Max js object is intact. You can download the entire patch from the Max-projects archive: https://github.com/tkzic/max-projects folder: maxvine
Internet API’s
API’s (application programming interfaces) provide methods for programs (other than web browsers) to access Internet data. Any app that access data from the web uses an API.
For example, if you copy this URL into a web browser address bar, it will return a block of data in JSON format about the most popular videos on Vine: https://api.vineapp.com/timelines/popular
HTTP requests
An HTTP request transfers data to or from a server. A web browser handles HTTP requests in the background. You can also write programs that make HTTP requests. A program called “curl” runs http requests from the terminal command line. Here are examples: https://reactivemusic.net/?p=5916
Response data
Data is usually returned in one of 3 formats:
JSON
XML
HTML
JSON is the preferred method because its easy to access the data structure.
Max HTTP requests
There are several ways to make HTTP requests in Max, but the best method is the js object: Here is the code that runs the GET request for the Vine API:
function get(url)
{
var ajaxreq = new XMLHttpRequest();
ajaxreq.open("GET", url);
ajaxreq.onreadystatechange = readystatechange;
ajaxreq.send();
}
function readystatechange()
{
var rawtext = this._getResponseKey("body");
var body = JSON.parse(rawtext);
outlet(0, body.data.records[0].videoUrl);
}
The function: get() formats and sends an HTTP request using the URL passed in with the get message from Max. When the data is returned to Max, the readystatechange() function parses it and sends the URL of the most popular Vine video out the left outlet of the js object.
Playing Internet audio/video files in Max
The qt.movie object will play videos, with the URL passed in by the read message.
Unfortunately, qt.movie sends its audio to the system, not to Max. You can use Soundflower, or a virtual audio routing app, to get the audio back into Max.
Traveling along the outer edge of the circle, the distance goes from 0 to 2*PI radians, then starts over again. In degrees it would be 0 to 360. A clock goes from 0 to 12. In Max and Pd the phasor~ objects are normalized to run from 0.0 to 1.0. Think of flattening out the edge of the circle to a straight line.
The phasor as input to a sine or cosine function generates one cycle of a wave for each revolution – as shown in the above animation. For example, cosine would go from 0 to 1 to 0 to -1 to 0.
If you graph the phasor value, it looks like a sawtooth wave – rising in a ramp from 0.0 to 1.0 then falling straight down to 0.0 to start again.
With waves, the distance around the circle represents time (or phase), the projected cosine value represents amplitude.
In science…
“A phasor can be considered a vector rotating about the origin in a complex plane. The cosine function is the projection of the vector onto the real axis. Its amplitude is the modulus of the vector, and its argument is the total phase . The phase constant represents the angle that the vector forms with the real axis at t = 0.”
-WIkipedia
In art…
“And the seasons they go round and round And the painted ponies go up and down We’re captive on the carousel of time We can’t return we can only look Behind from where we came And go round and round and round In the circle game.”