/* typedef enum { final static int DIM_COHESION=0; final static int DIM_KEY=1; final static int DIM_NUM_LAYERS=2; final static int DIM_RTHM_CONSISTENCY=3; final static int DIM_RTHM_DENSITY=4; final static int DIM_RTHM_LENGTH=5; final static int DIM_SCALE=6; final static int DIM_SECTION_CHANGE=7; final static int DIM_TEMPO=8; } DIM_NAME; // Hungarian: dim typedef enum { final static int LDIM_ACTIVE=0; final static int LDIM_CONSONANCE=1; final static int LDIM_DIRECTION=2; final static int LDIM_INSTRUMENT=3; final static int LDIM_PITCH_MAGNET=4; final static int LDIM_RTHM_CONSISTENCY=5; final static int LDIM_RTHM_DENSITY=6; final static int LDIM_RTHM_LENGTH=7; final static int LDIM_RTHM_STYLE=8; final static int LDIM_RTHM_STYLE_ARG=9; final static int LDIM_TEMPO=10; } LAYER_DIM_NAME; // Hungarian: ldim */ public class CGenPoint { // constants final static int DIM_COHESION=0; final static int DIM_KEY=1; final static int DIM_NUM_LAYERS=2; final static int DIM_RTHM_CONSISTENCY=3; final static int DIM_RTHM_DENSITY=4; final static int DIM_RTHM_LENGTH=5; final static int DIM_SCALE=6; final static int DIM_SECTION_CHANGE=7; final static int DIM_TEMPO=8; // More constants final static int LDIM_ACTIVE=0; final static int LDIM_CONSONANCE=1; final static int LDIM_DIRECTION=2; final static int LDIM_INSTRUMENT=3; final static int LDIM_PITCH_MAGNET=4; final static int LDIM_RTHM_CONSISTENCY=5; final static int LDIM_RTHM_DENSITY=6; final static int LDIM_RTHM_LENGTH=7; final static int LDIM_RTHM_STYLE=8; final static int LDIM_RTHM_STYLE_ARG=9; final static int LDIM_TEMPO=10; final static int NUM_KEYS = 12; static CSection g_secTest; //======bogus global functions===== static public void assert(boolean b) { if (!b) (new int[1])[-1] = 0; } static public int rand() { return (int)(Math.random() * 9747); } //================================ // Operations //----------------------- public static int iRandomTweak () { int iTarget = rand() % 13; switch (iTarget) { case 0: return iSetCoord(DIM_COHESION, (char)(rand()%80 + 10)); case 1: return iSetCoord(DIM_KEY, (char)(rand()%NUM_KEYS)); case 2: return iSetCoord(DIM_SCALE, (char)(rand()%120)); case 3: return iSetCoord(DIM_TEMPO, (char)(rand()%64 + 18)); //(rand()%127 + 1 + pvGetCoord(DIM_TEMPO))/2); case 4: return iSetCoord(DIM_RTHM_CONSISTENCY, (char)(rand()%128)); case 5: return iSetCoord(DIM_RTHM_DENSITY, (char)(rand()%88 + 20)); case 6: return iSetCoord(DIM_RTHM_LENGTH, (char)(rand()%30 + 5)); } int iLayer = rand() % pvGetCoord(DIM_NUM_LAYERS); switch (iTarget) { case 7: return iSetLayerCoord(LDIM_CONSONANCE, iLayer, (char)(rand()%50 + 25)); case 8: return iSetLayerCoord(LDIM_DIRECTION, iLayer, (char)(rand()%40 + 40)); case 9: return 1;//iSetLayerCoord(LDIM_INSTRUMENT, iLayer, (char)(rand()%128)); case 10: return iSetLayerCoord(LDIM_PITCH_MAGNET, iLayer, (char)(rand()%24 + 45)); case 11: if (0==iSetLayerCoord(LDIM_RTHM_STYLE, iLayer, (char)(rand()%4))) return 0; // Else keep going: } assert(iTarget == 11 || iTarget == 12); switch (pvGetLayerCoord(LDIM_RTHM_STYLE, iLayer)) { case 0: return iSetLayerCoord(LDIM_RTHM_STYLE_ARG, iLayer, (char)(rand()%42)); case 1: return iSetLayerCoord(LDIM_RTHM_STYLE, iLayer, (char)3); // Between.normal case 2: return iSetLayerCoord(LDIM_RTHM_STYLE_ARG, iLayer, (char)(rand()%64 +20)); case 3: return 1; } assert(false); return 0; } // Access to dimension coordinates: //----------------------- public static char pvGetCoord (int dim) { switch (dim) { case DIM_COHESION: return g_secTest.pvGetCohesion(); case DIM_KEY: return g_secTest.pvGetKey(); case DIM_NUM_LAYERS: return (char)g_secTest.pstzGetPrevStanza(1).iNumLayers(); case DIM_SCALE: return g_secTest.sclGetScale().pvGet(); case DIM_SECTION_CHANGE: return g_secTest.pvChangeRate(); case DIM_TEMPO: { double f = g_secTest.pstzGetPrevStanza(1). rthmGetRhythm(0).pvGetTempo() - 1; return (char)(int)(.5 + f*127.0/11.0); } default: assert(false); break; } assert(false); return (char)0; } //----------------------- public static int iSetCoord (int dim, char pvNewCoord) { switch (dim) { case DIM_COHESION: g_secTest.SetCohesion(pvNewCoord); return 1; case DIM_KEY: g_secTest.SetKey(pvNewCoord); break; case DIM_RTHM_CONSISTENCY: { CStanza pStz = g_secTest.pstzGetPrevStanza(1); CRhythm rthm = pStz.rthmGetRhythm(0); if (!rthm.bGenerate((char)0,(char)0,pvNewCoord)) return 0; for (int C = 1; C