Tuesday, January 27, 2015

Class notes 1/27: more useful MIDI objects

kslider object--gives you little visual keyboard, it'll tell you the number of the pitch when you click on the keys--or you can get these numbers from the little keyboard in the documentation

mtof--MIDI pitch number to frequency

Velocity signals are usually interpreted by receiving device as amplitude, but some synthesizers may be more sophisticated and emphasize different frequencies depending on velocity to mimic different acoustic instruments.

4n is quarter note, 4nd is dotted quarter note, 8nt eighth note triplet, or you can calculate triplets by number of ticks--to have both duple and triple feel in same piece, send each of those messages differently, or different metros

timepoint object--specify moment that you want something to happen, can be 29.1.0 (bar 29, beat 1, tick 0)

metro has attribute called @active, which means whenever the transport is on, that metro will be on--another attribute called @autostarttime (or something similar), which allows you to specify when metro turns on

drunk object--kind of random generator, not quite as random as random object

urn object--generates numbers like random object but won't repeat numbers--if you keep banging once it's out, it won't change its number but will send bangs out right inlet--can input message "clear" to restart it--Dobrian trick is to connect right outlet of urn to inlet of "clear, bang" message so it restarts automatically after it gets to the end

random object--randomness is maybe impossible? to define, b/c we actually have very little or no experience with things that are random in the universe--in computers, pseudorandom--uses deterministic system, different programming languages have different ways of doing it and expressing it--can constrain number of random possibilities in Max, so can say random 12 (gives you twelve possibilities) or send 12 in right inlet--every time it's banged, it sends out integer number between 0 and 11--if you don't give it an argument, it only chooses 0--random object only deals with positive integers

decide object--random object, but just for 0 and 1, same as random 2

noise~ object--generates white noise, can filter it to create different effects, can sample it

sah~--sample and hold, samples noise, but only when receives triggering message in R inlet--triggering message can be cycle~ object, which samples white noise 8 times per second and sends it out--add one (so it's not negative), can mess with it from there (multiply it by a frequency, etc.)

prepend object--takes whatever you type in as argument, puts that argument before whatever comes in the inlet and sends them out together

append object--same as prepend, but puts argument on end of whatever comes in inlet

text button--can have button mode or toggle mode, if toggle mode, can have diff't messages depending on whether it's toggled on or off

table object--only stores integer numbers, whereas coll object stores floating point numbers

if object--works like an if;then statement

when object--reports the time in measure, beat, and ticks, have to unpack it though

MIDI deals with equal temperament, although some synthesizers you could send to might be able to handle other tunings--MSP gives you really specific control over pitch, so that would be a better way to work--but you can use Max to map onto a tuning system you've devised yourself, using a coll object would be one way

Middle C is 60--if you divide any pitch number of C's by 12, the remainder will be zero.  Therefore:
modulo 12 operation, %: gives you remainder when divided by 12, so C is 0, C#'s are 1, D's are 2, etc.--gives you pitch class of each note--so you could find a way to multiply each pitch class by a certain number to detune them

TO LOOK INTO: umenu, drunk

Thursday, January 22, 2015

Class notes 1/22: debugging, critique of rhythm patcher, sub patchers, transport object

stack overflow--prevents outlets from sending out more information until overload problem is fixed

Critique of Rhythm Patcher:
I'm adding modulating frequency to carrier frequency, pushing it all to clipping levels.  Have to put +~ object BEFORE cycle~ (carrier frequency) object and do +~82 so that you have carrier frequency at proper place.

Add something down at bottom that multiplies them all by a smaller number, because adding all 6 together will still clip otherwise.

Modulating with a sawtooth wave will still clip, despite the smoothing formula. To use sawtooth type wave, phasor is fine, or rampsmooth~, which adds in some filtering.

Embedded patchers--When you have the sub-patcher made, highlight all things you want to be made into one object, select Edit, Encapsulate--makes single object starting with p, click on it to open sub patcher.  Also creates inlet and outlet object in sub patcher, which show up as regular inlets & outlets in main patcher.  Can also do this by saving a patcher normally with a title like "chrisosc~," and then you can use that as a sub patcher in all your other patchers.

pack object--send several number boxes into it, it turns them into a list and sends them out as a unified list

unpack object--gets list in inlet, sends messages out through separate outlets

function object--makes shape you want using little dots that are connected, to delete dots, shift-click

Ways to think about time: absolute time, frequency (kind of the inverse), metronome time

transport object--separate clock/timekeeper that thinks in musical terms, tempo, bars, beats, etc.--turned on or off with 1 or 0, but it's not a metro, which thinks in relation to absolute time--make transport object with toggle, then metro 4n (to make quarter notes, for example), and metro will now know what 4n means--default tempo of transport is 120--input tempo message

tempo message--tells tempo to transport object, type "tempo 48" or whatever tempo into message box

Tuesday, January 20, 2015

Class notes 1/20: MIDI history, messages

Musical Instrument Digital Interface (MIDI), since late '70s, early '80s.

BINARY
1 byte = 8 bits = 256 ways to represent information  (2^8)
10101101-->  first 1 is MSb (Most Significant bit) and last 1 is LSb (Least Significant bit)

HEXADECIMAL  (colors in HTML use this, a few other things)
0123456789ABCDEF
A0 is hexadecimal for 160 (A is 10*16^1 plus 0)

Dave Smith suggested to synthesizer manufacturers who were considering using computers to control their products to create a language they could all use.  Receiving device actually creates the sound.

Macs have CoreAudio and CoreMIDI built in to their operating system, and Macs include AudioMidiSetup application automatically (hidden in a subfolder, search for it).  They both also have a MIDI device built in.

midiin object--when patcher locked, can select input device--also digital ways to send MIDI to another program, like GarageBand

128 possible gradations of velocity in MIDI
"note on" message with 0 velocity does same thing as "note off" message

SERIES OF BYTES IN A MIDI MESSAGE
status byte (tells you what kind of message it is, starts with 1 so it's over 128 and not a velocity message, 128-255)
data byte (starts with a zero, 0-127, the actual content of the message)--the number 60 means middle C, then move chromatically from there
velocity (0-127, where 0 means key has been released--or you can send note off specific message, and then the third byte will be release velocity--we don't use this very often)

-MIDI sends no information about duration-  Inventors thought this would be used in real time, in performance, so people would be pressing and holding keys to determine duration.  Receiving device can contain internal processing to measure duration.  That's how a sequencer works--it has a tempo going, uses tempo info to figure out where beats & durations are.

Pitch bend messages can also be sent--224 is status byte meaning pitch bend, then fine pitch bend value, then coarse pitch bend value--some devices put 0 in that middle slot and don't use it, some devices combine fine and coarse bend into one 14-bit number so there's much finer pitch bend resolution--8092 is medium bend--receiving device decides how much bend the pitch wheel will actually give you, a lot of devices use two semitones up and down as a standard

Program change message: changes sound (piano, for example) to some other sound

pgmout object--sends out easy MIDI message to change sound--also internally prevents you from sending out messages outside the 0-127 range

midiout object--considers every number you input to be a byte, you have to program it all manually

notein--looks at MIDI coming in, only responds to note on and note off messages--sends out channel, velocity, and pitch information, just the stuff you care about--or you can type in the device/channel you want after that, and it'll get rid of that outlet for you

noteout--takes in pitch, velocity info, sends out pitch, can specify channel

*when programming, make sure you program a way to end a note or sound

channel information: last four bits of status byte--first channel is 0000, second channel is 0001, etc.--computers have channels 0-15, we humans call it 1-16

bendin object--gives you a simple 0-127 readout of pitch bend, with 64 being middle spot

ctlin object--Mod wheel and other controllers, can select them from the object

ctlout 123 1--input 127 as a message, that's reserved in MIDI as the "panic" messages that turns everything off

makenote object--expects to receive pitch, velocity, and duration--sends out pitches & velocities--tags each note with a duration value, schedules a note off for that pitch in the future

*counter object is good for making chromatic scales, just specify which pitches to start & stop

An array is a stored list of information, use index (#s starting at 0)--can use to store preferred pitches, etc.

coll object--lock, double click, opens editing window to type in what to store, in format "1, 60;"--as in, when you receive the message 1, output middle C--like line by line programming--array doesn't automatically get saved with patcher, use the inspector to "embed", or else type "coll @embed 1" right into object IMMEDIATELY--otherwise it'll erase your whole array you've already typed when you try to save it, embed it FIRST

also object called table (stores numbers, very simple), buffer (stores numbers)

Monday, January 19, 2015

Problems & notes while making "rhythm" patcher

I've managed to set up six LED buttons, each of which controls a sine wave that's being modulated by another wave to vibrato a few times a second.  The pitches form a not-quite-harmonic series, which makes it sound nice and crunchy.  I'm hoping that, when I put them all together, the result will be rhythmically interesting, and the user would be able to turn each of the six tones on or off to change the sound.

Unfortunately, now that I've got the buttons to do what I want them to do and added a gain control for each of the six sounds, I can't hear anything coming out of my speakers.  The dac~ is on, and the level meters in Max itself are registering mostly what I'd expect.  I just can't hear the signals aloud, except occasionally in unexpected ways.  Replacing the dad~ with ezdac~ makes no difference.

*I've now realized the cycle~ object doesn't understand "start/stop" or "0/1" messages.  I have to figure out how to turn each of the six sounds' audio on and off independently.  Either I'll have to put in six different dac~ objects (doubt it will work), or I'll have to find a different way to start and stop each sound going.

*Lizzy helped me to figure this out.  First of all, I had to add a line~ object to each sound so that I didn't get nasty clicks when starting and stopping the sounds.  You have to add floating-point messages (0. and 1.) to the input values for that to get it to ramp up (1.) and ramp down (0.).  Then I added a route object right below the LED buttons, with the choices of 0 and 1, which then bang the line~ object with either 0. or 1. messages to ramp up and ramp down the signal to full volume, and then the master volume of each sound is controlled by the live.gain faders.  Very nice of Lizzy to teach me that.

Thursday, January 15, 2015

Class notes 1/15: modulating signals, time & computers

For controlling volume, use numbers between 0 and 128 (max volume).

Shift key allows you to make multiple connections at once.

If sound is too soft, how do we figure out the multiplier to get it to the correct volume?  In Audacity, there's a normalization function that fixes things.

loadmess~  When the patcher loads, send out this (short) message.

live.gain~   Slider that scales volume for moderate loudness, shows dB of output.

Modulating one signal by another:
This is why you'd scale a signal to a smaller amplitude and then use an add function to push it up towards +1.  It can be used to modulate the amplitude of another signal, say a cycle~ 440, to create tremolo (and eventually other effects).  Send the modulating signal into a multiplier and then to the signal you want to modulate.  If you send it directly into the frequency you want to modulate (the cycle~), it will create vibrato (pitch variation) instead.

Modulating signal can be amplified by a lot (times 12, for example), to change "depth" of modulating oscillator.  (Think of that as the amount of the modulator's effect.)

If you bring modulating signal really wide and up in frequency into audio range, can get whole host of strange harmonics.


Time:
CPU clock, crystal vibrating at known frequency installed in each computer--each vibration allows circuit(s) to be closed and opened.
CPU speed is like 2.4 GHz now, it's really fast.
Computer tries to do tasks you give it as fast as possible.  What if you want a computer to do something at a slower, pre-determined rate?

metro~  Outputs a bang message at regular intervals.  (Time expressed in milliseconds.)  Right inlet can be connected to number box that will change intervals.  If you want to set a tempo of beats per minute, use !/~ to divide bpm into 60,000 and will calculate how many ms between beats for you.

counter~  Counts the number of times something has happened--output left outlet to select~ 7 (or whatever number) and output select 7 to a zero message to tell it to stop after that.  *It starts counting at zero, so saying select 7 will stop it after 8 times.

"ABCDE" Patch Critique

-ezdac~ doesn't understand "bang," just "start" or "1," so you need to bang a message box that sends that message to ezdac~

-open in presentation mode--from Patcher Inspector

-think about where and how graphics should look when it opens, position, window size (Max will save window size, too)

-add a comment to presentation mode to specify that those are pitches, not the keys to press on the keyboard

Tuesday, January 13, 2015

Class notes 1/13: cycle, scope, plot, meter, line

cycle~ is a single sine wave oscillator, can choose the frequency.  Sends out a full-amplitude wave.

scope~ tries to draw a visual sine wave for you, representing the signal

plot~ will plot audio information, but you have to define the axes and scale in an input message

meter~ gives you a green-to-red sound meter, if you put a number box at output, gives you numerical level

*~ multiplies--helpful for adjusting volume, since automatic output from oscillator is at volume 1.  Shouldn't adjust this instantaneously, as it will create a click.  Need to gradually adjust volume.  Do this with -linear interpolation-.  Instead of a number box with a multiplier in it, replace with:

line~  whole job is to do linear interpolation, sends out audio signal, in R inlet wants the amount of time to get to new value (in milliseconds), in L inlet wants volume it should go to, or you can input them as a list into the L inlet

None of the meters will work unless the DAC is turned on.  Think of the DAC being on as Max being able to process audio information.

Apparently, I can't hear much above 18,000 Hz.

Monday, January 12, 2015

First Patcher Problems

I managed to create a patcher that plays five thumb piano samples (A, B, C, D, and E) when five keys on the keyboard are depressed (A, S, D, F, and spacebar).  That took some trial and error.  The big difficulty, though, is inserting image files appropriately to represent that visually.  I've tried a couple of things, and fpic seems like it will be the best way to get pictures in there.  Right now, I can't get the "auto fit" attribute to change, which is frustrating, because that's what's standing between me and a completed patch.

I noticed that Max's path for searching for audio files reverted back to the original after I closed my session last time.  I thought that, once I set a search pathway, Max would retain that, but I guess I'll have to re-input it each time?  I hope there's a way around that.

*Revision 1/15  Max somehow started retaining its search pathway.  Weird bug.

Wednesday, January 7, 2015

Digital Audio article by CD

-It would be cool to have a listening session with audio examples recorded at various sample and bit rates, as well as examples recorded with some analog technologies, to hear the differences.  It would also be good to hear clipping and aliasing, so that I can listen for these things in my own work.  Access to different speakers?  Different sets of headphones?

-I'd like to get more in-depth on the mathematics of synthesis.  Are we going to do FFT's in this class?  Analysis of acoustic sounds?  Designing synths from that?

-A-weighting sounds for human hearing