Friday, March 13, 2015

Final project update 3

It seems I've been missing the entire set of Max objects that are part of the Live API.  This has the potential to make everything a lot easier, except I now have to remake my patch.  I hope, if I put in the time, that it will work, and not just be a lot of time wasted.

Tuesday, March 10, 2015

Class notes 3/10: buffers, delays, filtering

allocate some body of memory, a table capable of holding x samples, with an index at each location

that's what delay~ object does--its argument should be how many samples of memory to set aside--really, it works in chunks of audio, not individual samples

I/O buffer tells you what size chunk of audio it will get from operating system before bringing it into Max--probably default 512

signal vector size--not same as I/O vector size, how many samples are calculated at one time and sent out to DAC--there's always a small delay

to find out what happened 3 samples ago--subtract 3 from current index number, find out what's there--but have to make sure it's within the appropriate range (0-x)--when you get beyond end of buffer, subtract 44,100 from it, so it puts you back to zero--circular buffer--not literally circular, but cycles back to beginning of buffer once it reaches the end--this is how delay works

tapin, tapout objects work with a buffer to access different indices at random (?)

click~ object--when you bang it, it sends out 1--otherwise sends out a 0--so, if you do that with an audio signal, it sounds like a click

as two sine waves of the same frequency are delayed over the length of a phase, you get an amplitude-scaled sine wave of the same frequency--that's how a filter works usually, is by suppressing or boosting certain frequencies

tapin~ object--creates a place in memory that can hold a certain amount of time in sound--specify in ms--must be connected to tap out~

tapout~ object--tell it how many ms of delay you want it to look in the past, translates from ms to samples for you

can use tap out~'s output to feed back into tap in~ to generate feedback--generally this kind of feedback doesn't work in MSP, but this is a rare exception, works b/c tapout~ will never let you go back more than a signal vector's worth of time in the past--this allows you to do repeated echoes, like a "delay" function on a pedal or in a DAW

matrix delay~ (or something like that) object, for video--stores a number of matrices, can ask it to look back in the past a certain number of index #'s back

can also specify time value for delay in a tempo-related way, with translate object

in pop music, subliminal delay of like a half note, at an extremely low level--builds mysterious harmonic complexity b/c of suspensions--check out any Enya song, or Prince uses it a lot even with guitar

chorusing is a slight randomization of delay time, like passing a changing filter through sound, to emulate slight out-of-tuneness, or a bit like a flanger

there's an example that uses a rand~ object with tapin~ and tapout~ objects to give somewhat of a chorus-y effect

*good idea: use loop $1 message into sfplay~ object to loop it, put a toggle into the loop $1 message

play a version of a sound that's delayed exactly 1 sample, will interfere at half the sampling rate destructively, will create a kind of low-pass filtering effect

comb~ object--allows feedback delays internally, feedbacks less than one vector size, can specify milliseconds of delay, how much of the feedback and feedforward signals do you want

delay snare drum by 1 ms, get a pitchy sound

reson~ object--choose center frequency to be emphasized, and Q factor (how sharply to emphasize sound)--did Chris make this?  or does it come with Max?  not sure

table object--can specify frequencies, amplitudes, etc.

biquad~ object--all-purpose filter object in Max, often used alongside filtergraph~ object which allows you to send info into biquad~--help file shows you the formula it uses, you could input the scaling factors yourself, but filtergraph takes care of that for you--left inlet of filtergraph object lets you put in menu and set mode of filter--allows one cutoff or center frequency, basically

*filtering is delay--it's just really short delay

you can chain biquad~ objects, there may even be an object called cascade~ which would do this for you

Reason is a cool DAW that mimics hardware setups in electronic music studios, complete with cables and all

Sunday, March 8, 2015

Final project update #2

I'm having trouble mapping dials in Max for Live to actual dials on the Live interface.  Specifically, I want these dials to control the proportion of the signal being sent through reverb and delay, and the selected audio track in Live has built-in send dials for this purpose.  I want the dials to run through Max, because I want the motion of the dials to be automated very gradually.  I suppose there may be some way automate this in Live itself, but I was hoping to have Max time everything.

I already had to download one external object, aka.keyboard, to get Max to communicate with Live.  I made a bunch of keyboard shortcuts in Live, and I'm having this object in Max automatically press certain keys at certain triggers.  I thought mapping Max objects to Live controls directly would be super easy, because that's what I thought Max for Live was for.  It doesn't seem that way, though.

