//midi_monster.h #ifndef __MIDI_MONSTER_H__ #define __MIDI_MONSTER_H__ #include #include #include #include #include #include "y-fluidsynth.h" #include #include #include using namespace std; typedef map > > monsterMap; // typedef vector incomingVec; // typedef vector outgoingVec; struct MidiNote{ int pitch; //strength of pitch value float pitchPercentage; int ival; //strenght of ival value float ivalPercentage; int dur; int overlap_t; int starting_t; int vel; }; class MidiMonster { public: MidiMonster(); ~MidiMonster(); //unlimited in size, int pitch, float g_t map incoming_pitches; // calculate Silence will be true when ever there are no incoming pitches bool calculateSilence; //bool reset_g_t; int num_notes_on; //int note_to_turn_off; //limited by the CHAIN_SIZE - using unique chin sizes to allow for flexibility later and better visualizations vector pitch2map; vector dur2map; vector vel2map; vector ival2map; vector t_ival2map; //time onset intervals vector nno2map; //number notes on to be mapped //maps! monsterMap pitchMap; monsterMap durMap; monsterMap velMap; monsterMap ivalMap; monsterMap t_ivalMap; monsterMap nnoMap; //each map will have this key and the value will indicte if it is locked or unlocked string locked_key; //what fluidsynth actually plays and uses to read the maps vector pitch2play; vector dur2play; vector vel2play; vector ival2play; vector t_ival2play; vector nno2play; //for drawing //methods void store_midi(std::vector< unsigned char > *message, float g_t); void init_improvisor(); void improvise(YFluidSynth* synth, float g_t); int quantize(int numSamples); void push(int data, vector& v, int max_size); void process(vector& v, monsterMap& m, int max_size); string makeKey(vector& v, int max_size); void put_into_map(string key, int val, monsterMap& cur_map); bool map_is_unlocked(monsterMap& m); void lock(monsterMap& m); void unlock(monsterMap& m); void wait_for_unlock(monsterMap& m); void init_all_maps(); int lookup_key(string key, monsterMap& m); int get_val_from_vector(monsterMap::iterator mmit, monsterMap* m);//(vector >& v); int get_some_other_probable_item(monsterMap& m); void draw(float g_t); void draw2(float g_t); long int hash(string key); int sum_histories(vector >& v); pair find_node_position(string key); float mess_with(float y, float g_t); string int2str(int i); }; #endif