Skip to content

Instantly share code, notes, and snippets.

@shinmai
Last active April 27, 2021 20:24
Show Gist options
  • Select an option

  • Save shinmai/ca2ae0ad242f4db768cab43c2bc92be9 to your computer and use it in GitHub Desktop.

Select an option

Save shinmai/ca2ae0ad242f4db768cab43c2bc92be9 to your computer and use it in GitHub Desktop.
My hacky method for converting samples to use as digidrums in ttrak
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
if (argc != 3) {
fprintf(stderr, "%s in.raw (signed 8-bit mono PCM, little-endian) out.4bi", argv[0]);
return 1;
}
FILE *in = fopen(argv[1], "rb"), *out = fopen(argv[2], "wb");
while (!feof(in)) {
int c = fgetc(in); fgetc(in);
fputc(c / 0x11, out);
}
fclose(in);
fclose(out);
return 0;
}

Converting wav samples to 4bi digidrums for ttrak

step 1

compile 4bi-conv.c from below:

gcc 4bi-conv.c -O0 -o 4bi-conv

step 2

Convert wav sample to raw signed 8-bit mono PCM with SoX:

sox input.wav -b 8 -c 1 -r 11025 -L -e signed-integer intermediary.raw

step 3

Conver raw 8-bit PCM to 4-bit PCM with 4bi-conv:

4bi-conv intermediary.raw output.4bi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment