From 5be332938d51b75dee8856ad87e2edbe9b8ce3b2 Mon Sep 17 00:00:00 2001 From: Dominik Wenger Date: Fri, 11 Jan 2008 23:46:10 +0000 Subject: refactored voicefont and wavtrim for inclusion into rbutil. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16058 a1c6a512-1295-4272-9138-f99709370657 --- tools/voicefont.c | 107 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 59 insertions(+), 48 deletions(-) (limited to 'tools/voicefont.c') diff --git a/tools/voicefont.c b/tools/voicefont.c index 10f08f385c..3dd5169cc7 100644 --- a/tools/voicefont.c +++ b/tools/voicefont.c @@ -22,6 +22,8 @@ * ****************************************************************************/ +#include "voicefont.h" + #include #include @@ -64,11 +66,9 @@ int BitswapAudio (unsigned char* pDest, unsigned char* pSrc, size_t len) return 0; } - -int main (int argc, char** argv) +int voicefont(FILE* voicefontids,int targetnum,char* filedir, FILE* output) { - FILE* pFile; - + int i,j; /* two tables, one for normal strings, one for voice-only (>0x8000) */ @@ -90,35 +90,18 @@ int main (int argc, char** argv) int target_id; int do_bitswap_audio = 0; - - if (argc < 2) - { - printf("Makes a Rockbox voicefont from a collection of mp3 clips.\n"); - printf("Usage: voicefont \n"); - printf("\n"); - printf("Example: \n"); - printf("voicefont voicefontids.txt 2 voice\\ voicefont.bin\n"); - return -1; - } - pFile = fopen(argv[1], "r"); - if (pFile == NULL) - { - printf("Error opening language file %s\n", argv[1]); - return -2; - } - /* We bitswap the voice file only SH based archos players, target IDs - equal to or lower than 8. See the target_id line for each target in - configure */ - target_id = atoi(argv[2]); + equal to or lower than 8. See the target_id line for each target in + configure */ + target_id = targetnum; if (target_id <= 8) do_bitswap_audio = 1; memset(voiceonly, 0, sizeof(voiceonly)); - while (!feof(pFile)) + while (!feof(voicefontids)) { - fgets(line, sizeof(line), pFile); + fgets(line, sizeof(line), voicefontids); if (line[0] == '#') /* comment */ continue; @@ -132,24 +115,18 @@ int main (int argc, char** argv) continue; } } - fclose(pFile); + fclose(voicefontids); - pFile = fopen(argv[4], "wb"); - if (pFile == NULL) - { - printf("Error opening output file %s\n", argv[4]); - return -2; - } - fseek(pFile, HEADER_SIZE + count*8, SEEK_SET); /* space for header */ + fseek(output, HEADER_SIZE + count*8, SEEK_SET); /* space for header */ for (i=0; i \n"); + printf("\n"); + printf("Example: \n"); + printf("voicefont voicefontids.txt 2 voice\\ voicefont.bin\n"); + return -1; + } + + FILE* ids = fopen(argv[1], "r"); + if (ids == NULL) + { + printf("Error opening language file %s\n", argv[1]); + return -2; + } + + FILE* output = fopen(argv[4], "wb"); + if (output == NULL) + { + printf("Error opening output file %s\n", argv[4]); + return -2; + } + + voicefont(ids, atoi(argv[2]),argv[3],output); return 0; } +#endif -- cgit v1.2.3