Structures in AMPLE – part 1

Kevin Doyle

There are three main types of structure available in AMPLE:

a) Loops;

b) Conditionals;

c) Conditional loops.

I will examine each of these in turn over the next few issues of AMPLINEX and give examples of their use.

In this issue I will look at loops.

Loops in AMPLE

These are the simplest AMPLE structures and allow a group of AMPLE words to be performed a defined number of times. E.g.

"loop" [ 8 FOR( 48, 0:CDEFGABC )FOR ]

will play the scale of C eight times in succession. This technique can be very useful when a musical part contains a repeating riff which may only change after a certain number of bars. E.g.

"riff" [ 24, -2:GBgC/bg/ ]

"12-bar-blues" [ 0@ 4 FOR( riff )FOR 5@ 2 FOR( riff )FOR 0@ 2 FOR( riff )FOR -5@ 1 FOR( riff )FOR 5@ 1 FOR( riff )FOR 0@ 2 FOR( riff )FOR ]

In the above example the lines containing '1 FOR( riff )FOR' could, of course, have been more succinctly written merely as 'riff'.

FOR(…)FOR loops can be 'nested' to give more complex structures e.g. -

"riff1" [ 24, -1:CCFe ]

"riff2" [ 24, -1:gABC ]

"riff3" [ 24, -1:DDFe ]

"riff4" [ 24, -1:Gfed ]

"loops" [ 4FOR( 2FOR( 2FOR( riff1 riff2 )FOR 2FOR( riff3 riff4 )FOR )FOR 2FOR( riff1 riff2 riff3 riff4 )FOR )FOR ]

There are two AMPLE words which are designed specifically for use within a FOR(…)FOR loop - these are COUNT and INDEX. They both act as counters - the difference is that COUNT starts at 1 and increments by one through each pass of the loop. INDEX starts at the number of loops to be performed and reduces by one until it reaches 1. So,

"upoct" [ 4FOR( 24, INDEX:CDE )FOR ]

will play CDE with octave settings of 4, 3, 2 and 1, whereas,

"downoct" [ 4FOR( 24, COUNT:CDE )FOR ]

will play CDE with octave settings of 1, 2, 3 and 4.

In the next issue I will be looking at conditional structures using IF and ELSE and the use of the logical operators ON, OFF, AND, OR, XOR and NOT.