Ascii art

Characters drawn with characters.

Wikipedia: http://en.wikipedia.org/wiki/ASCII_art

page274

 notes

On auto-generating ascii art…

Mplayer AALIB support: http://archive.oreilly.com/pub/h/4441

sudo install aalib

To install mplayer in macports:

sudo port install mplayer-devel

To watch a ‘normal video’

mplayer video1.avi

To watch an “ascii video”

mplayer -vo aa video1.avi

So far have not been able to get aalib running with mplayer in macports. Here’s how it works in linux: http://jamsubuntu.blogspot.com/2008/10/how-to-watch-any-video-in-ascii.html

 

ep-426 Interactive Video – Spring 2015 week 14

Jitter programming

Developing with javascript, gen, and external objects.

Javascript

Jitter in javascript: https://reactivemusic.net/?p=19218

Gen

Jitter gen: https://reactivemusic.net/?p=19205

Particles

https://reactivemusic.net/?p=19194

Jitter objects

Writing Jitter external objects: https://reactivemusic.net/?p=19208

Revisiting Vizzie

Even after all that, Vizzie is my first choice when starting a project or building a prototype.

Vine analyzer example:

https://github.com/tkzic/max-projects/tree/master/maxvine

patch: maxvine-analyzer.maxpat (requires other files in the maxvine folder)

More analog video

media converter demo: https://reactivemusic.net/?p=19173

Miscellaneous

And topics that didn’t get covered.

Algorithmic video and data visualization
Projection mapping

Cornerpin: https://reactivemusic.net/?p=11838

Lighting control systems

DMX: Andrew Pask tutorial: https://reactivemusic.net/?p=18266

Development tools
Miscellaneous

60 minutes of whales: https://reactivemusic.net/?p=8433

Assignment

Do something.

ep-341 Max/MSP – Spring 2015 week 14

(under construction)

Algorithmic composition and generative music – part 3

Sensors, sonification, and data.

Sensors

Data

Vine API in Max

A Max patch that displays, transforms, and responds to internet data.

building materials
  • Max (6.1.7 or newer)
  • Soundflower –

Both available from Cycling 74 http://cycling74.com/

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.

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.

Here is a link to information about the Vine API: https://github.com/starlock/vino/wiki/API-Reference

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.

MBTA API
Audio from video

https://reactivemusic.net/?p=12570

Video from audio

https://reactivemusic.net/?p=12570

Sonification of Vine videos

https://github.com/tkzic/max-projects/tree/master/maxvine

patch: maxvine-analyzer.maxpat (requires other files in the maxvine folder)

Steve Hensley example: local file: shensely_maxvine.maxpat

References

There is a large archive of examples here: Internet sensors: https://reactivemusic.net/?p=5859

Aggregators

There are API services that consolidate many API’s into one API. For example:

Scaling data

Look at the Max tutorial (built in to Max Help) called “Data : data scaling” It contains most of what you need to know to work with streams of data.

Curl examples: https://reactivemusic.net/?p=5916

Assignment

Algorithmic/generative music. Due in class next week.

 

Convert photocell data to MIDI

With Arduino and Max.

Screen Shot 2015-04-26 at 7.27.20 PM

An update to the basic Arduino/Max patches: https://reactivemusic.net/?p=11809

Replace the potentiometer in the “Arduino Serial Read” project with a photocell (LDR: Light dependent resistor)  and a 10K pulldown resistor, wired as shown in the image above and explained here: https://learn.adafruit.com/photocells/using-a-photocell (from Adadfruit)

The “Analog” lead represents the center terminal of a potentiometer and connects to A0.

The Arduino sketch is the example sketch: Analog | analogInOutSerial

download

Screen Shot 2015-04-26 at 7.50.42 PM

https://github.com/tkzic/max-projects

folder: arduino-basics

patch: arduino-serial-read-midi.maxpat

For instructions and circuit, refer to “Arduino Serial Read” project: https://reactivemusic.net/?p=11809

Jitter in javascript

Why would you write Jitter code inside a js object?

  • Math expressions
  • File IO
  • Borrowed code
  • You’re just that way

There are three Jitter javascript tutorials (built in to Max) 45-47

Screen Shot 2015-04-24 at 12.55.44 AM

The Max javascript documentation is generally far flung. A helpful reference by Tim Schenk https://reactivemusic.net/?p=17445

Here’s an example to get started with. It downsamples a movie and changes the background color. Something I often dream about.

Screen Shot 2015-04-24 at 12.35.31 AM

Download

https://github.com/tkzic/max-projects

Folder: jitter-js

  • patch: downsamp-thing.maxpat
  • javascript source: downsamp.js

Writing Jitter external objects

Not as easy as it looks.

Screen Shot 2015-04-24 at 12.48.55 AM

Getting started

First, think of a way to get the same results without writing an external. For example, borrow other code, use javascript, gen, Processing, or MSPaint.

Apparently that didn’t work out. Well I can only get you so far.

Assuming that you have already done the following

Learn how to write non-Jitter externals:

Edit the examples

Currently the Jitter examples in the SDK are in the folders: examples/matrix and examples/gl. We’ll pretend we didn’t see GL.

Here’s a sensible approach on Mac OS.

  • Duplicate the example folder: jit.clip and rename the duplicate to something like jit.cliptz
  • Inside jit.cliptz open the Xcode project
  • Rename the Xcode project while in Xcode by single-clicking on the project name and editing it.
  • Now feel free to alter the code in any way. Look in jit.clip.c

In jit.clip.c, find the functions starting with

void jit_clip_vector_char(long n, t_jit_clip_vecdata *vecdata, t_jit_op_info *in, t_jit_op_info *out)

These are functions that processing the matrix vectors for char, long, and float matrixes respectively. We’ll work with the char function.

Change the code so that the pixel values are inverted as well as clipped by subtracting pixel values from 255.

Change two lines of code, marked here by the comment: // invert

	if ((is==1)&&(os==1)) {
		++n;--op;--ip;
		while (--n) {
			tmp =  *++ip;
			*++op = 255 - tmp>max?max:tmp<min?min:tmp; // invert
		}		
	} else {
		while (n--) {
			tmp =  *ip;
			*op = 255 - tmp>max?max:tmp<min?min:tmp; // invert
			ip+=is;op+=os;
		}
	}

 

  •  Clean and build the project.
  • The .mxo file will be under the Products folder. <Ctrl> click to show in finder
  • Copy the .mxo file into the same folder as your Max patch
  • What Max patch? This one:

Screen Shot 2015-04-24 at 12.38.14 AM

The window on the left is inverted because its getting that way in the object we just hacked.

That’s all

I didn’t really explain anything. Sometimes going through the motions is a start. If I had to do this for a living I would find the example that is most like a desired result and hack away.

Download

https://github.com/tkzic/max-projects

folder: jitter-dev

files:

  • test-object.maxpat
  • jit.cliptz.mxo (external) you will make your own version of this in Xcode

 

Jitter gen

Tutorials by Gregory Taylor

gen~ for beginners (not Jitter) https://cycling74.com/wiki/index.php?title=gen~_For_Beginners

Delicious Max Tutorials by dude837 

http://otherbirds.com/tutorials/

Pixelface (gen): https://www.youtube.com/watch?v=e49qgv5NuUQ