Thursday, March 5, 2015

Class notes 3/5: 3D animation and OpenGL

can do "moderately interesting" things with 3D animation in Max

there's a center point (0,0,0) around which everything is measured

OpenGL has lighting capabilities to determine direction of incoming light

reminder: use qmetro instead of metro, since it's ok if a frame of video gets dropped

jit.gl.render object --> render means turn something into a usable output, so it draws whatever it thinks it should draw and puts it out

send a message "erase, bang" to jit.gl.render to clear the previous information and give us the new information

give jit.gl.render object @erase_color 0. 0. 0. 1.--which means no red, no green, no blue, full opacity--when it erases, it's black--RGBalpha for this object (not the same order in every object)

jit.gl.gridshape object --> makes lots of tiny triangle drawings and stitches them together to make your picture--@shape attribute: sphere, cube, taurus, all kinds of things--put in pak position object 0. 0. 0.  so initial position is at origin--if you give it no size information, it will pretty much fill up screen

to automate something moving through space, have program running to continually change x, y, and z values--can use line objects or any algorithm you can dream up

check jit.gl.gridshape's attributes in inspector window--there's a lot--also check OB3D attributes, which are all available to any GL object

attrui object--type in gl_color, it gives you a menu--when you make an attrui object, it gives you the options to change that attribute in selectable form, either a menu or a continuum

@lighting_enable --> turns on lighting capabilities, otherwise looks like light is coming from all directions

jit.gl.texture object --> whatever you send into this can be referred to with the @texture attribute of jit.gl.gridshape--texture can be an image or a movie that will play in that shape

depth enable attribute--> can decide which objects are in front of & behind other objects

can also put a movie on a plane to put it in 3D space--> jit.gl.videoplane

to change name of a string of jit objects, send message drawto [new name]

pak camera object--> tells where your camera is coming from, position can be controlled just like a gridshape

nurbs is a cool concept--you have a 3D shape, and you have points that protrude or intrude to distort it--can put an image or video on the shape to see the image or video distorted

jit.gl.physics or jit.gl.physdraw (or something like that) object--> should emulate some natural physical movements, like a ball bouncing against a wall

jit.gl.multiple object --> if you want a whole bunch of the same thing, instead of adding shapes or whatever individually--once it reaches the maximum number you specify, it'll stop

*from reading: wireframe mode allows you to see 3D shapes as a grid

Tuesday, March 3, 2015

Class notes 3/3: JS for Max

JavaScript is object-oriented programming.  That means it has properties and methods.

Start by specifying "inlets = " and "outlets = " properties.

function name(1,2,3) {
           method();
           method();
}

A function can have arguments.  Above, 1,2, and 3 are arguments.

Useful method in Max: outlet(1, "bang");--this will send out the outlet on the right, whereas outlet(0) sends out the left outlet--try to keep right-to-left order as is typical for Max.

function anything() {

This means, if anything comes in other than what's already defined, do this.
A function can call another function within it.

In JS, no distinction between ints and floats.  In Max, yes.

At beginning of script, set variables.  In JS, equals sign means "set this to this."  A double equals sign == means is it equal to?  Testing if the logical expression is true or false.

var x = 0;

Any variable you set outside of a function is considered a global variable.  That means it's accessible from any part of the program, but that doesn't mean it can't be changed in a function.  A local variable only exists within a function, and it ceases to exist after that.

Set up script so if people put the wrong things into the object, sends out an error message--can do this function-by-function.

function msg_int( incoming)  {
That's a function that allows an integer to be input, can set that to a variable to store it, and/or can send it out immediately.

A function in a JS script is a potential incoming message from Max.  So you might have function msg_int, or function msg_float, or whatever other message might come in.

isNaN means "is not a number"--so if incoming isn't a number, can send an error, or whatever

Arrays:

thearray = new Array(1);

array name = new Array(# of arguments);

myfavoritearray = [32, 76, 95.3, "chris"];

Very much like a coll object, numbered automatically with index numbers

while loop-->set an initial condition, keep testing condition, if it's this, do this--have to also set a stop condition


Sunday, March 1, 2015

JavaScript in Max article

js object

JS is for scripts within web pages.  Uses core JS, not client-side JS.  Save as a text file with a .js extension somewhere in Max file search path, then type filename as argument in js object.

Default 1 inlet, 1 outlet; specify this at start of script.

Create a function()