Created
January 26, 2018 05:57
-
-
Save JerrySievert/cfac490ac59044bd6f01b95ac50992b7 to your computer and use it in GitHub Desktop.
converts samples to vcvrack for me
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
union bytes { | |
float val; | |
unsigned char str[sizeof(float)]; | |
}; | |
int main (int argc, char **argv) { | |
FILE *f1; | |
union bytes b; | |
long len; | |
long l = 0; | |
if (argc < 2) { | |
printf("USAGE: %s file ...\n", argv[0]); | |
return 1; | |
} | |
for (int i = 1; i < argc; i++) { | |
l = 0; | |
f1 = fopen(argv[i], "r"); | |
fseek(f1, 0, SEEK_END); | |
len = ftell(f1); | |
fseek(f1, 0, SEEK_SET); | |
printf("const float kick%d[] = {\n", i); | |
while (l < (len / sizeof(float))) { | |
fread(b.str, sizeof(char), 4, f1); | |
printf("%f", b.val * 5); | |
if (l < (len / sizeof(float)) - 1) { | |
printf(", "); | |
} | |
l++; | |
} | |
printf("\n};\n\nunsigned int kick%d_len = %ld;\n\n", i, (long) len / 4); | |
fclose(f1); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment