Music 159: (visual) programming for music

On this page you will find some hints and links to experiment with computer-aided composition processes related to my Music-159 lecture on visual programming for music.

The support slides of the class are available here (PDF).

The main course materials are patches for the om7 visual programming environment. om7 is a work-in-progress prototype inspired from the OpenMusic (OM) computer-aided composition environment.1) It should be easy to get started and experiment with; however, do not hesitate to contact me if you have any problem with it.

— download

om7: https://github.com/openmusic-project/om7/releases

Additional downloads (optional):

— doc

class materials

All om7 and Max patches are available here.

— patch 1: basics

This patch is a simple example of how to:

- instanciate a simple midi-note object,
- abstract this process as a sub-patch,
- use this subpatch in lambda-mode to generate a sequence of notes,
- apply some treatments on the sequence using the same procedure.

— patch 2: sound processing

This patch is an introduction to the sound processing operators in OM:
SOUND-CUT, SOUND-FADE, SOUND-MIX, SOUND-SEQ, etc.

We apply similar procedures to:

- generate a small grain extracted from a source sound,
- abstract this process as a sub-patch,
- use this subpatch in lambda-mode to generate a set of grains using MAPCAR,
- apply a higher-order function as combinator to sequence the grains using REDUCE,
- save the result as a new sound file.

— patch 3: sound synthesis (Csound)

This patch uses the CS-ARRAY object from the OMChroma library.
⇒ Get OMChroma for om7 here: https://forge.ircam.fr/p/omchroma/downloads/

CS-ARRAY is a 2D-matrix matched with a Csound instrument. When first eveluated, the "source-code" and "instr-num" inputs will determine the instrument within a Csound orchestra, and the rest of the "optional" slots of the matrix will be initialized accordingly.

The matrix will generate a number of lines (or "note statements") in a Csound score. This number is determined by the ELTS input of the object and will determine how other, optional inputs are interpreted to fill data in the matrix:
- A single value is duplicated <ELTS> times for each element,
- A list of values is read circularly until filling the <ELTS> values,
- A function (or lambda expression) is evaluated at each cell,
- A BPF is sampled in <ELTS> points,
- etc.

We set these synthesis input values from times and pitch extracted from the previous PIANO-ROLL, which was just copied in this patch. Notes envelopes are determined by a an object GEN07 (a BPF defining a Csound table) that we can edit by hand.

The CS-ARRAY is connected to CS-SYNTHESIZE, which will
1) Format Csound code and write it to disk as two files (score and orchestra)
2) Perform an external call to Csound.

If the "keyword" input <RUN> is set to NIL, CS-SYNTHESIZE will not call Csound and just return the pathnames to the generated Csound files.

Note: Csound must be previously installed and correctly set in the om7 Preferences/Externals tab.

— patch 4: sound spatialization (spat)

This patch is an introduction to the om-spat library for om7.
⇒ Get om-spat for om7 at: https://forge.ircam.fr/p/OM7/downloads/695/.

om-spat embeds native components from the spat~ library as graphic controllers and DSP processors for reverberation, spatialization and other sound effects.

In this patch, an algorithm generates a 3D trajectory (lists of x, y, and z points connected to a 3DC object), and then associates this trajectory to a sound in the SPAT-SCENE object. The other important input of SPAT-SCENE is a list of (x y z) points specifying the positions of loudspeakers. Several sound sources and trajectories can also be connected together using lists (LIST function).

In SPAT-SCENE, it is possible to set some interpolation and rendering attributes. The spatial sound scene can be rendered for instance as a stream of OSC messages, as spatialized/multichannel audio, or graphically only.

The function SPAT-SYNTH performs a run of the trajectories in the scene, generating a N-channels audio file (N= number of speakers) from the specified sound sources.

— patch 5: reactive process

This patch is an introduction to reactive processes in om7. The basic part of it is just an interpolation process between two BPC objects.

The red patch cords and inputs/outputs are reactive: they can propagate notifications of changes in order to automatically update dependent parts of the functional graph. If you edit one of the curves, or the number of interpolation steps, the COLLECTION object at the bottom should automatically update. You can decide which parts of the patch are to be reactive by setting/unsetting the reactivity states of the boxes and connections.

The number of interpolation steps can also be set using the SLIDER object, by command+click-drag, or just click-drag if the patch editor is locked (CMD+E).

In a more advanced setting, we will activate the OSC-RECEIVE box (unset/reset reactive with R) in order to get this value from an external application (e.g. the Max patcher dummy-controller.maxpat).

— patch 6: dynamic sequencer

This patch is actually no a patch but a maquette: a hybrid object at the crossroad between a visual program and a sequencer that really exist only in OM.

The sequencer can be viewed as a set of superimposed musical tracks, or as a program. It also has an attached "control patch" that controls/sets its global contents. All these are viewed/hidden etc. using the buttons at the top of the sequencer view.

This example is a pretty elaborate one. To start with, you can just play with dragging and moving objects around from the om7 patches, create embedded patches in the sequencer tracks etc. A page will be available soon on the online user manual.

In this example, the global execution (flash icon) will evaluate the output of the control patch on the left. This will add a first process in track #1.

This process is reactive: it will be triggered when reached by the play cursor, and perform two actions:
1) Generate qa random sequence of notes (as in Patch #1),
2) Create a clone of itself and add it somewhere later into another track of the sequencer.

The clone will then execute when reached by the cursor, and so on (indefinitely).

In the control patch, a reactive OSC-RECEIVE can also be activated (much like in Patch #5) which will interactively change the number of notes to be generated in the next process call.

— patch 7: odot

This last example illustrates the use of advanced OSC communication, through the use of odot expressions.

Curves (here, BPC objects) can be "executed" in different ways: their "action" attribute (by default, null) can be set for instance to "print", "send-as-osc", etc. It can also be programmed by the user (you!) to perform a specific task.

Here we set the action to be a lambda function created from the sub-patch send-point-bundle which sends and OSC bundle containing the position of the current point, but also a number of odot expressions defining different ways of generating a cloud of points around this central point position.

Note that send-point-bundle box is in mode LAMBDA (set/unset with L) in order to not execute, but return is corresponding lambda expression when evaluated.

The Max patch receiving this data (odot-spat-receive.maxpat) also runs odot and is therefore able to evaluate these expressions in order to convert the received point-bundle to a point-cloud bundle.

1) ⇒ If you want to do more computer-aided composition, you can also download and try out the latest OM 6.12/6.13 releases from Ircam's ForumNet website.
 


bresson/cnmat/m159.txt · Dernière modification: 2019/07/29 23:23 par Jean Bresson