#include #include #define MAX_INSTRUMENTS 20 #define MAX_MEASURES 1000 typedef struct{ int ticker[64]; int ender[64]; int pitches[64]; }melody; typedef struct{ int total_thismel; /*number of times it will play current melody*/ int count_thismel; /*number of times it HAS played it*/ int octave; int currfrag; melody currentmelody; }instrument; int randpitch(int octave){ int answer=(octave+1)*12; int rando=rand()%8; switch(rando){ case 0:return answer;/*do*/ case 1:return answer+2;/*re*/ case 2:return answer+4; case 3:return answer+5; case 4:return answer+7; case 5:return answer+9; case 6:return answer+11; case 7:return answer+12;/*do*/ } } melody makemelody(int tickpermeasure, int sloppiness, int density, int octave){ melody currentmelody; int i;int tickercount=0;int endercount=0; for(i=0;iMAX_INSTRUMENTS){ printf("\nI'm sorry, please keep instrument count under %d",MAX_INSTRUMENTS);exit(0); } printf("input:instcount=%d", instcount); } if(argv[i][1]=='r'){ resolution=atoi(argv[i+1]); tickpermeasure=pow(2,resolution); printf("input:res=%d", resolution); } if(argv[i][1]=='d'){ duration=atoi(argv[i+1]); if (duration>MAX_MEASURES){ printf("\nI'm sorry, please keep duration under %d measures",MAX_MEASURES);exit(0); } printf("input:dur=%d", duration); } } output=fopen(argv[1],"w"); fprintf(output,"//Skini file created by RILEY.C by Daniel Iglesia, 5/10/03\n"); fprintf(output,"//original parameters:\n"); fprintf(output,"// number of instruments:%d\n",instcount); fprintf(output,"// tempo in bpm:%d\n",tempo); fprintf(output,"// resolution (or, minimum note value= 1/(2^resolution):%d\n",resolution); fprintf(output,"// duration:%d measures\n",duration); tick=(float)240/(tempo*tickpermeasure); printf("tick=%f ", tick); inst[0].total_thismel=duration; inst[0].count_thismel=0; inst[0].octave=3; inst[0].currentmelody=makepulse(tickpermeasure, sloppiness, inst[0].octave,resolution); for(i=0;i