A very simple grammar

Quit BP2 and double-click "-gr.doeslittle" in the "BP2 examples" folder. This will start again BP2, bypassing the welcome dialog, and the content of the "Grammar" window will be displayed as follows :

-se.doeslittle
// A very simple grammar that does almost nothing

RND
S --> C4.C5.D5 C5 F#4.A4.C5
S --> G3 C4_ B3 C4
S --> {C5 D5 E5 F5, G5 D5 C6}

Type cmd-k or select "Compile" in the "Action" menu. BP2 quickly compiles the grammar, i.e. it generates some internal code ( tokens) that will enable it to produce items.

Now type cmd-r ("run") or select "Produce items" in the "Action" menu. After a short while an item is displayed in the graphic score and played on the MIDI output. You are given the option to produce more, play again, display as text or cancel. When producing more you will notice that the inference engine (the machines that "runs" the grammar) selects any of the three rules in the grammar to produce an item. This selection is random with equal probabilities, as stated by the instruction "RND" on top of the grammar.

The operation of this grammar is very simple : it starts with a work string containing only 'S', the starting symbol. A rule is selected at random. The selected rule replaces 'S', its left argument, with its right argument. Then no change is possible any more ; the item is displayed and played.

Type cmd-option space or select "Settings" in the "Windows" menu. A "Settings" dialog in two parts is displayed, along with three more option dialogs. These will be analysed in greater detail (see Fig.24 in §5.2). These settings have been loaded automatically from the file "-se.doeslittle" whose name appears on top of the "Grammar" window. For the time being, just watch the checked items : "Show graphics" forces graphic display, and "Use MIDI in/out" allows items to be played on the MIDI device. You may for instance check "Non-stop improvize" button and type cmd-r again. Now BP2 produces items continuously. To stop the production, hold the mouse button down and then click "STOP" when the red dialog appears in the top-left corner.

Improvizing on a slow computer may look deceiving because BP2 takes time to produce a new item and does not keep the tempo. Check the "Compute while playing" button to allow BP2 to proceed with calculations and keep items ready to play in a queue. If the grammar is not too complex, the tempo will be maintained. The drawback is that when you click to stop the improvisation, items still in the queue may continue playing. Clicking again will abort playing, but it may keep a note hanging because its 'NoteOff' has not been received. Flush the output clicking the "MIDI PANIC" button on the "Control Panel".

Every time the grammar is run it produces exactly the same sequence of pieces. This is due to the fact that BP2 resets its inner random number generator unless the "Allow randomize" button is checked on the upper "Settings" dialog.