/* files.c */ /* Copyright 1990 Thomas E. Janzen All Rights Reserved */ /* ** FACILITY: ** ** AlgoRhythms music improviser on Commodore (TM) Amiga (TM) ** compiled with Lattice (TM) C 5.05 ** ** ABSTRACT: ** ** Algorhythms improvises music over the MIDI serial port. ** ** AUTHORS: Thomas E. Janzen ** ** CREATION DATE: 26-MAR-1990 ** ** MODIFICATION HISTORY: ** DATE NAME DESCRIPTION **-- */ #include #include #include #include #include "AlgoRhythms.h" extern struct GfxBase *GfxBase; extern struct IntuitionBase *IntuitionBase; extern struct DOSBase *DOSBase; extern struct MathBase *MathBase; static int Open_Read_File(char *FileName); static int Open_Save_File(char *FileName); FILE *FilePointer; struct Parameter { double CenterCycle; double CenterPhase; double SpreadCycle; double SpreadPhase; }; int Save_File(char *FileName, const double *TotalDuration, const int *ScaleLength, const int Scale[], const int *voices, const int *tempo, const struct Parameter *Pitch, const struct Parameter *Thickness, const struct Parameter *Dynamics, const struct Parameter *Duration, const struct NoteEvent *Events, double MinNoteLen, double MaxNoteLen){ int Status=0; register int ScaleIndex; register int i; Status=Open_Save_File(FileName); if(Status == 1) return Status; fprintf(FilePointer,"%4.2f\n",*TotalDuration); fprintf(FilePointer,"%4.2f\n",MinNoteLen); fprintf(FilePointer,"%4.2f\n",MaxNoteLen); fprintf(FilePointer,"%d\n",*ScaleLength); for(ScaleIndex = 0; ScaleIndex<(*ScaleLength); ScaleIndex++) { fprintf(FilePointer,"%d\n",Scale[ScaleIndex]); } fprintf(FilePointer,"%d\n",*voices); fprintf(FilePointer,"%d\n",*tempo); fprintf(FilePointer,"%4.2f\n",Pitch->CenterCycle); fprintf(FilePointer,"%4.2f\n",Pitch->CenterPhase); fprintf(FilePointer,"%4.2f\n",Pitch->SpreadCycle); fprintf(FilePointer,"%4.2f\n",Pitch->SpreadPhase); fprintf(FilePointer,"%4.2f\n",Duration->CenterCycle); fprintf(FilePointer,"%4.2f\n",Duration->CenterPhase); fprintf(FilePointer,"%4.2f\n",Duration->SpreadCycle); fprintf(FilePointer,"%4.2f\n",Duration->SpreadPhase); fprintf(FilePointer,"%4.2f\n",Dynamics->CenterCycle); fprintf(FilePointer,"%4.2f\n",Dynamics->CenterPhase); fprintf(FilePointer,"%4.2f\n",Dynamics->SpreadCycle); fprintf(FilePointer,"%4.2f\n",Dynamics->SpreadPhase); fprintf(FilePointer,"%4.2f\n",Thickness->SpreadCycle); fprintf(FilePointer,"%4.2f\n",Thickness->SpreadPhase); for(i=0;iCenterCycle=atof(tempstring); stringptr=fgets(tempstring,buflen,FilePointer); Pitch->CenterPhase=atof(tempstring); stringptr=fgets(tempstring,buflen,FilePointer); Pitch->SpreadCycle=atof(tempstring); stringptr=fgets(tempstring,buflen,FilePointer); Pitch->SpreadPhase=atof(tempstring); stringptr=fgets(tempstring,buflen,FilePointer); Duration->CenterCycle=atof(tempstring); stringptr=fgets(tempstring,buflen,FilePointer); Duration->CenterPhase=atof(tempstring); stringptr=fgets(tempstring,buflen,FilePointer); Duration->SpreadCycle=atof(tempstring); stringptr=fgets(tempstring,buflen,FilePointer); Duration->SpreadPhase=atof(tempstring); stringptr=fgets(tempstring,buflen,FilePointer); Dynamics->CenterCycle=atof(tempstring); stringptr=fgets(tempstring,buflen,FilePointer); Dynamics->CenterPhase=atof(tempstring); stringptr=fgets(tempstring,buflen,FilePointer); Dynamics->SpreadCycle=atof(tempstring); stringptr=fgets(tempstring,buflen,FilePointer); Dynamics->SpreadPhase=atof(tempstring); stringptr=fgets(tempstring,buflen,FilePointer); Thickness->SpreadCycle=atof(tempstring); stringptr=fgets(tempstring,buflen,FilePointer); Thickness->SpreadPhase=atof(tempstring); for(i=0;i