6. Interactive
control
When
the "Interactive (use input)" button
is checked on the lower "Settings" dialog
(accessed by typing cmd-option space, see Fig.24 in §5.2), BP2 keeps
listening to messages received on its MIDI input and may react to them if
instructed to do so. It keeps listening even whe it is not doing anything
particular such as improvizing music or running a script.
Instructions
on how to react are stored in a "-in.<name>"
file displayed in the "Interaction" window.
The format of these instructions is part of BP2's script language, therefore
it is convenient to say that the "Interaction" window contains a script.
Conversely,
BP2 produces MIDI messages, some of which may be used to trigger processes on
external devices (including copies of BP2). For instance, BP2 is able to start
any
process when prompted by the appropriate MIDI message. This is possible thanks
to the instruction
IN
On “note” channel “1..16” do “script
instruction”
which
will execute the specified script instruction at the time a NoteOn message is
received, including running another script if “script instruction”
is:
Run
script “filename”
Caution:
this instruction will only work if BP2 finds the specified script (or its
alias), either in the start-up directory (the one in which you did a
double-click to start BP2), or in the latest directory in which a script was
found during the current session. Otherwise, BP2 will prompt the user to
locate the script.
6.1 When
does it react?
BP2
does react to MIDI input provided that (1) it is in the appropriate format,
i.e. the message has been declared in the "Interaction" window
("-in.<filename>" file), and (2) both the "Interactive (use input)"
and "Use MIDI in/out"
buttons on the lower "Settings" dialog
are checked (see Fig.24).
The
status of these buttons is saved and loaded along with "-se.<filename>"
settings files. Each time a project, grammar or data is loaded, their status
might therefore change. Also make sure that a file has been loaded to the
"Interaction" window, or load it manually if necessary: its name will be
inserted on top of the "Grammar" and "Data" windows, so that it may
automatically be loaded next time you start the project.
A
third condition for BP2 to react to MIDI input messages is that it has free
time. Messages are stacked into the MIDI input buffer waiting for BP2 to read
them, which it does as often as possible. A delay in the response may be
caused by the fact that BP2 was engaged on some more urgent task.
Apart
from launching scripts, many parameters controlling BP2's operation may be
directly modified via the MIDI input, as demonstrated below.
6.2 The
MIDI filter
Let
us check the ability of BP2 to receive and transmit MIDI messages. Select
"MIDI filter" in the "Misc." menu.
Fig.25
The MIDI filter dialog
Checked
boxes on the left indicate which types of MIDI messages are currently received
by BP2. Some of these messages may activate processes, as we will see later.
The right column indicates which messages are transmitted to the MIDI output.
Transmission may be necessary if BP2 is part of a chain of MIDI devices --
unless you connect other devices to the "MIDI thru" output of the computer's
interface.
If
a box is checked in the right column the corresponding box is automatically
checked in the left column, because a message cannot be transmitted unless it
is received.
Settings
shown Fig.25 are the default settings recorded in "-se.startup". If you load
project "-gr.koto3"
the MIDI filter dialog will display the settings found in "-se.koto3".
Clicking the "Reset" button makes it possible to retrieve start-up settings.
BP2
keeps receiving and transmitting messages (at idle time) provided that the "Use
MIDI in/out" button is checked on the top "Settings" dialog (type cmd-option
space, see Fig.24). If the option is not checked you will be prompted to turn
it on when displaying the MIDI filter dialog.
6.3 The
"Interaction" window
Suppose
that the project "-gr.koto3"
has been loaded. Before playing the first item, BP2 loads interactive code
file "-in.abc1" that contains the actual information the project needs for
external control. The file is loaded just before the first item is played if
"Interactive (use input)" is checked on the "Settings" dialog.
File
"-in.abc1" appears as follows:
BP2
script
Note
convention = English
IN
Synchronize start ON-OFF F#4 channel 15 [toggle]
IN
Repeat 'v' times D5 channel 15
IN
End repeat G5 channel 15
IN
Repeat forever E5 channel 15
IN
Derive further A4 channel 15
IN
Reset weights B4 channel 15
IN
Quit F5 channel 15
IN
Use each substitution G#4 channel 15
IN
Set computation time to 'v' F4 channel 15
IN
Smooth-striated time E4 channel 15
IN
Use-ignore object constraints C#5 channel 15
IN
Skip next item D4 channel 15
IN
Play again item D#5 channel 15
IN
Min 10 ticks in 3 sec C6 max 20 ticks in 3 sec C7 channel 15
IN
Synchro tag W1 = C3 channel 15
IN
Synchro tag W2 = C#3 channel 15
IN
Synchro tag W7 = D3 channel 15
IN
Synchro tag W8 = D#3 channel 15
IN
Parameter K10 = velocity C8 channel 15
IN
Param K1 = controller #7 channel 15
IN
Param K2 = controller #17 channel 15
IN
Param K9 = controller #0 channel 15
This
file is actually a
script.
Instructions appearing in the "Interaction" window belong to the subset of
well-formed script instructions. (See the entire set in the "Script" menu.)
The
order of instructions in the "Interaction" window is not relevant. The only
instructions that should appear on top are "BP2 script" and "Note convention =
..." indicating the convention used for interpreting the following
instructions. If another note convention is selected in the "Misc" menu, the
content of the "Interaction" window is automatically translated to the new
convention, and the second instruction is modified or created accordingly. In
this way, interactive files remain consistent with projects using different
note conventions.
The
compiler checks the consistency of instructions: if for instance the same key
or controller is assigned several tasks, an error message will be displayed.
New
instructions are entered by pulling down the "Script" menu when the
"Interaction" window is active. Slots may then be filled with the required
values. Remember that you can enter note names by hitting a key on the MIDI
keyboard once "Type from MIDI [toggle]"
(cmd-j) is active. All instructions are documented on-line: type cmd-? and
pick an instruction in the "Script" menu.
6.4 Distributed
improvisation
Interactive
controls make it possible for several BP2's and other MIDI devices to
collaborate on the same MIDI 'network'. Communication is generally done on a
reserved MIDI channel, here for instance channel 15.
You
must set the MIDI keyboard to channel 15
to be able to interact with project "-gr.koto3".
Consider
for example:
IN
Synchronize start ON-OFF F#4 channel 15 [toggle]
IN
Start play C5 channel 15
The
first instruction (a toggle command) assigns key F#4 to instruct BP2 to accept
or ignore 'Start play' instructions. When BP2 starts improvising, its response
to 'Start play' depends on the setting of radio button "Synchronize start" on
the "Settings" dialog. (It might also have been changed by script instructions
"Synchronize start ON" or "Synchronize start OFF".) It will be changed again
by key F#4 channel 15.
The
second instruction is the 'Start play' definition itself: BP2 should wait for a
NoteOn of key C5 channel 15. If this instruction is missing, then instead of
waiting for a NoteOn BP2 will wait for a 'Start' or 'Continue' MIDI message.
Note
that this amounts to the same as inserting a performance control "_script(Wait
for C5 channel 15)" or "_script(Wait for Start)" in the beginning of each item.
However, once defined in the "Interaction" window, the 'Start play' instruction
may be deactivated and reactivated by key F#4.
'Start
play' is useful for synchronising the beginning of a musical item accurately.
The 'start' message may be sent from a MIDI keyboard or from any other MIDI
device, including another BP2. For instance it could be (it
is!)
the 'sync' sound-object terminating every production in grammar "-gr.koto3".
With two computers connected to MIDI, you may run project "-gr.koto3" on both
and see how they collaborate... Don't forget to set up "Interactive (use
input)" on both machines. Then modify the grammars to give an 'individuality'
to each one. It works? You've entered the world of
distributed
improvisation!
Can you figure out a set-up with more computers, including humans messing
around?
Sending
a NoteOn on key C5 channel 15 otherwise prompts BP2 to play an item
immediately. If BP2 is still busy computing the item, several flags will be
set so that production is terminated as quickly as possible (by-passing all
constraints). This is an equivalent of "it's up to you now" signals used by
jazz musicians in a band.
6.5 More
interaction!
Here
are a few hints for using the interactive features of BP2 in a set-up that
would comprise several computers with various MIDI software, and human
musicians interacting with keyboards or MIDI instruments.
Limitations
are mainly with MIDI channels: several channels are required to play different
instruments or to connect different keyboards, and a few remaining channels may
be assigned to "non-musical" communication. Don't forget to set MIDI devices
to OMNI OFF
so that control messages are not audible.
Let
us look at a few instructions contained in "-in.abc1".
IN
Set computation time to 'v' F4 channel 15
instructs
BP2 that every NoteOn received on F4 channel 15 assigns a limit value to the
computation
time
of the current item. The limit is a function of the NoteOn's velocity. This
is a way to tell BP2 it should come up with an item ready to play before some
other process has been completed. (For instance another BP2 is currently
playing the preceding item and it is able to figure out its maximum duration.)
If
v
is the velocity of the NoteOn on key F4, computation time may not exceed 472
v
(in
milliseconds).
IN
Min 10 ticks in 3 sec C6 max 20 ticks in 3 sec C7 channel 15
instructs
BP2 that all keys between C6 and C7 on channel 15 contain a new setting of its
time base (and metronome). Here, C6 will set the time base to 10 ticks in 3
seconds, and C7 to 20 ticks in 3 seconds. Keys between C6 and C7 will assign
interpolated values.
A
'change tempo' instruction could be imbedded in a particular musical item.
Thus, BP2 may instruct its neighbours that the metronome has changed. It may
also change its own metronome using "_script(Tempo ... ticks in ... secs)". A
good idea is to follow the 'change tempo' instruction with a 'skip next item'
instruction using key D4 channel 15 as instructed by
IN
Skip next item D4 channel 15
IN
Set tempo controller 0 channel 15 range 4.5
The "Set tempo"
controller is a MIDI pedal changing the metronome speed. "Range 4.5" is the
ratio between the maximum value and the minimum value. If the controller is in
its medium position (64) then the metronome value is the default one.
IN
Parameter K10 = velocity C8 channel 15
IN
Param K1 = controller #7 channel 15
These
instructions allow the setting of
control
parameters
K10 and K1, respectively, by MIDI devices: K10 is set to the velocity of a
NoteOn message on key C8, channel 15, and K1 is set to the value of MIDI
controller #7, channel 15.
Remember
that K1,... are global variables that may be used as
weights
in grammar
rules, arguments of
performance
controls
(e.g. _volume(K10), see §1.10), or comparison values in flags (see
§11.2).
6.6 Synchronisation
tags
Consider
the following instructions:
IN
Synchro tag W1 = C3 channel 15
IN
Synchro tag W2 = C#3 channel 15
IN
Synchro tag W7 = D3 channel 15
IN
Synchro tag W8 = D#3 channel 15
These
define
synchronisation
tags
notated <<W1>>, <<W2>>... Each tag is assigned an
input
sound-object. When
BP2 finds a tag within a structure of sound-objects it stops everything
(including its internal clock) until the input sound-object is received, i.e.
the corresponding NoteOn is received or the mouse is clicked. This allows you
to synchronise any performance on notes or sequences of notes expected at a
particular time.
Suppose
that you have typed or produced the following item:
a
b <<W7>> c <<W1>> <<W3>>
<<W8>> d
(Use
example in file "-da.trytags")
BP2 will play 'a' and 'b' normally, then it will display a message indicating
that it is waiting for "D3 channel 15", i.e. the <<W7>> tag. You
may actually depress the "D3" key , send a NoteOn or simply click the mouse.
BP2 will then continue playing 'c' and hang again waiting for C3, the
<<W1>> tag. Now it must stand on the <<W3>> tag, which
is not defined, so it prompts you to send a mouse click. Eventually, it will
hang on <<W8>>, prompting you to play D#3 or send a mouse click.
When done, BP2 will play 'd'.
Synchronisation
tags
may appear in polymetric expressions
as well. Each tag relates to the sound object immediately following it in the
same sequence. For instance, the item
b
b <<f>> {5, a c b, f - <<W8>> f} a <<chik>>
b <<sync>>
yields
exactly the graphic output shown Fig.17, but the <<W8>>
synchronisation tag will force BP2 to wait for a click or D3 channel 15 before
it performs the second occurrence of 'f'. The score table below (Fig.26) makes
it clear that the actual interruption separates the item in two parts:
Fig.26
A phase diagram for
"b
b <<f>> {5, a c b, f - <<W8>> f} a <<chik>>
b <<sync>>"
Synchronisation
tags are processed as
out-time
sound-objects
but they represent "input" instead of "output" sound-objects. They are also
less complex than other out-time objects because they may only be defined as
NoteOn's. Undefined tags react to mouse clicks.
Synchronisation
tags have been implemented in an earlier version of BP2, at a time scripts and
performance controls were not available. A tag like <<W8>> could
equivalently be replaced with any variable rewritten as:
_script(Wait
for D#3 channel 15)
6.7 Apple
Events -- BP2 in a client-server environment
Bol
Processor BP2 is designed for
client-server
technology. First
of all, BP2 can run in background. For instance, after launching an
improvisation or a script, clicking outside BP2 (in the Finder or any other
application window visible in the back) sends BP2 to
background.
This means, it continues its job, including playing sounds through the MIDI
output, while the user is doing (almost) anything else on the same computer.
Indeed, running several applications implies that enough RAM space is available
and the machine is good at sharing resources in an efficient way.
In
addition, BP2 responds to
Apple
Events,
i.e. events that enable communication between different applications under
MacOS. A typical "client" application is supplied to show the range of
possibilities. It is a Claris® FileMaker Pro database named
"TryAppleEvents.fm",
which contains scripts telling BP2 to do certain things, and explanations on
the actual operation.
If
it does not work, check Apple Events created by the FileMaker scripts (call
"ScriptMaker" in the "Script" menu of FileMaker 3.0). Each event appearing in
the script should show "BP2.9.3" as the target, not "<unknown>". If it
shows "<unknown>" it probably means that "TryAppleEvents.fm"
is not in the same folder as "BP2.9.3", or the desktop needs to be rebuilt.
Note
that FileMaker Pro 3.0 does not recognise an application on a remote disk,
which means it is not able to send a remote Apple Event even though BP2 would
be able to process it.
The
environment should be arranged properly when BP2 is used as a server. It is
recommended that no client application hides the bottom part of the screen on
which BP2 displays messages. The top left part is also useful to see that BP2
has received a "pause" event and is waiting for "resume" or "stop". Doing so,
its activity can be controlled without bringing BP2 to the foreground.
The
list of currently available Apple Events is found in the on-line documentation
under the "Apple Events" entry accessed in the "Frequently aked questions..."
dialog. The current version processes events sending musical 'scores' in text
format, BP2 scripts, and various tasks such as loading a settings file or
changing the note convention.
The
client-server technology
has tremendous potential. BP2 is so far a unique MIDI software able to handle
musical material as
text
(scores and
processes
such as grammars or scripts). This data may be stored in the fields of a
standard database working as a client of BP2.
BP2
may in turn
send
Apple Events
to other applications (running on the same computer) thanks to script
instructions:
AE
send normal class '“AEclass”' ID '“AEID”' to
application '“signature”'
AE
send fast class '“AEclass”' ID '“AEID”' to application
'“signature”'
The
difference between these two instructions lies in the priority which the Finder
will give to the event.
Note
that in the current version, the target application must already be opened,
failing to which the Apple Event won't be able to reach it; in other words, BP2
does not launch applications.
If
you are working in the field of graphic animations you may take advantage of
BP2 as a server for producing high-quality music on MIDI devices. Random
improvisation may be an important asset: each time the animation is played part
of the music track will be composed afresh.