/* TAPE2TXT.c - A program to decode Rhodes Chroma/Expander cassette */ /* dump files (22050Hz, 8-bit, signed raw audio files) into */ /* raw binary data and/or patch dump listings */ /* */ /* Version 0.1 - written 07-AUG-99 by David Clarke */ /* (ac151@freenet.carleton.ca) */ /* Version 0.2 - edit on 25-FEB-00 by David Clarke */ /* (ac151@freenet.carleton.ca) */ /* Updated description of Param 16 to properly identify */ /* function of value 31 */ /* Version 0.3 - updated 12-OCT-04 by D. Clarke */ /* (ac151@freenet.carleton.ca) */ /* corrected "%s" string formats in printf statements */ /* */ /* Please feel free to compile, change or do whatever you want with this */ /* utility; however, if you make any significant improvements I'd */ /* appreciate you e-mailing me a copy. Thanks! */ /* */ /* Syntax: */ /* TAPE2TXT FILENAME.SND {Option} */ /* */ /* The program will output 1 file called FILENAME.TXT */ /* {Option} can be one of the following: */ /* */ /* VONLY DEBUG SKIP FULL */ /* */ /* VONLY: Will only decode program values (i.e., no header information */ /* and no textual description of the parameters.) */ /* DEBUG: Print out all data, all the time (shows raw tape data, */ /* including checksum data, etc.) */ /* SKIP: Do not stop processing the file when an error (parity or */ /* checksum) is encountered. */ /* FULL: Not only show numerical values for programs, but also show text*/ /* description of them as well. (Default Value) */ /* */ /**************************************************************************/ #include #include #include #include /* Program-wide defines */ #define ZeroTopLimit 21 /* Max/Min number of samples which*/ #define ZeroBotLimit 15 /* can validly represent a '0' */ #define OneTopLimit 12 /* Max/Min number of samples which*/ #define OneBotLimit 6 /* can validly represent a '1' */ #define TRUE 1 #define FALSE 0 static unsigned char ChkSumC; /* Calculated check sum value */ static unsigned char ChkSumR; /* Check sum read from the data file */ static char out[] = ".txt"; /* output file suffix */ static char in[] = ".snd"; /* input file suffix */ static char OldByte = 1; /* Init info for read */ char *f1name; /* full input file name */ char f2name[50]; /* full output file name */ char *Opt_Name; /* command line options */ static int In11Bit[11]; /* 11 bits that make up and output word */ static int DCD_Bits[60]; /* 60 words that make up a output program */ static int Cur_Program_No; /* Counter for printout of program numbers */ static int Opt_Full, Opt_Debug, Opt_Skip, Opt_VOnly; /* Optional printout boolean variables */ FILE *f1, *f2; char *P1Name[16] = {"16 Channel Mode", "Independ. Chan. Mode - No Cross Mod", "Independ. Chan. Mode - Sync", "Independ. Chan. Mode - Ring Mod", "Independ. Chan. Mode - Filter FM", "Parallel Filter Mode - No Cross Mod", "Parallel Filter Mode - Sync", "Parallel Filter Mode - Ring Mod", "Parallel Filter Mode - Filter FM", "Series Filter Mode - No Cross Mod", "Series Filter Mode - Sync", "Series Filter Mode - Ring Mod", "Series Filter Mode - Filter FM", "Var. Mix Filt. Mode - No Cross Mod", "Var. Mix Filt. Mode - Sync", "Var. Mix Filt. Mode - Ring Mod"}; char *P2Name[8] = {"Left: Latch Right: Sustain", "Left: Latch Right: (Disabled)", "Left: (Disabled) Right: Sustain", "Left: (Disabled) Right: (Disabled)", "Left: NOTE Gate Right: Sustain", "Left: NOTE Gate Right: (Disabled)", "Left: -NOTE Gate Right: Sustain", "Left: -NOTE Gate Right: (Disabled)"}; char *P3Name[16] = {"Poly - Polyphonic", "Poly - Pitch Ordered", "Poly - Chord Buffer", "Poly - All Channel", "Mono - All Channel", "Mono - Last Note, Single Trigger", "Mono - Last Note, Multi-Trigger", "Mono - First Note", "Mono - Bottom Note", "Mono - Top Note", "Mono - Arpeggio Up", "Mono - Arpeggio Down", "Mono - Arpeggio Up/Down", "Mono - Arpeggio Down/Up", "Mono - Sequencer", "Mono - Random"}; char *P5Name[4] = {"Output 0", "Output 1", "Output 2", "Output 3"}; char *P7Name[2] = {"Portamento", "Glissando"}; char *P8Name[4] = {"Asynchronous Free-Run", "Independent Key-Trig", "Single Free-Running", "Single Key-Triggered"}; char *P10Name[16]= {"None", "Pressure", "KYBD", "-KYBD", "Velocity", "-Velocity", "ENV 2", "-ENV 2", "Pedal 1", "-Pedal 1", "Pedal 2", "-Pedal 2", "Lever 1", "-Lever 1", "Lever 2", "-Lever 2"}; char *P11Name[16]= {"Sine", "Cosine", "Offset Sine", "Half-Sine", "Triangle B", "Triangle A", "Sawtooth", "Lag Square", "Square", "Pattern F", "Pattern E", "Pattern D", "Pattern C", "Pattern B", "Pattern A", "Random"}; char *P12Name[16]= {"None", "Pressure", "KYBD", "-KYBD", "Velocity", "-Velocity", "ENV 1", "ENV 2", "Pedal 1", "Pedal 2", "Lever 1", "Lever 2", "0.85 Sec. Delay", "1.3 Sec. Delay", "2.6 Sec. Delay", "5.1 Sec. Delay"}; char *P13Name[8] = {"None", "Low", "Medium Low", "Medium", "Medium High", "High", "Threshold", "-Threshold"}; char *P15Name[8] = {"None", "Pressure", "-KYBD", "KYBD", "Velocity", "-Velocity", "Pedal 1", "Pedal 2"}; char *P27Name[16]= {"KYBD Glide A", "Sweep A", "ENV 1A", "ENV 2A", "KYBD Glide B", "Sweep B", "ENV 1B", "ENV 2B", "Lever 1", "Lever 2", "Pedal 1", "Pedal 2", "Velocity", "Threshold Velocity", "Pressure", "Threshold Pressure"}; char *P46Name[4] = {"ENV 1A", "ENV 2A", "ENV 1B", "ENV 2B"}; char *P50Name[8] = {"None", "Pressure", "KYBD", "Sweep A", "Pedal 1", "-Pedal 1", "Pedal 2", "-Pedal 2"}; char *PanelName[4]={"ERROR!", "Edit B", "Edit A", "Edit Both"}; char *LinkName[4]= {"No Link", "Link Upper", "Link Lower", "Link Unison"}; char *TrnsPose[4]= {"No Transpose", "Up 1 Octave", "Down 1 Octave", "ERROR!"}; /* Return the 'sign' of the passed byte */ int CalcSign(int Byte2Chk) { if (Byte2Chk > 0) return(1); else return(-1); } /* Count the number of samples before we hit a 'zero crossing' in the */ /* input (SND) file */ int ReadTillFlip() { int counter; char NewByte; counter = 0; while (!feof(f1)) { NewByte = fgetc(f1); if (CalcSign(NewByte) == CalcSign(OldByte)) counter++; else { OldByte = NewByte; return(counter); } OldByte = NewByte; } return(-1); } /* Read the 255 zero + 1 one packet preamble */ void ReadPreamble() { int zerocount, Time; zerocount = 0; while ((!feof(f1)) && (zerocount <= 254)) { Time = ReadTillFlip(); if ((Time <= ZeroTopLimit) && (Time >= ZeroBotLimit)) zerocount++; else zerocount = 0; } Time = ReadTillFlip(); /* This is half a "one" */ Time = ReadTillFlip(); /* This is the other half of "one" */ zerocount = 0; if (Opt_Debug == TRUE) fprintf(f2, "Just Read Preamble\n"); } /* Return the integer representation of the "Size Byte" stored in the */ /* Chroma data stream */ int Read_Size_Byte() { int StopCount, temp, parity, Time, index, countone, x; StopCount = 0; index = 0; countone = 0; while (!feof(f1) && (StopCount < 1)) { Time = ReadTillFlip(); if ((Time <= ZeroTopLimit) && (Time >= ZeroBotLimit)) { In11Bit[index] = 0; index++; countone = 0; } if ((Time <= OneTopLimit) && (Time >= OneBotLimit)) { countone++; if (countone == 2) { In11Bit[index] = 1; countone = 0; index++; } } if ((Time < OneBotLimit) || (Time > ZeroTopLimit)) { countone = 0; } if (index == 11) { for (x = 0; x <= 10; ++x) { if (Opt_Debug == TRUE) fprintf(f2, "%d", In11Bit[x]); } if (Opt_Debug == TRUE) fprintf(f2, " Decoded Size Byte "); for (x = 8; x > 0; --x) { if (Opt_Debug == TRUE) fprintf(f2, "%d", In11Bit[x]); } index = 0; StopCount++; temp = 128*In11Bit[8] + 64*In11Bit[7] + 32*In11Bit[6] + 16*In11Bit[5] + 8*In11Bit[4] + 4*In11Bit[3] + 2*In11Bit[2] + In11Bit[1]; parity = In11Bit[8] ^ In11Bit[7] ^ In11Bit[6] ^ In11Bit[5] ^ In11Bit[4] ^ In11Bit[3] ^ In11Bit[2] ^ In11Bit[1]; if (Opt_Debug == TRUE) { fprintf(f2, "%s %3d %s %d", " Integer val = ", temp, "Parity =", parity); fprintf(f2, "%s", "\n"); } ChkSumC = ChkSumC + temp; } } return(temp); } /* Read a generic 'Data' byte from the audio file - storing the 11 bit */ /* result in In11Bit[], and the integer representation of the 8 data bits */ /* into DCD_Bits[] */ void Read_Data_Byte(int StopVar) { int StopCount, parity, Time, index, countone, x; StopCount = 0; index = 0; countone = 0; while (!feof(f1) && (StopCount < StopVar)) { Time = ReadTillFlip(); if ((Time <= ZeroTopLimit) && (Time >= ZeroBotLimit)) { In11Bit[index] = 0; index++; countone = 0; } if ((Time <= OneTopLimit) && (Time >= OneBotLimit)) { countone++; if (countone == 2) { In11Bit[index] = 1; countone = 0; index++; } } if ((Time < OneBotLimit) || (Time > ZeroTopLimit)) { countone = 0; /* if neither a 1 nor 0, reset counter */ } if (index == 11) { for (x = 0; x <= 10; ++x) { if (Opt_Debug == TRUE) fprintf(f2, "%d", In11Bit[x]); } if (Opt_Debug == TRUE) fprintf(f2, " Decoded Data Byte "); for (x = 8; x > 0; --x) { if (Opt_Debug == TRUE) fprintf(f2, "%d", In11Bit[x]); } index = 0; DCD_Bits[StopCount] = 128*In11Bit[8] + 64*In11Bit[7] + 32*In11Bit[6] + 16*In11Bit[5] + 8*In11Bit[4] + 4*In11Bit[3] + 2*In11Bit[2] + In11Bit[1]; parity = In11Bit[8] ^ In11Bit[7] ^ In11Bit[6] ^ In11Bit[5] ^ In11Bit[4] ^ In11Bit[3] ^ In11Bit[2] ^ In11Bit[1]; if (parity == In11Bit[9]) { if (Opt_Debug == TRUE) fprintf(f2, "%s %3d %s %d", " Integer val = ", DCD_Bits[StopCount], "Parity =", parity); } else { if (Opt_Skip == FALSE) { printf("PARITY ERROR IN DATA BYTE - STOPPING\n"); exit(0); } } ChkSumC = ChkSumC + DCD_Bits[StopCount]; if (Opt_Debug == TRUE) fprintf(f2, "%s", "\n"); StopCount++; } } } /* Read the CheckSum Byte from the audio stream - compare against the */ /* checksum that was calculated from the other read data */ void Read_ChkSum_Byte() { int StopCount, parity, Time, index, countone, x; unsigned char ChkTemp; StopCount = 0; index = 0; countone = 0; while (!feof(f1) && (StopCount < 1)) { Time = ReadTillFlip(); if ((Time <= ZeroTopLimit) && (Time >= ZeroBotLimit)) { In11Bit[index] = 0; index++; countone = 0; } if ((Time <= OneTopLimit) && (Time >= OneBotLimit)) { countone++; if (countone == 2) { In11Bit[index] = 1; countone = 0; index++; } } if ((Time < OneBotLimit) || (Time > ZeroTopLimit)) { countone = 0; } if (index == 11) { for (x = 0; x <= 10; ++x) { if (Opt_Debug == TRUE) fprintf(f2, "%d", In11Bit[x]); } if (Opt_Debug == TRUE) fprintf(f2, " Decoded ChkSum Byte "); for (x = 8; x > 0; --x) { if (Opt_Debug == TRUE) fprintf(f2, "%d", In11Bit[x]); } index = 0; StopCount++; ChkSumR = 128*In11Bit[8] + 64*In11Bit[7] + 32*In11Bit[6] + 16*In11Bit[5] + 8*In11Bit[4] + 4*In11Bit[3] + 2*In11Bit[2] + In11Bit[1]; parity = In11Bit[8] ^ In11Bit[7] ^ In11Bit[6] ^ In11Bit[5] ^ In11Bit[4] ^ In11Bit[3] ^ In11Bit[2] ^ In11Bit[1]; ChkTemp = ~ChkSumC +1; if (ChkSumR == ChkTemp) { if (Opt_Debug == TRUE) fprintf(f2, "%s %3d %s %3d", " Checksum Read =", ChkSumR, "Calc =", ChkTemp); } else { if (Opt_Skip == FALSE) { printf("CHECKSUM ERROR IN BLOCK - STOPPING\n"); exit(0); } } if (Opt_Debug == TRUE) fprintf(f2, "%s", "\n"); StopCount++; } } } /* Decode a Chroma memory byte - in effect, do a parameter lookup given */ /* the offset in the program (WordNum), the number of bits of data */ /* (DataSize) and where in the 8-bit byte that the data begins */ /* (StartBit) */ int DCDB(int WordNum, int DataSize, int StartBit) { int temp; temp = DCD_Bits[WordNum + 1] >> (StartBit - DataSize + 1); switch(DataSize) { case 1: temp = temp & 1; break; case 2: temp = temp & 3; break; case 3: temp = temp & 7; break; case 4: temp = temp & 15; break; case 5: temp = temp & 31; break; case 6: temp = temp & 63; break; case 7: temp = temp & 127; break; default: break; } if (temp >= 64) /* Take care of the -64 .. 63 values too */ temp = -1 * (128 - temp); return(temp); } /* Decode the DCD_Bits array to produce the program listing output */ void Decode_Program() { int temp; Cur_Program_No++; fprintf(f2, "%s %d", "\nDump for Program", Cur_Program_No); fprintf(f2, "%s %3d", "\nControl - Patch (Param 1)", DCDB( 1, 4, 3)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P1Name[DCDB( 1, 4, 3)]); fprintf(f2, "%s %3d", "\nControl - FSW Mode (Param 2)", DCDB( 5, 3, 2)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P2Name[DCDB( 5, 3, 2)]); fprintf(f2, "%s %3d", "\nControl - Kybd Alg (Param 3)", DCDB(31, 4, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P3Name[DCDB(31, 4, 7)]); fprintf(f2, "%s %3d", "\nControl - Detune (Param 4)", DCDB( 2, 5, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = No Detune, 1 = Sharp, 31 = More Sharp"); fprintf(f2, "%s %3d", "\nControl - Out. Sel (Param 5)", DCDB( 2, 2, 2)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P5Name[DCDB( 2, 2, 2)]); fprintf(f2, "%s %3d", "\nA - Glide Rate (Param 6)", DCDB(28, 5, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = None, 1 = Fast, 31 = Slow"); fprintf(f2, "%s %3d", "\nA - Glide Shape (Param 7)", DCDB(14, 1, 6)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P7Name[DCDB(14, 1, 6)]); fprintf(f2, "%s %3d", "\nA - Sweep Mode (Param 8)", DCDB( 4, 2, 1)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P8Name[DCDB( 4, 2, 1)]); fprintf(f2, "%s %3d", "\nA - Sweep Rate (Param 9)", DCDB( 4, 6, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Slow, 63 = Fast"); fprintf(f2, "%s %3d", "\nA - Sweep Rate Mod (Param 10)", DCDB( 3, 4, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P10Name[DCDB( 3, 4, 7)]); fprintf(f2, "%s %3d", "\nA - Sweep Wave Shape (Param 11)", DCDB( 6, 4, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P11Name[DCDB( 6, 4, 7)]); fprintf(f2, "%s %3d", "\nA - Sweep Ampl Mod (Param 12)", DCDB( 6, 4, 3)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P12Name[DCDB( 6, 4, 3)]); fprintf(f2, "%s %3d", "\nA - Env 1 Ampl Touch (Param 13)", DCDB( 9, 3, 2)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P13Name[DCDB( 9, 3, 2)]); fprintf(f2, "%s %3d", "\nA - Env 1 Attack (Param 14)", DCDB( 7, 5, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Instant, 1 = Fast, 31 = Slow"); fprintf(f2, "%s %3d", "\nA - Env 1 Attack Mod (Param 15)", DCDB( 7, 3, 2)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P15Name[DCDB( 7, 3, 2)]); fprintf(f2, "%s %3d", "\nA - Env 1 Decay (Param 16)", DCDB( 8, 5, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Instant, 1 = Fast, 30 = Slow, 31 = Infinite"); fprintf(f2, "%s %3d", "\nA - Env 1 Decay Mod (Param 17)", DCDB( 8, 3, 2)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P15Name[DCDB( 8, 3, 2)]); fprintf(f2, "%s %3d", "\nA - Env 1 Release (Param 18)", DCDB( 9, 5, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Instant, 1 = Fast, 30 = Slow, 31 = Thresh"); fprintf(f2, "%s %3d", "\nA - Env 2 Delay (Param 19)", DCDB(10, 5, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = None, 1 = Short, 30 = Long, 31 = Retrig on SWP A"); fprintf(f2, "%s %3d", "\nA - Env 2 Ampl Touch (Param 20)", DCDB(13, 3, 2)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P13Name[DCDB(13, 3, 2)]); fprintf(f2, "%s %3d", "\nA - Env 2 Attack (Param 21)", DCDB(11, 5, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Instant, 1 = Fast, 31 = Slow"); fprintf(f2, "%s %3d", "\nA - Env 2 Attack Mod (Param 22)", DCDB(11, 3, 2)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P15Name[DCDB(11, 3, 2)]); fprintf(f2, "%s %3d", "\nA - Env 2 Decay (Param 23)", DCDB(12, 5, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Instant, 1 = Fast, 30 = Slow, 31 = Infinite"); fprintf(f2, "%s %3d", "\nA - Env 2 Decay Mod (Param 24)", DCDB(12, 3, 2)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P15Name[DCDB(12, 3, 2)]); fprintf(f2, "%s %3d", "\nA - Env 2 Release (Param 25)", DCDB(13, 5, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Instant, 1 = Fast, 30 = Slow, 31 = Thresh"); fprintf(f2, "%s %3d", "\nA - Pitch Tune (Param 26)", DCDB(14, 6, 5)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Low, 12 = Concert, 63 = High"); fprintf(f2, "%s %3d", "\nA - Pitch Mod 1 Sel. (Param 27)", DCDB(18, 4, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P27Name[DCDB(18, 4, 7)]); fprintf(f2, "%s %3d", "\nA - Pitch Mod 1 Depth(Param 28)", DCDB(15, 7, 6)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "-64 = -Deep, 0 = None, 63 = Deep"); fprintf(f2, "%s %3d", "\nA - Pitch Mod 2 Sel. (Param 29)", DCDB(18, 4, 3)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P27Name[DCDB(18, 4, 3)]); fprintf(f2, "%s %3d", "\nA - Pitch Mod 2 Depth(Param 30)", DCDB(16, 7, 6)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "-64 = -Deep, 0 = None, 63 = Deep"); fprintf(f2, "%s %3d", "\nA - Pitch Mod 3 Sel. (Param 31)", DCDB(19, 4, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P27Name[DCDB(19, 4, 7)]); fprintf(f2, "%s %3d", "\nA - Pitch Mod 3 Depth(Param 32)", DCDB(17, 7, 6)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "-64 = -Deep, 0 = None, 63 = Deep"); fprintf(f2, "%s %3d", "\nA - Waveshape Select (Param 33)", DCDB(20, 2, 1)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0=Sawtooth, 1=Pulse, 2=Pink Noise, 3=White Noise"); fprintf(f2, "%s %3d", "\nA - Waveshape Width (Param 34)", DCDB(20, 6, 7)); if (Opt_Full == TRUE) { if (DCDB(20, 2, 1) == 0) { fprintf(f2, "%s %s", " ", "0=Normal, 1=Slight, 32=Greatly, 63=Slight"); } if (DCDB(20, 2, 1) == 1) { fprintf(f2, "%s %s", " ", "0=Narrow Pulse, 32=Square Wave, 63=Broad Pulse"); } } fprintf(f2, "%s %3d", "\nA - Waveshape Mod Sel(Param 35)", DCDB(19, 4, 3)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P27Name[DCDB(19, 4, 3)]); fprintf(f2, "%s %3d", "\nA - Wveshpe Mod Depth(Param 36)", DCDB(21, 7, 6)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "-64 = -Deep, 0 = None, 63 = Deep"); fprintf(f2, "%s %3d", "\nA - Cutoff LP/HP (Param 37)", DCDB(15, 1, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Low Pass, 1 = High Pass"); fprintf(f2, "%s %3d", "\nA - Cutoff Resonance (Param 38)", DCDB(10, 3, 2)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Min Res., 7 = Max Res."); fprintf(f2, "%s %3d", "\nA - Cutoff Tune (Param 39)", DCDB(22, 6, 5)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Low Freq., 63 = High Freq."); fprintf(f2, "%s %3d", "\nA - Cutoff Mod 1 Sel (Param 40)", DCDB(26, 4, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P27Name[DCDB(26, 4, 7)]); fprintf(f2, "%s %3d", "\nA - Cutoff Mod 1 Dpth(Param 41)", DCDB(23, 7, 6)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "-64 = -Deep, 0 = None, 63 = Deep"); fprintf(f2, "%s %3d", "\nA - Cutoff Mod 2 Sel (Param 42)", DCDB(26, 4, 3)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P27Name[DCDB(26, 4, 3)]); fprintf(f2, "%s %3d", "\nA - Cutoff Mod 2 Dpth(Param 43)", DCDB(24, 7, 6)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "-64 = -Deep, 0 = None, 63 = Deep"); fprintf(f2, "%s %3d", "\nA - Cutoff Mod 3 Sel (Param 44)", DCDB(27, 4, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P27Name[DCDB(27, 4, 7)]); fprintf(f2, "%s %3d", "\nA - Cutoff Mod 3 Dpth(Param 45)", DCDB(25, 7, 6)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "-64 = -Deep, 0 = None, 63 = Deep"); fprintf(f2, "%s %3d", "\nA - Volume Mod 1 Sel (Param 46)", DCDB(27, 2, 3)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P46Name[DCDB(27, 2, 3)]); fprintf(f2, "%s %3d", "\nA - Volume Mod 1 Dpth(Param 47)", DCDB( 3, 4, 3)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = None, 15 = Deep"); fprintf(f2, "%s %3d", "\nA - Volume Mod 2 Sel (Param 48)", DCDB(27, 2, 1)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P46Name[DCDB(27, 2, 1)]); fprintf(f2, "%s %3d", "\nA - Volume Mod 2 Dpth(Param 49)", DCDB( 5, 4, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = None, 15 = Deep"); fprintf(f2, "%s %3d", "\nA - Volume Mod 3 Sel (Param 50)", DCDB(28, 3, 2)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P50Name[DCDB(28, 3, 2)]); fprintf(f2, "%s %3d", "\nB - Glide Rate (Param 6)", DCDB(58, 5, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = None, 1 = Fast, 31 = Slow"); fprintf(f2, "%s %3d", "\nB - Glide Shape (Param 7)", DCDB(44, 1, 6)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P7Name[DCDB(44, 1, 6)]); fprintf(f2, "%s %3d", "\nB - Sweep Mode (Param 8)", DCDB(34, 2, 1)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P8Name[DCDB(34, 2, 1)]); fprintf(f2, "%s %3d", "\nB - Sweep Rate (Param 9)", DCDB(34, 6, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Slow, 63 = Fast"); fprintf(f2, "%s %3d", "\nB - Sweep Rate Mod (Param 10)", DCDB(33, 4, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P10Name[DCDB(33, 4, 7)]); fprintf(f2, "%s %3d", "\nB - Sweep Wave Shape (Param 11)", DCDB(36, 4, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P11Name[DCDB(36, 4, 7)]); fprintf(f2, "%s %3d", "\nB - Sweep Ampl Mod (Param 12)", DCDB(36, 4, 3)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P12Name[DCDB(36, 4, 3)]); fprintf(f2, "%s %3d", "\nB - Env 1 Ampl Touch (Param 13)", DCDB(39, 3, 2)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P13Name[DCDB(39, 3, 2)]); fprintf(f2, "%s %3d", "\nB - Env 1 Attack (Param 14)", DCDB(37, 5, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Instant, 1 = Fast, 31 = Slow"); fprintf(f2, "%s %3d", "\nB - Env 1 Attack Mod (Param 15)", DCDB(37, 3, 2)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P15Name[DCDB(37, 3, 2)]); fprintf(f2, "%s %3d", "\nB - Env 1 Decay (Param 16)", DCDB(38, 5, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Instant, 1 = Fast, 30 = Slow, 31 = Infinite"); fprintf(f2, "%s %3d", "\nB - Env 1 Decay Mod (Param 17)", DCDB(38, 3, 2)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P15Name[DCDB(38, 3, 2)]); fprintf(f2, "%s %3d", "\nB - Env 1 Release (Param 18)", DCDB(39, 5, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Instant, 1 = Fast, 30 = Slow, 31 = Thresh"); fprintf(f2, "%s %3d", "\nB - Env 2 Delay (Param 19)", DCDB(40, 5, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = None, 1 = Short, 30 = Long, 31 = Retrig on SWP A"); fprintf(f2, "%s %3d", "\nB - Env 2 Ampl Touch (Param 20)", DCDB(43, 3, 2)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P13Name[DCDB(43, 3, 2)]); fprintf(f2, "%s %3d", "\nB - Env 2 Attack (Param 21)", DCDB(41, 5, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Instant, 1 = Fast, 31 = Slow"); fprintf(f2, "%s %3d", "\nB - Env 2 Attack Mod (Param 22)", DCDB(41, 3, 2)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P15Name[DCDB(41, 3, 2)]); fprintf(f2, "%s %3d", "\nB - Env 2 Decay (Param 23)", DCDB(42, 5, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Instant, 1 = Fast, 30 = Slow, 31 = Infinite"); fprintf(f2, "%s %3d", "\nB - Env 2 Decay Mod (Param 24)", DCDB(42, 3, 2)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P15Name[DCDB(42, 3, 2)]); fprintf(f2, "%s %3d", "\nB - Env 2 Release (Param 25)", DCDB(43, 5, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Instant, 1 = Fast, 30 = Slow, 31 = Thresh"); fprintf(f2, "%s %3d", "\nB - Pitch Tune (Param 26)", DCDB(44, 6, 5)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Low, 12 = Concert, 63 = High"); fprintf(f2, "%s %3d", "\nB - Pitch Mod 1 Sel. (Param 27)", DCDB(48, 4, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P27Name[DCDB(48, 4, 7)]); fprintf(f2, "%s %3d", "\nB - Pitch Mod 1 Depth(Param 28)", DCDB(45, 7, 6)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "-64 = -Deep, 0 = None, 63 = Deep"); fprintf(f2, "%s %3d", "\nB - Pitch Mod 2 Sel. (Param 29)", DCDB(48, 4, 3)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P27Name[DCDB(48, 4, 3)]); fprintf(f2, "%s %3d", "\nB - Pitch Mod 2 Depth(Param 30)", DCDB(46, 7, 6)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "-64 = -Deep, 0 = None, 63 = Deep"); fprintf(f2, "%s %3d", "\nB - Pitch Mod 3 Sel. (Param 31)", DCDB(49, 4, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P27Name[DCDB(49, 4, 7)]); fprintf(f2, "%s %3d", "\nB - Pitch Mod 3 Depth(Param 32)", DCDB(47, 7, 6)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "-64 = -Deep, 0 = None, 63 = Deep"); fprintf(f2, "%s %3d", "\nB - Waveshape Select (Param 33)", DCDB(50, 2, 1)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0=Sawtooth, 1=Pulse, 2=Pink Noise, 3=White Noise"); fprintf(f2, "%s %3d", "\nB - Waveshape Width (Param 34)", DCDB(50, 6, 7)); if (Opt_Full == TRUE) { if (DCDB(50, 2, 1) == 0) { fprintf(f2, "%s %s", " ", "0=Normal, 1=Slight, 32=Greatly, 63=Slight"); } if (DCDB(50, 2, 1) == 1) { fprintf(f2, "%s %s", " ", "0=Narrow Pulse, 32=Square Wave, 63=Broad Pulse"); } } fprintf(f2, "%s %3d", "\nB - Waveshape Mod Sel(Param 35)", DCDB(49, 4, 3)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P27Name[DCDB(49, 4, 3)]); fprintf(f2, "%s %3d", "\nB - Wveshpe Mod Depth(Param 36)", DCDB(51, 7, 6)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "-64 = -Deep, 0 = None, 63 = Deep"); fprintf(f2, "%s %3d", "\nB - Cutoff LP/HP (Param 37)", DCDB(45, 1, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Low Pass, 1 = High Pass"); fprintf(f2, "%s %3d", "\nB - Cutoff Resonance (Param 38)", DCDB(40, 3, 2)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Min Res., 7 = Max Res."); fprintf(f2, "%s %3d", "\nB - Cutoff Tune (Param 39)", DCDB(52, 6, 5)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = Low Freq., 63 = High Freq."); fprintf(f2, "%s %3d", "\nB - Cutoff Mod 1 Sel (Param 40)", DCDB(56, 4, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P27Name[DCDB(56, 4, 7)]); fprintf(f2, "%s %3d", "\nB - Cutoff Mod 1 Dpth(Param 41)", DCDB(53, 7, 6)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "-64 = -Deep, 0 = None, 63 = Deep"); fprintf(f2, "%s %3d", "\nB - Cutoff Mod 2 Sel (Param 42)", DCDB(56, 4, 3)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P27Name[DCDB(56, 4, 3)]); fprintf(f2, "%s %3d", "\nB - Cutoff Mod 2 Dpth(Param 43)", DCDB(54, 7, 6)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "-64 = -Deep, 0 = None, 63 = Deep"); fprintf(f2, "%s %3d", "\nB - Cutoff Mod 3 Sel (Param 44)", DCDB(57, 4, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P27Name[DCDB(57, 4, 7)]); fprintf(f2, "%s %3d", "\nB - Cutoff Mod 3 Dpth(Param 45)", DCDB(55, 7, 6)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "-64 = -Deep, 0 = None, 63 = Deep"); fprintf(f2, "%s %3d", "\nB - Volume Mod 1 Sel (Param 46)", DCDB(57, 2, 3)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P46Name[DCDB(57, 2, 3)]); fprintf(f2, "%s %3d", "\nB - Volume Mod 1 Dpth(Param 47)", DCDB(33, 4, 3)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = None, 15 = Deep"); fprintf(f2, "%s %3d", "\nB - Volume Mod 2 Sel (Param 48)", DCDB(57, 2, 1)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P46Name[DCDB(57, 2, 1)]); fprintf(f2, "%s %3d", "\nB - Volume Mod 2 Dpth(Param 49)", DCDB(35, 4, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", "0 = None, 15 = Deep"); fprintf(f2, "%s %3d", "\nB - Volume Mod 3 Sel (Param 50)", DCDB(58, 3, 2)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", P50Name[DCDB(58, 3, 2)]); fprintf(f2, "%s %3d", "\nPanel - Edit Mode ", DCDB(30, 2, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", PanelName[DCDB(30, 2, 7)]); fprintf(f2, "%s %3d", "\nPanel - Edit Program ", DCDB(30, 6, 5)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", " "); temp = DCDB(31, 4, 3); if (temp > 7) temp = -2 * (16 - temp); else temp = 2 * temp; fprintf(f2, "%s %3d", "\nPanel - Link Balance ", temp); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", " "); fprintf(f2, "%s %3d", "\nPanel - Link Type ", DCDB( 0, 2, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", LinkName[DCDB( 0, 2, 7)]); fprintf(f2, "%s %3d", "\nPanel - Link Program ", DCDB( 0, 6, 5)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", " "); temp = DCDB(32, 8, 7); if (temp > 31) temp = -1 * (128-temp); fprintf(f2, "%s %3d", "\nPanel - Keyboard Split ", temp); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", " "); fprintf(f2, "%s %3d", "\nPanel - Main Transpose Type ", DCDB( 1, 2, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", TrnsPose[DCDB( 1, 2, 7)]); fprintf(f2, "%s %3d", "\nPanel - Link Transpose Type ", DCDB( 1, 2, 5)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", TrnsPose[DCDB( 1, 2, 5)]); fprintf(f2, "%s %3d", "\nPanel - Sequence Program Number", DCDB(29, 8, 7)); if (Opt_Full == TRUE) fprintf(f2, "%s %s", " ", " "); fprintf(f2, "\n\n"); } int main(int argc, char *argv[]) { int BytesInPacket; /* Variable to hold number of bytes to expect */ /* in upcoming data packet (in SND file) */ Cur_Program_No = 0; Opt_Full = TRUE; /* By default, the full output listing is */ Opt_Debug = FALSE; /* produced */ Opt_Skip = FALSE; Opt_VOnly = FALSE; if (argc == 1) { printf("Syntax: TAPE2TXT {filename.snd} {option}\n"); printf(" where option is one of FULL, DEBUG, SKIP, VONLY\n"); exit(0); } f1name = argv[1]; if (argc > 2) { Opt_Name = argv[2]; if (strcmp(Opt_Name, "FULL") == 0) Opt_Full = TRUE; else if (strcmp(Opt_Name, "DEBUG") == 0) Opt_Debug = TRUE; else if (strcmp(Opt_Name, "SKIP") == 0) Opt_Skip = TRUE; else if (strcmp(Opt_Name, "VONLY") == 0) { Opt_VOnly = TRUE; /* If only the program values are wanted */ Opt_Full = FALSE; /* make sure the default option is reset */ } else { printf("Syntax: TAPE2TXT {filename.snd} {option}\n"); printf(" where option is one of FULL, DEBUG, SKIP, VONLY\n"); exit(0); } } if (Opt_Debug == TRUE) /* If debug is selected, make sure all */ Opt_Full = TRUE; /* output is enabled */ strncpy(f2name, f1name, strlen(f1name)-4); strcat(f2name, out); if ((f1 = fopen(f1name, "rb")) == NULL) { printf("Can't open %s\n", f1name); exit(0); } if ((f2 = fopen(f2name, "wt")) == NULL) { printf("Can't open %s\n", f2name); exit(0); } while (!feof(f1)) { ChkSumC = 0; ReadPreamble(); /* Look for preamble in file */ BytesInPacket = Read_Size_Byte(); /* see how much data is to come */ Read_Data_Byte(BytesInPacket); /* Read all the upcoming bytes */ Read_ChkSum_Byte(); if (BytesInPacket == 60) /* if we found a "program dump" packet */ { /* then decode it as such */ Decode_Program(); } } fclose(f1); /* Close Input File */ fclose(f2); /* Close Output File */ return(0); }