static bool load_drum_pxt(char *fname, int d) { int i; signed short sample; stPXSound snd; stat("load_drum: loading %s into drum index %d", fname, d); if (pxt_load(fname, &snd)) return 1; pxt_Render(&snd); drumtable[d].nsamples = snd.final_size; drumtable[d].samples = (signed short *)malloc(snd.final_size * 2); // *2 - it is 16-bit #ifndef QUIET stat("drum0%X [%s]: %d samples", d, fname, drumtable[d].nsamples); #endif // read data out of pxt's render result and put it into our drum sample table for(i=0;i<drumtable[d].nsamples;i++) { sample = snd.final_buffer[i]; //i'm upscaling the 8-bit value to 16-bit; //but this also sets volume of drums relative to music sample *= 200; drumtable[d].samples[i] = sample; } FreePXTBuf(&snd); return 0; }
static bool load_drum_pxt(FILE *fd, int s, int d) { int i; signed short sample; stPXSound snd; if (pxt_load(fd, &snd, s)) return 1; pxt_Render(&snd); drumtable[d].nsamples = snd.final_size; drumtable[d].samples = (signed short *)malloc(snd.final_size * 2); // *2 - it is 16-bit // read data out of pxt's render result and put it into our drum sample table for(i=0;i<drumtable[d].nsamples;i++) { sample = snd.final_buffer[i]; //i'm upscaling the 8-bit value to 16-bit; //but this also sets volume of drums relative to music sample *= 200; drumtable[d].samples[i] = sample; } FreePXTBuf(&snd); return 0; }