

	  \  |_ _| __ \_ _|    _ \       |   |
	 |\/ |  |  |   | |    |   | _` | __| __| _ \  __| __ \
	 |   |  |  |   | |    ___/ (   | |   |   __/ |    | | |
	_|  _|___|____/___|  _|   \__,_|\__|\__\___|_|   _| |_|

	      _ \
	     |   |  __| _ \   __| _ \  __|  __|  _ \   __|
	     ___/  |   (   | (    __/\__ \\__ \ (   | |
	    _|    _|  \___/ \___\___|____/____/\___/ _|


	   By Shawn Hargreaves (shawn@talula.demon.co.uk)




======================================
============ Introduction ============
======================================

I wrote this program over the Christmas holiday of 1995/96, as part of my 
music degree at York University. Most of the initial development was done on 
the PC, but I built the final version on the Atari ST because of the easy 
access to MIDI I/O, and because that was the system most easily available 
within the music department. But now that Allegro has MIDI input functions, 
I can make a PC version with proper MIDI support as well, so here it is!

The Pattern Processor takes a number of musical phrases or "patterns", which 
you can record in realtime from a MIDI keyboard, and modifies them through a 
range of mutation functions based on standard musical devices like 
transposition and inversion. The output material will gradually deviate 
further and futher away from your original inputs, and this process can be 
controlled (to some extent: it doesn't work nearly as well as I had 
originally hoped :-) by feedback provided using the pitch bend wheel.

1998 update: added an option to log the generated music into a format zero 
MIDI file, as well as just squirting it out to an external synth. I don't 
have ready access to an ST compiler any more, so this feature is only 
included in the PC executable, but the code should still build happily on 
the ST. If by some miracle anyone is actually using this program on the ST 
and wants logging functions for it, a simple recompile will hopefully be 
enough to provide them.

There are a lot of problems with this system, but every now and then it 
manages to produce something pretty cool, particularly when it comes to 
complex rhythmic and textural material, so I think it turned out quite well 
considering how experimental the whole idea was.



======================================
============ Requirements ============
======================================

You will need a MIDI keyboard with a pitch bend wheel and sustain pedal. If 
you have an Atari, just plug it in and you are ready to go. If you are using 
a PC, you will need an MPU-401 or SoundBlaster compatible MIDI interface, 
and this may need to be configured before it will work properly.

First, just run the program and see what happens. If all goes well you 
should hear a metronome tick coming from your synth (this defaults to the GM 
hihat sound, but can be changed using the -c{channel} and -n{note} 
command line options), and wiggling the pitch bend should move the slider 
bar at the bottom of the screen. If this doesn't work, edit the sound.cfg 
file to reflect your hardware settings. For output you can set the midi_card 
variable to any of the supported drivers, but the midi_input_card should be 
set to use the MPU-401 (recommended) or the SB MIDI interface (if the MPU 
doesn't work). You may also need to set some of the port or IRQ variables, 
depending on what settings your card is using.



===============================
============ Usage ============
===============================

When you first run the program you will hear a metronome tick, and can play 
along with this on your keyboard. Various parameters such as the MIDI 
channel and tick speed can be adjusted using the commands listed on the 
screen.

To record a pattern, press and hold the sustain pedal, play some notes, and 
then release the sustain pedal. The program will instantly start replaying 
and modifying this pattern, producing a whole new range of phrases that are 
in some way based on your original input. You can play along with this in 
realtime, and new patterns can be recorded at any point.

It usually works better to input a few short, simple patterns than to play 
long complicated phrases. Try just recording a one octave scale or a single 
note repeated a few times with some interesting rhythm, press the D and M 
keys to increase the output density and mutation rate parameters up to 
around 15, and then sit back and listen to what the program comes up with...

The pitch bend wheel is used to provide value-judgment feedback on whatever 
the program is playing at the time. Upward movements mean that you like what 
you just heard, and downward bends indicate that you weren't impressed. This 
feedback is used when choosing which patterns should be mutated to produce 
new material and which should be discarded, and it also affects the 
probability weightings for each type of mutation.



===============================
============ Files ============
===============================

The source code should be very easy to port, because all the platform 
specific routines are located in sysdep.h. The Atari version was built with 
the Mark Williams C compiler, which is pretty much a bog standard K&R 
system. The MSDOS version uses the djgpp compiler, and requires a version of 
the Allegro library subsequent to 3.0 (ie. one that supports the MIDI input 
functions). If you don't already have this, it can be obtained from the 
work-in-progress link on my Allegro webpages.

   README.TXT  - what you are reading now
   PP.DOC      - my original university project report, in Word format

   PP.EXE      - MSDOS (djgpp/Allegro) executable
   PP.TOS      - Atari ST executable

   MAKEFILE    - makefile for building MSDOS version
   PP.MAK      - workspace script for building Atari version

   SOUND.CFG   - sound hardware configuration for the MSDOS version

   DEFS.H      - data structures and function prototypes
   SYSDEP.H    - machine-dependent routines and portability macros
   DYN.C       - mutators for changing pattern dynamics
   FEEDBACK.C  - routines for processing the user feedback
   HELPER.C    - helper functions for manipulating patterns
   INVERT.C    - mutators for inverting and reversing patterns
   LIST.C      - linked list and probability functions
   MAIN.C      - main program control loop
   MIDI.C      - midi recording/playback routines
   MUTATE.C    - mutation control functions
   PATTERN.C   - routines for manipulating pattern structures
   PCMIDI.C    - MIDI hardware access for the MSDOS (Allegro) version
   PITCH.C     - mutators for changing the pitch of notes
   RHYTHM.C    - mutators for changing the rhythm of patterns
   TRANSPOS.C  - mutators for transposing the pitch of patterns
   UI.C        - simple text mode user interface



===================================
============ Copyright ============
===================================

You can do whatever the hell you like with this program. If you want to pay 
me large sums of money for it, that is perfectly acceptable...


Shawn Hargreaves
shawn@talula.demon.co.uk
http://www.talula.demon.co.uk/
