Max/MSP text to Morse code generator

work in progress. not published.

I needed a text to morse code generator in Max for the Twitter streaming map project. There was an ancient one that used [mxj] but its kind of a pain to use that object. I thought it can’t be that difficult to write one? I didn’t really have any idea where to start. Something about the blank Max patch causes brain activity? I went through about 5 different approaches. Eventually came up with this pattern thing, from thinking about the lighted buttons on the tr-808 drum machine.

For example, the letter A is . _ (dot dash)

morse code has rules for spacing:

dot = 1
space between tones = 1
dash = 3
space between letters = 3
space between words = 7

If you think of a drum machine pattern, the pattern for letter A would be: 1 0 1 1 1 0 0 0  (with the 3 trailing 0’s for letter spacing)

I made a [coll] with all the letter patterns indexed by ascii codes.

Then just concatenate letter patterns, for a given block of text,  together into one big list and run it through [zl.nth] clocked by a [metro] and [counter]. the ones and zero’s turn an oscillator on and off.

local file: tkzic/internetsensors/twitter-stream2/morse5.maxpat

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

 

SSTV in Max

Slow scan television simulation using Jitter.

See this Cycling 74 forum post for an explanation of how frame rate is limited by audio sample rate and  horizontal resolution: https://cycling74.com/forums/topic/jit-poke-vertical-bars-at-high-scan-frequencies/

Download

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

Screen Shot 2015-04-09 at 7.24.11 PM

Folder: sstv

Patches:

  • raster-scan4.maxpat (original)
  • raster-scan5.maxpat (better frame rate by lowering screen resolution to 160 x 120)
  • raster-poly-wrap5.maxpat (even better frame rate – up to 15 fps – by up sampling to 384 KHz)

Note – set your audio sample rate to 96KHz if possible, to get the results described above.

Brushtips

Painting in Max/MSP with various brush styles.

By Nesa Popov

From this post: https://cycling74.com/forums/topic/live-drawing-w-jitter-wacom-tablet/

Screen Shot 2015-04-05 at 4.23.28 PM

The brush styles are contained in the frames of a Quicktime movie.

Also see “Harmony drawing App” https://reactivemusic.net/?p=3806

Download

This patch was copied from the Cycling74 forum and is distributed without permission of the author.

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

Folder: brushtips

patch: brushtips.maxpat

RF mixer simulation in Max

Audio simulation of an RF circuit.

Screen Shot 2015-03-29 at 4.49.36 PM

The simulation serves no purpose, but its fun. There are 4 versions. I think the third one sounds best (rf-mixer-sim3.maxpat). Its interesting to hear how much spectral distortion happens from multiplying sawtooth waves.

Screen Shot 2015-03-29 at 4.46.55 PM

Download

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

folder: rf-mixer

patches:

Note: please set the signal vector size to 1 (or as low as possible) and enable overdrive and audio interrupt

Screen Shot 2015-03-29 at 5.22.30 PM

Four versions:

  • rf-mixer-sim.maxpat (initial attempt)
  • rf-mixer-sim2.maxpat (uses sah~ and rate~ objects)
  • rf-mixer-sim3.maxpat (uses gate~ objects with a phasor~ clock)
  • rf-mixer-sim4.maxpat (bandpass filter on RF input)

 

12th root of 2

The note relationships in a chromatic scale are based on the 12th root of 2.

An octave has a ratio of 2. An octave is divided into 12 equal steps.

For example, to find the ratio of one semi-tone (half step), on a scientific calculator, use this button:

Screen Shot 2015-03-23 at 12.36.27 PM

Here’s the result where x = 2 and y = 12

Screen Shot 2015-03-23 at 12.47.48 PM

In a computer program, you could use the pow() function calculate 2 to the 1/12 power. Here’s an example in javascript:

Screen Shot 2015-03-23 at 12.44.03 PM

This Max patch shows the relationships between any two notes and how to calculate the pitch of a note based on the semi-tone interval. You might use it as a starting point to design your own scales. For example, a 13 note chromatic scale.  Or relationships based on randomness.

Screen Shot 2015-03-23 at 12.32.36 PM

Download

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

folder: 12throotof2

patch: 12throotof2.maxpat