/*====================================================/ / Name: composer.h / / Author: Joy Schoenberger / / Date: April 2002 / / Purpose: Header file for composer class for / / CS710 Masters research project: Genetic / / Algorithms for Musical Composition with / / Coherency Through Genotype / /====================================================*/ #include "genmus.h" #include "rng.h" class Composer{ private: void initializeByHand(); // hand-roled initialization used for initial testing only void initialize(); // random initialization of DNA void initializeBroad(); // pseudo-random initialization that allows for more initial possibility // in the first generation. this should lead to broader evolution bool composeNextNote(Note& nextNote, Note prevNote, int numVoices, Chord currChord, bool first, int minPitch, int maxPitch, int noteNum); // The heart of the composition process Phrase composePhrase(); // calls composeNextNote for each note of the phrase // with randomly selected number of voices bool ivalCheckOK(int placedNote,Note prevNote, int noteNum); // checks intervals between prev and next note against // the validIntervals genome int Equilikely(int, int); // standard random integer generator int max(int a,int b){ if(ab) return b; else return a; } // rolled my own min function to make my life easier public: // Constructors Composer (void); // Destructor ~Composer (void); DNA* genMap; // I'd like to protect this, but it makes cross-breeding a pain void display(); // show this composer's DNA void mutate(); // this just calls initialize() DNA* crossBreed(Composer & Mate); // mates this composer with Mate and returns their offspring DNA Song composeSong(); // calls composePhrase for each of four phrases };