| #include "voice.h" // for LoadVoice, voice | #include "voice.h" // for LoadVoice, voice | ||||
| #include "wavegen.h" // for WavegenInit, WavegenSetVoice | #include "wavegen.h" // for WavegenInit, WavegenSetVoice | ||||
| static int CalculateSample(unsigned char c3, int c1); | |||||
| #define N_ITEM_STRING 256 | #define N_ITEM_STRING 256 | ||||
| typedef struct { | typedef struct { | ||||
| { | { | ||||
| int displ; | int displ; | ||||
| unsigned char c1; | unsigned char c1; | ||||
| unsigned char c3; | |||||
| int c2; | |||||
| int sample; | int sample; | ||||
| int sample2; | int sample2; | ||||
| float x; | float x; | ||||
| if ((c = fgetc(f)) == EOF) | if ((c = fgetc(f)) == EOF) | ||||
| break; | break; | ||||
| c3 = (unsigned char)c; | |||||
| c2 = c3 << 24; | |||||
| c2 = c2 >> 16; // sign extend | |||||
| sample = (c1 & 0xff) + c2; | |||||
| sample = CalculateSample((unsigned char) c, c1); | |||||
| if (sample > max) | if (sample > max) | ||||
| max = sample; | max = sample; | ||||
| while (!feof(f)) { | while (!feof(f)) { | ||||
| c1 = fgetc(f); | c1 = fgetc(f); | ||||
| c3 = fgetc(f); | |||||
| c2 = c3 << 24; | |||||
| c2 = c2 >> 16; // sign extend | |||||
| unsigned char c3 = fgetc(f); | |||||
| sample = (c1 & 0xff) + c2; | |||||
| sample = CalculateSample(c3, c1); | |||||
| if (feof(f)) break; | if (feof(f)) break; | ||||
| } | } | ||||
| #pragma GCC visibility pop | #pragma GCC visibility pop | ||||
| static int CalculateSample(unsigned char c3, int c1) { | |||||
| int c2 = c3 << 24; | |||||
| c2 = c2 >> 16; // sign extend | |||||
| return (c1 & 0xff) + c2; | |||||
| } |