ebook2cw-0.8.2/0000755000175000017500000000000012071564040012455 5ustar fabianfabianebook2cw-0.8.2/isomap.txt0000644000175000017500000000040312071564040014503 0ustar fabianfabian# Example ISO8859 character mapping file of ebook2cw. # # The format of each line is: # x=yyy # # where x is the character to be mapped to the string yyy # # x is a single character, yyy is a string of up to 3 characters. ä=ae ö=oe ü=ue Ä=aw Ü=ue Ö=oe ß=sz ebook2cw-0.8.2/ebook2cw.c0000644000175000017500000013151512071564040014342 0ustar fabianfabian/* ebook2cw - converts an ebook to morse mp3s Copyright (C) 2007 - 2012 Fabian Kurz, DJ1YFK $Id: ebook2cw.c 559 2013-01-04 14:14:36Z dj1yfk $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. source code looks properly indented with ts=4 */ #ifdef LAME #include #endif #ifdef OGGV #include #endif #include #include #include #include #include #include #include /* for mkdir, not used on Windows */ #if !__MINGW32__ #include #include #include #endif #include "codetables.h" #ifndef VERSION #define VERSION "0.0.0" #endif #define PCMBUFFER 220500 /* 20 seconds at 11kHz, for one word. plenty. */ #define NOISEBUFFER 220500 /* 20 seconds at 11kHz, for one word. plenty. */ #define MP3BUFFER 285000 /* abt 1.25*PCMBUFFER + 7200, as recommended */ #define ISO8859 0 #define UTF8 1 #define MP3 0 #define OGG 1 #define NOENC 2 #define SINE 0 #define SAWTOOTH 1 #define SQUARE 2 #define NOISEAMPLITUDE (10000.0) #define CWAMPLITUDE (20000.0) #ifdef LAME /* Global for LAME */ lame_global_flags *gfp; #endif #ifdef OGGV /* Globals for OGG/Vorbis */ ogg_stream_state os; ogg_page og; ogg_packet op; vorbis_info vi; vorbis_comment vc; vorbis_dsp_state vd; vorbis_block vb; #endif /* Struct CWP to keep all CW parameters */ typedef struct { /* CW parameters */ int wpm, /* speed, words per minute */ freq, /* audio frequency in Hz */ rt, /* risetime, in samples */ ft, /* falltime, in samples */ qrq, /* increase speed each qrq minutes */ reset, /* reset qrq each chapter? */ farnsworth, /* effective, farnsworth speed */ pBT, /* sent for each paragraph? */ waveform, /* waveform, sine(1), sawtooth(2), square(3) */ original_wpm, /* starting speed; if qrq is used */ wordspace, /* wordspace in samples, depends on Farnsworth*/ letterspace; /* inter-letter space */ float ews; /* extra word space */ /* Noise parameters */ int bandpassbw, /* Noise filter bandwidth */ bandpassfc, /* f_center of the bandpass */ addnoise, /* 1 if noise should be added, 0 if not */ snr; /* SNR of the CW with the noise */ /* mp3/ogg encoder parameters, buffers */ int encoder; int samplerate, brate, quality; int inpcm_size, mp3buffer_size, noisebuf_size, ditlen, /* normal dit length in samples */ fditlen, /* farnsworth ditlen in samples */ maxbytes; /* max bytes of a 'dah' */ short int *dit_buf, *dah_buf, *inpcm, *noisebuf; unsigned char *mp3buffer; /* Chapter splitting */ char chapterstr[80], /* split chapters by this string */ chapterfilename[80]; /* time based splitting, seconds */ int chaptertime; /* word based splitting */ int chapterwords; /* encoding and mapping */ int encoding, /* ISO8859 or UTF8 */ use_isomapping, use_utf8mapping; char isomapindex[256]; /* contains the chars to be mapped */ int utf8mapindex[256]; /* for utf8 as decimal code */ char isomap[256][4]; /* by these strings */ char utf8map[256][8]; char configfile[1025]; char id3_author[80], id3_title[80], id3_comment[80], id3_year[5]; FILE *outfile; unsigned int outfile_length; } CWP; /* functions */ void init_cw (CWP *cw); void init_encoder (CWP *cw); void encode_buffer (int length, CWP *cw); void ogg_encode_and_write (CWP *cw); void flush_ogg (CWP *cw); void help (void); void showcodes (int i); int makeword(char * text, CWP *cw); void closefile (int letter, int chw, int chms, CWP *cw); void openfile (int chapter, CWP *cw); void buf_alloc (CWP *cw); void buf_check (int j, CWP *cw); void command (char * cmd, CWP *cw); void readconfig (CWP *cw); int install_config_files (char *homedir, CWP *cw); void setparameter (char p, char * value, CWP *cw); void loadmapping(char *filename, int enc, CWP *cw); char *mapstring (char *string, CWP *cw); void addnoise (int length, CWP *cw); float snramplitude (int snr); void fillnoisebuffer (short int *buf, int size, float amplitude); void filterloop (short int *buf, int l, int b); void scalebuffer(short int *buf, int length, float factor); void addbuffer (short int *b1, short int *b2, int l); char *timestring (int ms); void guessencoding (char *filename); void add_silence (int ms, CWP *cw); #ifdef CGI int hexit (char c); void urldecode(char *buf); #endif /* main */ int main (int argc, char** argv) { int pos, i, c, tmp; char word[1024]=""; /* will be cut when > 1024 chars long */ int chapter = 0; int chw = 0, tw = 0, qw = 0; /* chapter words, total words, qrq words */ int chms = 0, tms = 0, qms = 0; /* millisec: chapter, total, since qrq */ time_t start_time, end_time; /* conversion time */ int finishchapter = 0; /* finish chapter after this sentence */ FILE *infile; #ifdef CGI char * querystring; static char text[10000]; static char outfilename[1024]; #endif #ifdef CGIBUFFERED char *cgibuf; #endif /* initializing the CW parameter struct with standard values */ CWP cw; cw.wpm = 25; cw.freq = 600; cw.rt = 50; cw.ft = 50; cw.qrq = 0; cw.reset = 1; cw.farnsworth = 0; cw.ews = 0.0; cw.pBT = 1; cw.waveform = SINE; cw.bandpassbw = 500; cw.bandpassfc = 800; cw.addnoise = 0; cw.snr = 0; #ifdef LAME cw.encoder = MP3; #else cw.encoder = OGG; #endif cw.samplerate = 11025; cw.brate = 16; cw.quality = 5; cw.inpcm_size = PCMBUFFER; cw.noisebuf_size = NOISEBUFFER; cw.mp3buffer_size = MP3BUFFER; cw.ditlen = 0; strcpy(cw.chapterstr, "CHAPTER"); strcpy(cw.chapterfilename, "Chapter"); cw.chaptertime = 0; cw.chapterwords = 0; cw.encoding = ISO8859; cw.use_isomapping = cw.use_utf8mapping = 0; strcpy(cw.configfile, "ebook2cw.conf"); strcpy(cw.id3_author, "CW audio book"); strcpy(cw.id3_title, ""); strcpy(cw.id3_comment, "Generated by ebook2cw"); strcpy(cw.id3_year, ""); infile = stdin; cw.outfile_length = 0; start_time = time(NULL); srand((unsigned int) start_time); #ifndef CGI printf("ebook2cw %s - (c) 2013 by Fabian Kurz, DJ1YFK\n\n", VERSION); /* * Find and read ebook2cw.conf */ readconfig(&cw); while((i=getopt(argc,argv, "XOo:w:W:e:f:uc:k:Q:R:pF:s:b:q:a:t:y:S:hnT:N:B:C:g:d:l:"))!= -1){ setparameter(i, optarg, &cw); } if (optind < argc) { /* something left? if so, use as infile */ if ((argv[optind][0] != '-') && (argv[optind][0] != '\0')) { if ((infile = fopen(argv[optind], "r")) == NULL) { fprintf(stderr, "Error: Cannot open file %s. Exit.\n", argv[optind]); exit(EXIT_FAILURE); } } } #endif /* ifndef CGI */ /* init encoder (LAME or OGG/Vorbis) */ init_encoder(&cw); /* Initially allocate inpcm, noisebuffer, mp3buffer, dit_buf, dah_buf */ buf_alloc(&cw); #ifndef CGI printf("Speed: %dwpm, Freq: %dHz, Chapter: >%s<, Encoding: %s\n", cw.wpm, cw.freq, cw.chapterstr, cw.encoding == UTF8 ? "UTF-8" : "ISO 8859-1"); printf("Effective speed: %dwpm, ", cw.farnsworth ? cw.farnsworth : cw.wpm); printf("Extra word spaces: %1.1f, ", cw.ews); printf("QRQ: %dmin, reset QRQ: %s\n", cw.qrq, cw.reset ? "yes" : "no"); if (cw.chapterwords) { printf("Chapter limit: %d words, ", cw.chapterwords); } if (cw.chaptertime) { printf("Chapter limit: %d seconds, ", cw.chaptertime); } printf("Encoder: %s\n\n", (cw.encoder == OGG) ? "OGG" : "MP3"); #endif #ifdef CGI /* CGI standard: write directly to stdout ==> no Content-Length possible * CGI buffered: write to file /tmp/$time-$rnd and later generate output */ #ifndef CGIBUFFERED cw.outfile = stdout; #else /* we need to generate a good random number for the file name; * just using rand(time) won't do if two requests come in the * same second. temporarily use cw.outfile FD to open urand */ if ((cw.outfile = fopen("/dev/urandom", "r")) == NULL) { fprintf(stderr, "Error: Failed to open /dev/urandom.\n"); exit(EXIT_FAILURE); } fread(&i, sizeof(i), 1, cw.outfile); srand(i); i = rand(); fclose(cw.outfile); snprintf(outfilename, 80, "/tmp/%d-%d", start_time, i); if ((cw.outfile = fopen(outfilename, "wb+")) == NULL) { fprintf(stderr, "Error: Failed to open %s\n", outfilename); exit(EXIT_FAILURE); } #endif switch (cw.encoder) { case MP3: printf("Content-Type: audio/mpeg\n"); break; case OGG: printf("Content-Type: audio/ogg\n"); break; } #ifndef CGIBUFFERED /* header is finished */ printf("\n"); #endif querystring = getenv("QUERY_STRING"); if ((querystring == NULL) || strlen(querystring) > 9000) { exit(1); } sscanf(querystring, "s=%d&e=%d&f=%d&t=%9000s", &cw.wpm, &cw.farnsworth, &cw.freq, text); strcat(text, " "); urldecode(text); flush_ogg(&cw); #endif init_cw(&cw); /* generate raw dit, dah */ strcat(cw.chapterstr, " "); cw.original_wpm = cw.wpm; /* may be changed by QRQing */ chapter = 0; #ifndef CGI openfile(chapter, &cw); #endif i=0; pos=0; /* 100ms of silence at the start; some decoders otherwise produce * crackling noises */ add_silence(100, &cw); /* read input, assemble full words (anything ending in ' ') to 'word' and * generate CW, write to file by 'makeword'. words with > 1024 characters * will be split */ #ifndef CGI while ((c = getc(infile)) != EOF) { #else while ((c = text[i++]) != '\0') { #endif if (c == '\r') /* DOS linebreaks */ continue; word[pos++] = c; if ((c == ' ') || (c == '\n') || (pos == 1024)) { word[pos] = '\0'; #ifndef CGI /* new chapter */ if ((strcmp(cw.chapterstr, word) == 0) || /* regular */ finishchapter == 2 ) { closefile(chapter, chw, chms, &cw); tw += chw; tms += chms; chw = 0; chms = 0; chapter++; if (cw.qrq && cw.reset) { cw.wpm = cw.original_wpm; init_cw(&cw); qw = 0; } finishchapter = 0; openfile(chapter, &cw); } #endif /* check for commands: |f or |w */ if (word[0] == '|') { command(word, &cw); } else { tmp = makeword(mapstring(word, &cw), &cw); chms += tmp; qms += tmp; chw++; } /* Every 'cw.qrq' minutes speed up 1 WpM */ if (cw.qrq && ((qms/60000.0) > cw.qrq)) { cw.wpm += 1; init_cw(&cw); printf("QRQ: %dwpm\n", cw.wpm); qms = 0; } /* word finished; reached word- or time-limit? */ if (finishchapter || (cw.chaptertime && chms/1000 >= cw.chaptertime) || (cw.chapterwords && chw == cw.chapterwords)) { /* Yes! Finish sentence (i.e. until next '.', '!' or '?') * and then start a new chapter */ finishchapter = 1; /* End of sentence? */ if (word[pos-2] == '.' || word[pos-2] == '!' || word[pos-2] == '?') { finishchapter = 2; } } word[0] = '\0'; pos = 0; } /* word */ } /* eof */ /* CGI: Add some silence (500ms) to the end of the file */ #ifdef CGI add_silence(500, &cw); #endif #ifndef CGI closefile(chapter, chw, chms, &cw); end_time = time(NULL); printf("Total words: %d, total time: %s\n", tw+chw, timestring(tms+chms)); printf("Conversion time: %s (Speedup: %.1fx)\n", timestring(1000.0 * difftime(end_time, start_time)), ((tms+chms)/(1000.0 * difftime(end_time,start_time))) ); #else /* in CGI mode, we need to do this to close the file properly */ if (cw.encoder == OGG) { /* (otherwise done in closefile() */ #ifdef OGGV vorbis_analysis_wrote(&vd,0); ogg_encode_and_write(&cw); #endif } #endif if (cw.encoder == MP3) { #ifdef LAME lame_close(gfp); #endif } else { #ifdef OGGV ogg_stream_clear(&os); vorbis_block_clear(&vb); vorbis_dsp_clear(&vd); vorbis_comment_clear(&vc); vorbis_info_clear(&vi); #endif } free(cw.mp3buffer); free(cw.inpcm); free(cw.noisebuf); #ifdef CGIBUFFERED /* File is completed, so we know the length and can send the * content length header, and then the whole file */ printf("Content-Length: %d\n", cw.outfile_length); printf("\n"); i = (int) ftell(cw.outfile); rewind(cw.outfile); /* maybe one day sendfile(2) will support writing to a * file descriptor, not just a socket, to make this * easier and faster... */ cgibuf = malloc((size_t) i+1); if (cgibuf == NULL) { fprintf(stderr, "malloc() for cgibuf failed!\n"); exit(EXIT_FAILURE); } fread(cgibuf, sizeof(char), (size_t) i, cw.outfile); fclose(cw.outfile); fwrite(cgibuf, sizeof(char), (size_t) i, stdout); unlink(outfilename); #endif return (EXIT_SUCCESS); } /* init_cw - generates a dit and a dah to dit_buf and dah_buf */ void init_cw (CWP *cw) { int x, len; double val, val1, val2; /* calculate farnsworth length samples */ if (cw->farnsworth) { if (cw->farnsworth > cw->wpm) { fprintf(stderr, "Warning: Effective speed (-e %d) must be lower " "than character speed (-w %d)! Speed adjusted.\n", cw->farnsworth, cw->wpm); cw->farnsworth = cw->wpm; } cw->fditlen = (int) (6.0*cw->samplerate/(5.0*cw->farnsworth)); } /* dit */ len = (int) (6.0*cw->samplerate/(5.0*cw->wpm)); /* in samples */ /* size of dit_buf, dah_buf may have to be increased, when speed decreased */ if (len > cw->ditlen) { if ((cw->dah_buf = realloc(cw->dah_buf, 3*len * sizeof(short int))) == NULL) { fprintf(stderr, "Error: Can't reallocate dah_buf[%d]\n", 3*len); exit(EXIT_FAILURE); } if ((cw->dit_buf = realloc(cw->dit_buf, len * sizeof(short int))) == NULL) { fprintf(stderr, "Error: Can't allocate dit_buf[%d]\n", len); exit(EXIT_FAILURE); } } /* both dah_buf and dit_buf are filled in this loop */ for (x=0; x < 3*len; x++) { switch (cw->waveform) { case SINE: val = sin(2*M_PI*cw->freq*x/cw->samplerate); break; case SAWTOOTH: val = ((1.0*cw->freq*x/cw->samplerate)- floor(1.0*cw->freq*x/cw->samplerate))-0.5; break; case SQUARE: val = ceil(sin(2*M_PI*cw->freq*x/cw->samplerate))-0.5; break; } /* Shaping rising edge, same for dit and dah */ if (x < cw->rt) val *= pow(sin(M_PI*x/(2.0*cw->rt)),2); val1 = val2 = val; /* Shaping falling edge, dit */ if (x < len) { if (x > (len-cw->ft)) { val1 *= pow((sin(2*M_PI*(x-(len-cw->ft)+cw->ft)/(4*cw->ft))), 2); } cw->dit_buf[x] = (short int) (val1 * CWAMPLITUDE); } /* Shaping falling edge, dah */ if (x > (3*len-cw->ft)) { val2 *= pow((sin(2*M_PI*(x-(3*len-cw->ft)+cw->ft)/(4*cw->ft))), 2); } cw->dah_buf[x] = (short int) (val2 * CWAMPLITUDE); } /* for */ cw->ditlen = len; /* Calculate maximum number of bytes per 'dah' for the PCM stream, * this will be used later to check if the buffer runs full * (10000 margin) */ if (cw->farnsworth) { cw->maxbytes = (int) ((4+7.0*cw->ews)*(cw->fditlen)) + 10000; } else { cw->maxbytes = (int) ((6+7.0*cw->ews) * len) + 10000; } /* Calculate word space, letter space, considering EWS and farnsworth */ cw->wordspace =(int)(1+7*cw->ews)*(cw->farnsworth ? cw->fditlen : cw->ditlen); cw->letterspace = (cw->farnsworth ? 3*cw->fditlen - cw->ditlen : 2*cw->ditlen); return; } /* makeword -- converts 'text' to CW by concatenating dit_buf amd dah_bufs, * encodes this to MP3 and writes to open filehandle outfile */ int makeword(char * text, CWP *cw) { const char *code; /* CW code as . and - */ int c, i, j, u, w; int prosign = 0; unsigned char last=0; /* for utf8 2-byte characters */ j = 0; /* position in 'inpcm' buffer */ for (i = 0; i < strlen(text); i++) { c = (unsigned char) text[i]; code = NULL; if (c == '\n') { /* Same for UTF8 and ISO8859 */ if ((strlen(text) == 1) && cw->pBT) /* paragraph */ code = " -...- "; else code = " "; } else if (c == '<') { /* prosign on */ prosign = 1; continue; } else if ((c == '>') && prosign) { /* prosign off */ prosign = 0; code = ""; /* only inserts letter space */ } else if (cw->encoding == ISO8859) { code = iso8859[c]; } else if (cw->encoding == UTF8) { /* Character may be 1-byte ASCII or 2-byte UTF8 */ if (!(c & 128)) { /* MSB = 0 -> 7bit ASCII */ code = iso8859[c]; /* subset of iso8859 */ } else { if (last && (c < 192) ) { /* this is the 2nd byte */ /* 110yyyyy 10zzzzzz -> 00000yyy yyzzzzzz */ c = ((last & 31) << 6) | (c & 63); code = utf8table[c]; last = 0; } else { /* this is the first byte */ last = c; } } } if (last) continue; /* first of two-byte character read */ /* Not found anything, produce warning message */ if (code == NULL) { #ifndef CGI if (c < 255) { fprintf(stderr, "Warning: don't know CW for '%c'\n", c); } else { fprintf(stderr, "Warning: don't know CW for unicode &#%d;\n", c); } #endif code = " "; } /* code contains letter as ./-, now assemble pcm buffer */ for (w = 0; w < strlen(code) ; w++) { /* make sure the inpcm buffer doesn't run full, * with a conservative margin. reallocate memory if neccesary */ buf_check(j, cw); c = code[w]; if (c == '.') for (u=0; u < cw->ditlen; u++) cw->inpcm[++j] = cw->dit_buf[u]; else if (c == '-') for (u=0; u < (3*cw->ditlen); u++) cw->inpcm[++j] = cw->dah_buf[u]; else /* word space */ for (u=0;u < cw->wordspace; u++) cw->inpcm[++j] = 0; for (u=0; u < cw->ditlen; u++) cw->inpcm[++j] = 0; } /* foreach dot/dash */ if (prosign == 0) { for (u=0; u < cw->letterspace; u++) cw->inpcm[++j] = 0; } } /* foreach letter */ /* j = total length of samples in 'inpcm' */ if (cw->addnoise) { addnoise(j, cw); } encode_buffer(j, cw); return (int) (1000.0*j/cw->samplerate); /* encoded length in ms */ } /* closefile -- finishes writing the current file, flushes the encoder buffer */ void closefile (int chapter, int chw, int chms, CWP *cw) { int outbytes; char outfilename[80] = ""; outbytes = 0; printf("words: %d, time: %s\n", chw, timestring(chms)); snprintf(outfilename, 80, "%s%04d.%s", cw->chapterfilename, chapter, (cw->encoder == MP3) ? "mp3" : "ogg"); printf("Finishing %s\n\n", outfilename); switch (cw->encoder) { case MP3: #ifdef LAME outbytes = lame_encode_flush(gfp,cw->mp3buffer, cw->mp3buffer_size); if (outbytes < 0) { fprintf(stderr, "Error: lame_encode_buffer returned %d.\n", outbytes); exit(EXIT_FAILURE); } if (fwrite(cw->mp3buffer, sizeof(char), outbytes, cw->outfile) != outbytes) { fprintf(stderr, "Error: Writing %db to file failed. Exit.\n", outbytes); exit(EXIT_FAILURE); } cw->outfile_length += outbytes; #endif break; case OGG: #ifdef OGGV vorbis_analysis_wrote(&vd,0); ogg_encode_and_write(cw); #endif break; case NOENC: /* Do nothing */ break; } if (cw->encoder != NOENC) fclose(cw->outfile); } /* openfile -- starts a new chapter by opening a new file as outfile */ void openfile (int chapter, CWP *cw) { char outfilename[80] = ""; #ifdef LAME static char tmp[80] = ""; #endif #ifdef OGGV ogg_packet hdr; ogg_packet hdr_comm; ogg_packet hdr_code; #endif snprintf(outfilename, 80, "%s%04d.%s", cw->chapterfilename, chapter, (cw->encoder == MP3) ? "mp3" : "ogg"); printf("Starting %s\n", outfilename); if ((cw->encoder != NOENC) && (cw->outfile = fopen(outfilename, "wb")) == NULL) { fprintf(stderr, "Error: Failed to open %s\n", outfilename); exit(EXIT_FAILURE); } switch (cw->encoder) { case MP3: #ifdef LAME snprintf(tmp, 79, "%s - %d", cw->id3_title, chapter); /* title */ id3tag_init(gfp); id3tag_set_artist(gfp, cw->id3_author); id3tag_set_year(gfp, cw->id3_year); id3tag_set_title(gfp, tmp); id3tag_set_comment(gfp, cw->id3_comment); #endif break; case OGG: #ifdef OGGV vorbis_comment_init(&vc); vorbis_comment_add_tag(&vc,"ENCODER","ebook2cw"); vorbis_analysis_init(&vd, &vi); vorbis_block_init(&vd, &vb); ogg_stream_init(&os,rand()); vorbis_analysis_headerout(&vd,&vc,&hdr,&hdr_comm,&hdr_code); ogg_stream_packetin(&os,&hdr); ogg_stream_packetin(&os,&hdr_comm); ogg_stream_packetin(&os,&hdr_code); flush_ogg(cw); #endif break; case NOENC: /* Do nothing */ break; } } void help (void) { printf("This is free software, and you are welcome to redistribute it\n"); printf("under certain conditions (see COPYING).\n"); printf("\n"); printf("ebook2cw [-w wpm] [-f freq] [-R risetime] [-F falltime]\n"); printf(" [-s samplerate] [-b mp3bitrate] [-q mp3quality] [-p]\n"); printf(" [-c chapter-separator] [-o outfile-name] [-Q minutes]\n"); printf(" [-a author] [-t title] [-k comment] [-y year]\n"); printf(" [-u] [-S ISO|UTF] [-n] [-e eff.wpm] [-W space]\n"); printf(" [-N snr] [-B filter bandwidth] [-C filter center]\n"); printf(" [-T 0..2] [-g filename] [-l words] [-d seconds]\n"); printf(" [infile]\n\n"); printf("defaults: 25 WpM, 600Hz, RT=FT=50, s=11025Hz, b=16kbps,\n"); printf(" c=\"CHAPTER\", o=\"Chapter\" infile = stdin\n"); printf("\n"); printf("Compile options: USE_LAME=" #ifdef LAME "YES " #else "NO " #endif "USE_OGG=" #ifdef OGGV "YES " #else "NO " #endif "DESTDIR="DESTDIR"\n"); printf("\n"); printf("Project website: http://fkurz.net/ham/ebook2cw.html\n"); exit(EXIT_SUCCESS); } /* * showcodes * Generates a HTML table of the available CW symbols in codetables.h * i = 1 -> ISO 8859-1, i=0 -> UTF-8 */ void showcodes (int i) { int k; int n = i ? 256 : 1921; printf("\n", i ? "iso-8859-1" : "utf-8"); printf("

ebook2cw codetables.h

\n"); printf("

%s

\n", i ? "ISO 8859-1" : "UTF-8"); printf("\n"); for (k=0; k < n; k++) { printf(""); if ((k < 128+i*128) && (iso8859[k] != NULL)) { printf("", k, k, iso8859[k]); } else if (utf8table[k] != NULL) { printf("", k, k, utf8table[k]); } else { printf("", k, k); } printf("\n"); } printf("
DecimalSymbolCW
%d&#%d;%s%d&#%d;%s%d&#%d; 
\n"); exit(EXIT_SUCCESS); } /* make sure the inpcm-buffer doesn't run full. * has to consider the effects of Farnsworth and extra word spacing * since memory is cheap and cpu cycles are precious, the size of the * buffers is doubled each time they run full (if they ever do) */ void buf_check (int j, CWP *cw) { if (j > cw->inpcm_size - cw->maxbytes) { cw->inpcm_size *= 2; cw->noisebuf_size = cw->inpcm_size; cw->mp3buffer_size *= 2; if ((cw->inpcm = realloc(cw->inpcm, cw->inpcm_size*sizeof(short int)))== NULL) { fprintf(stderr, "Error: Can't realloc inpcm[%d]\n", cw->inpcm_size); exit(EXIT_FAILURE); } if ((cw->noisebuf = realloc(cw->noisebuf, cw->noisebuf_size*sizeof(short int)))== NULL) { fprintf(stderr, "Error: Can't realloc noisebuf[%d]\n", cw->noisebuf_size); exit(EXIT_FAILURE); } fillnoisebuffer(cw->noisebuf, cw->noisebuf_size, NOISEAMPLITUDE); if ((cw->mp3buffer = realloc(cw->mp3buffer, cw->mp3buffer_size*sizeof(char))) == NULL) { fprintf(stderr, "Error: Can't realloc mp3buffer[%d]\n", cw->mp3buffer_size); exit(EXIT_FAILURE); } } } /* command * Receives a 'word' which starts with a | and then (possibly) a command, * to change speed or tone freq. */ void command (char * cmd, CWP *cw) { int i = 0; unsigned char c = 0; sscanf(cmd, "|%c%d", &c, &i); switch (c) { case 'f': if ((i > 100) && (i < (int) cw->samplerate/2)) { cw->freq = i; init_cw(cw); } else fprintf(stderr, "Invalid frequency: %s. Ignored.\n", cmd); break; case 'w': if (i > 1) { cw->wpm = i; init_cw(cw); } else fprintf(stderr, "Invalid speed: %s. Ignored.\n", cmd); break; case 'e': if (i > 1) { cw->farnsworth = i; init_cw(cw); } else fprintf(stderr, "Invalid speed: %s. Ignored.\n", cmd); break; case 'T': if (i >= 0 && i < 3) { cw->waveform = i; init_cw(cw); } else fprintf(stderr, "Invalid waveform: %d. Ignored.\n", i); break; case 'v': init_cw(cw); scalebuffer(cw->dit_buf, cw->ditlen, (float) (i/100.0)); scalebuffer(cw->dah_buf, 3*cw->ditlen, (float) (i/100.0)); break; case 'N': cw->addnoise = 1; cw->snr = i; break; default: fprintf(stderr, "Invalid command %s. Ignored.\n", cmd); } } /* readconfig * * reads a ebook2cw.conf file and sets parameters from the [settings] * part, then looks for character mappings in the [mappings] part. * * ebook2cw.conf is first searched in the current directory, then * ~/.ebook2cw/ and finally in DESTDIR/share/doc/ebook2cw/examples/ * and copied to ~/.ebook2cw/ if needed. * * A sample config `ebook2cw.conf' is included. */ void readconfig (CWP *cw) { FILE *conf = NULL; char tmp[1024] = ""; char p; /* parameter */ char v[80]=""; /* value */ static char mapfile[1024]=""; char *homedir = NULL; /* Part 1: * Find config file; if not found try to copy/install it to * ~/.ebook2cw */ if ((conf = fopen(cw->configfile, "r")) == NULL) { /* ebook2cw.conf not in current directory */ if ((homedir = getenv("HOME")) == NULL) { /* no home or Windows */ return; } #if !__MINGW32__ /* Linux/Unix: Look for ~/.ebook2cw/ebook2cw.conf */ snprintf(cw->configfile, 2048, "%s/.ebook2cw/ebook2cw.conf", homedir); if ((conf = fopen(cw->configfile, "r")) == NULL) { /* Not in ~/.ebook2cw/ either, look for it in * DESTDIR/ebook2cw/examples/ */ if ((conf = fopen(DESTDIR "/share/doc/ebook2cw/examples/ebook2cw.conf","r")) == NULL) { /* cannot find ebook2cw.conf anywhere. silently return */ return; } /* First run, we install/copy the defaults to ~/.ebook2cw */ else if (install_config_files(homedir, cw) == 0) { /* Files installed to ~/.ebook2cw/ */ snprintf(cw->configfile, 1024, "%s/.ebook2cw/ebook2cw.conf", homedir); /* open newly installed config file ... */ if ((conf = fopen(cw->configfile, "r")) == NULL) { printf("Couldn't read %s! Continue without config.", cw->configfile); return; } } else { /* installing didn't work for some reason, silently * return */ return; } } #endif } /* Part 2: * Read config file */ printf("Reading configuration file: %s\n\n", cw->configfile); /* We start in the [settings] section. * All settings are ^[a-zA-Z]=.+$ * */ while ((feof(conf) == 0) && (fgets(tmp, 80, conf) != NULL)) { tmp[strlen(tmp)-1]='\0'; if (strstr(tmp, "[mappings]")) { /* all parameters read */ break; } else { if (sscanf(tmp, "%c=%s", &p, v) == 2) { setparameter(p, v, cw); } } } /* mappings */ while ((feof(conf) == 0) && (fgets(tmp, 80, conf) != NULL)) { tmp[strlen(tmp)-1]='\0'; if (sscanf(tmp, "isomapfile=%255s", mapfile) == 1) { loadmapping(mapfile, ISO8859, cw); } else if (sscanf(tmp, "utf8mapfile=%255s", mapfile) == 1) { loadmapping(mapfile, UTF8, cw); } } } void setparameter (char i, char *value, CWP *cw) { switch (i) { case 'w': if ((cw->wpm = atoi(value)) < 1) { fprintf(stderr, "Error: Speed (-w) must be > 0!\n"); exit(EXIT_FAILURE); } break; case 'f': cw->freq = atoi(value); break; case 'R': cw->rt = atoi(value); break; case 'F': cw->ft = atoi(value); break; case 's': cw->samplerate = atoi(value); break; case 'b': cw->brate = atoi(value); break; case 'q': cw->quality = atoi(value); break; case 'd': /* chapter duration in seconds (optional!) */ cw->chaptertime = atoi(value); break; case 'l': /* chapter length in words (optional!) */ cw->chapterwords = atoi(value); break; case 'c': strncpy(cw->chapterstr, value, 78); break; case 'o': strncpy(cw->chapterfilename, value, 78); break; case 'a': strncpy(cw->id3_author, value, 78); break; case 't': strncpy(cw->id3_title, value, 75); break; case 'k': strncpy(cw->id3_comment, value, 78); break; case 'y': strncpy(cw->id3_year, value, 4); break; case 'Q': if ((cw->qrq = atoi(value)) < 1) { fprintf(stderr, "Error: QRQ time (-Q) must be > 0!\n"); exit(EXIT_FAILURE); } break; case 'u': cw->encoding = UTF8; break; case 'S': if (strstr(value, "ISO")) { showcodes(1); } else { showcodes(0); } break; case 'e': /* effective speed in WpM */ if ((cw->farnsworth = atoi(value)) < 1) { fprintf(stderr, "Error: Eff. speed (-e) must be > 0!\n"); exit(EXIT_FAILURE); } break; case 'W': cw->ews = atof(value); break; case 'n': cw->reset = 0; break; case 'O': #ifdef OGGV cw->encoder = OGG; #else fprintf(stderr, "Warning: ebook2cw was compiled without OGG support! Using Lame encoder.\n\n"); #endif break; case 'X': /* "Fake" */ cw->encoder = NOENC; break; case 'p': cw->pBT = 0; break; case 'g': guessencoding(value); break; case 'h': help(); break; case 'T': if (strstr(value, "SINE") || atoi(value) == 0) { cw->waveform = SINE; } else if (strstr(value, "SAWTOOTH") || atoi(value) == 1) { cw->waveform = SAWTOOTH; } else if (strstr(value, "SQUARE") || atoi(value) == 2) { cw->waveform = SQUARE; } break; case 'N': cw->snr = atoi(value); cw->addnoise = 1; if ((cw->snr < -10) || (cw->snr > 10)) { fprintf(stderr, "Warning: SNR %ddB not implemented." " Noise disabled.\n\n", cw->snr); cw->addnoise = 0; cw->snr = 0; } break; case 'B': cw->bandpassbw = atoi(value); break; case 'C': cw->bandpassfc = atoi(value); break; } /* switch */ } /* loadmapping * * opens a mapping file and writes the mappings to the mapping variables: * index: utf8mapindex, isomapindex * mappings: utf8map, isomap * */ void loadmapping(char *file, int enc, CWP *cw) { FILE *mp; char tmp[81] = ""; int i=0; int k=0; char c1=0; char c2=0; char s[6]=""; if ((mp = fopen(file, "r")) == NULL) { fprintf(stderr, "Warning: Unable to open mapping file %s. Ignored.\n", file); return; } switch (enc) { case ISO8859: memset(cw->isomapindex, 0, sizeof(char)*256); cw->use_isomapping = 1; break; case UTF8: memset(cw->utf8mapindex, 0, sizeof(int)*256); cw->use_utf8mapping = 1; break; } while ((feof(mp) == 0) && (fgets(tmp, 80, mp) != NULL)) { tmp[strlen(tmp)-1]='\0'; switch (enc) { case ISO8859: if (sscanf(tmp, "%c=%3s", &c1, s) == 2) { cw->isomapindex[i] = c1; strncpy(cw->isomap[i], s, 3); i++; } break; case UTF8: if (sscanf(tmp, "%c=%5s", &c1, s) == 2) { cw->utf8mapindex[i] = c1; strncpy(cw->utf8map[i], s, 5); i++; } else if (sscanf(tmp, "%c%c=%5s", &c1, &c2, s) == 3) { k = ((c1 & 31) << 6) | (c2 & 63); /* decimal */ cw->utf8mapindex[i] = k; /* unicode char */ strncpy(cw->utf8map[i], s, 5); i++; } break; } /* only memory for 256 mappings allocated. never going to happen */ if (i == 255) { fprintf(stderr, "Warning: Maximum number (256) of mappings reached" " in %s! Stopped here.", file); break; } } /* while */ } /* mapstring * receives a string and replaces all characters that show up in isomapindex / * utf8mapindex with their replacement strings, and returns it. */ char *mapstring (char * string, CWP *cw) { static char new[2048]=""; char c; int i, j, replaced; unsigned char last=0; memset(new, 0, 2048); switch (cw->encoding) { case ISO8859: if (!cw->use_isomapping) { return string; } while ((c = *string++) != '\0') { replaced = 0; for (i=0; i < 255; i++) { if (cw->isomapindex[i] == 0) { break; } else if (cw->isomapindex[i] == c) { strcat(new, cw->isomap[i]); replaced = 1; break; } } if (!replaced) { new[strlen(new)] = c; } } break; case UTF8: if (!cw->use_utf8mapping) { return string; } while ((c = *string++) != '\0') { j = 0; replaced = 0; if (!last && (c & 128)) { /* first of a 2 char seq */ last = c; continue; } if (last) { /* 110yyyyy 10zzzzzz -> 00000yyy yyzzzzzz */ j = ((last & 31) << 6) | (c & 63); } else { j = c; } for (i=0; i < 255; i++) { if (cw->utf8mapindex[i] == 0) { break; } else if (cw->utf8mapindex[i] == j) { strcat(new, cw->utf8map[i]); replaced = 1; break; } } if (!replaced) { if (last) { new[strlen(new)] = last; new[strlen(new)] = c; } else { new[strlen(new)] = c; } } last = 0; } } return new; } void buf_alloc(CWP *cw) { /* pcm, noise and mp3 buffers will be increased later as needed, but the * initial values should be sufficient for most speeds and reasonably long * words */ if ((cw->inpcm = calloc(PCMBUFFER, sizeof(short int))) == NULL) { fprintf(stderr, "Error: Can't allocate inpcm[%d]!\n", PCMBUFFER); exit(EXIT_FAILURE); } cw->inpcm_size = PCMBUFFER; if ((cw->noisebuf = calloc(NOISEBUFFER, sizeof(short int))) == NULL) { fprintf(stderr, "Error: Can't allocate noisebuf[%d]!\n", NOISEBUFFER); exit(EXIT_FAILURE); } cw->noisebuf_size = NOISEBUFFER; fillnoisebuffer(cw->noisebuf, cw->noisebuf_size, NOISEAMPLITUDE); if ((cw->mp3buffer = calloc(MP3BUFFER, sizeof(unsigned char))) == NULL) { fprintf(stderr, "Error: Can't allocate mp3buffer[%d]!\n", MP3BUFFER); exit(EXIT_FAILURE); } cw->mp3buffer_size = MP3BUFFER; /* Just give it one byte now. It will be reallocated everytime init_cw is * called, but to make it easy, allocate *something* to it now */ if ((cw->dah_buf = calloc(1, sizeof(short int))) == NULL) { fprintf(stderr, "Error: Can't allocate dah_buf[1]!\n"); exit(EXIT_FAILURE); } if ((cw->dit_buf = calloc(1, sizeof(short int))) == NULL) { fprintf(stderr, "Error: Can't allocate dit_buf[1]!\n"); exit(EXIT_FAILURE); } } #ifdef CGI /* * URLDECODE stuff, needed for the CGI only: * */ /* Anti-Web HTTPD */ /* Hardcore Software */ /* This software is Copyright (C) 2001-2004 By Hardcore Software and others. The software is distributed under the terms of the GNU General Public License. See the file 'COPYING' for more details. */ /* This code is Copyright (C) 2001 By Zas ( zas at norz.org ) The software is distributed under the terms of the GNU General Public License. See the file 'COPYING' for more details. */ /* I might've modified this slightly, but it's definitley Zas'. -Fractal */ int hexit(char c) { if ( c >= '0' && c <= '9' ) return c - '0'; if ( c >= 'a' && c <= 'f' ) return c - 'a' + 10; if ( c >= 'A' && c <= 'F' ) return c - 'A' + 10; return 0; } /* Decode string %xx -> char (in place) */ void urldecode(char *buf) { int v; char *p, *s, *w; w=p=buf; while (*p) { v=0; if (*p=='%') { s=p; s++; if (isxdigit((int) s[0]) && isxdigit((int) s[1]) ) { v=hexit(s[0])*16+hexit(s[1]); if (v) { /* do not decode %00 to null char */ *w=(char)v; p=&s[1]; } } } if (!v) *w=*p; p++; w++; } *w='\0'; return; } #endif /* ifdef CGI */ /* addnoise: adds noise with bandwidth, center frequency and SNR as defined in CWP noise amplitude is constant, the CW amplitude is scaled. */ void addnoise (int length, CWP *cw) { scalebuffer(cw->inpcm, cw->inpcm_size, snramplitude(cw->snr)); addbuffer(cw->inpcm, cw->noisebuf, cw->inpcm_size); filterloop(cw->inpcm, cw->inpcm_size, cw->bandpassbw); } /* snramplitude - returns the amplitude needed for a SNR of "snr" dB as float; noise average amplitude considered to be 0.25 Currently implemented by a lookup table with fixed, precalculated values. */ float snramplitude (int snr) { /* Lookup table; first value = -10dB, last +10dB */ float snrlookup[21] = { 0.042, 0.0475, 0.0533, 0.0599, 0.067, 0.075, 0.084, 0.094, 0.1055, 0.1187, 0.134, 0.15, 0.168, 0.19, 0.213, 0.238, 0.267, 0.3, 0.335, 0.378, 0.425 }; return snrlookup[snr+10]; } void fillnoisebuffer (short int *buf, int size, float amplitude) { int i; for (i=0; i < size; i++) { buf[i] = (short int) (2.0*amplitude*(rand()/(1.0*RAND_MAX)-0.5)); } } /* * Digital filter designed by mkfilter/mkshape/gencode A.J. Fisher Command * line: /www/usr/fisher/helpers/mkfilter -Bu -Bp -o 3 -a 3.7500000000e-02 * 1.6250000000e-01 -l * * Modified to filter "in place" with one array (buf) of length l */ void filterloop (short int *buf, int l, int b) { static float xv[7], yv[7]; short int *in; /* 4 filters with each 6 coefficients */ static float c[4][6] = { /* 100Hz */ {-0.6235385946, 3.3779247772, -8.2824221345, 11.5675604240, -9.6967045468, 4.6299593645}, /* 500Hz */ {-0.4535459334, 2.5370880100, -6.4847845669, 9.5144072211, -8.4472239809, 4.3051177389}, /* 1000Hz */ {-0.1978251873, 1.3168771088, -3.8803884946, 6.5449240143, -6.6950970397, 3.9046544087}, /* 2100Hz */ {0.0131505881, 0.2450198734, -0.6698556894, 0.9667482217, -1.8996423954, 2.3375093931} }; static float gain[4] = { 7.637953014e+02, 1.886640723e+02, 3.154970680e+01, 5.346000407e+00 }; long int k; /* bandwidth -> filter parameters */ if (b < 500 ) { b = 0; } else if (b < 1000) { b = 1; } else if (b < 2100) { b = 2; } else { b = 4; } in = calloc(l, sizeof (short int)); memcpy(in, buf, l*sizeof(short int)); for (k = 0; k < l; k++) { xv[0] = xv[1]; xv[1] = xv[2]; xv[2] = xv[3]; xv[3] = xv[4]; xv[4] = xv[5]; xv[5] = xv[6]; xv[6] = ((float) in[k] / 255) / gain[b]; yv[0] = yv[1]; yv[1] = yv[2]; yv[2] = yv[3]; yv[3] = yv[4]; yv[4] = yv[5]; yv[5] = yv[6]; yv[6] = (xv[6] - xv[0]) + 3 * (xv[2] - xv[4]) + (c[b][0] * yv[0]) + (c[b][1] * yv[1]) + (c[b][2] * yv[2]) + (c[b][3] * yv[3]) + (c[b][4] * yv[4]) + (c[b][5] * yv[5]); buf[k] = (short int) (yv[6] * 255.0); } } void scalebuffer(short int *buf, int length, float factor) { int i; for (i=0; i < length; i++) { buf[i] = (short int) buf[i]*factor; } } /* Adds buffer b2 to b1 with length l */ void addbuffer (short int *b1, short int *b2, int l) { int i; for (i=0; i < l; i++) { b1[i] += b2[i]; } } void init_encoder (CWP *cw) { #ifdef OGGV ogg_packet hdr; ogg_packet hdr_comm; ogg_packet hdr_code; #endif if (cw->encoder == MP3) { #ifdef LAME gfp = lame_init(); lame_set_num_channels(gfp,1); lame_set_brate(gfp, cw->brate); lame_set_in_samplerate(gfp, cw->samplerate); lame_set_out_samplerate(gfp, cw->samplerate); lame_set_mode(gfp,1); lame_set_quality(gfp, cw->quality); if (lame_init_params(gfp) < 0) { fprintf(stderr, "Failed: lame_init_params(gfp).\n\nPossible reason:\n * Bad sample rate, must be: 8k, 11.025k, 12k, 16k, 22.05k, 32k, 44.1k, 48k\n * Selected samplerate too high for selected bitrate.\n"); exit(1); } #endif } else { /* OGG */ #ifdef OGGV vorbis_info_init(&vi); if (vorbis_encode_init_vbr(&vi,1,cw->samplerate,0.7)) { fprintf(stderr, "Failed: vorbis_encode_init_vbr()\n"); exit(1); } vorbis_comment_init(&vc); vorbis_comment_add_tag(&vc,"ENCODER","ebook2cw"); vorbis_analysis_init(&vd, &vi); vorbis_block_init(&vd, &vb); ogg_stream_init(&os,rand()); vorbis_analysis_headerout(&vd,&vc,&hdr,&hdr_comm,&hdr_code); ogg_stream_packetin(&os,&hdr); ogg_stream_packetin(&os,&hdr_comm); ogg_stream_packetin(&os,&hdr_code); #endif } } void ogg_encode_and_write (CWP *cw) { /* vorbis_analysis_wrote() must have been called */ #ifdef OGGV /* Encode and write */ while (vorbis_analysis_blockout(&vd,&vb) == 1) { vorbis_analysis(&vb, NULL); vorbis_bitrate_addblock(&vb); while (vorbis_bitrate_flushpacket(&vd,&op)) { ogg_stream_packetin(&os,&op); while (1) { int result = ogg_stream_pageout(&os,&og); if (result == 0) break; fwrite(og.header,1,og.header_len, cw->outfile); fwrite(og.body,1,og.body_len, cw->outfile); cw->outfile_length += og.header_len; cw->outfile_length += og.body_len; } } } #endif } /* current content of the cw.inpcm buffer is encoded and written * to the cw.outfile */ void encode_buffer (int length, CWP *cw) { #ifdef LAME int outbytes; #endif #ifdef OGGV int i; float **buffer; /* for OGG enc only */ #endif switch (cw->encoder) { case MP3: #ifdef LAME outbytes = lame_encode_buffer(gfp, cw->inpcm, cw->inpcm, length, cw->mp3buffer, cw->mp3buffer_size); if (outbytes < 0) { fprintf(stderr, "Error: lame_encode_buffer returned %d. " "Exit.\n", outbytes); exit(EXIT_FAILURE); } if (fwrite(cw->mp3buffer, sizeof(char), outbytes, cw->outfile) != outbytes) { fprintf(stderr, "Error: Writing %db to file failed. Exit.\n", outbytes); exit(EXIT_FAILURE); } cw->outfile_length += outbytes; #endif break; case OGG: #ifdef OGGV buffer = vorbis_analysis_buffer(&vd, length); for (i=0; i < length; i++) { buffer[0][i] = (float) cw->inpcm[i]/(1.8*CWAMPLITUDE); } vorbis_analysis_wrote(&vd,i); ogg_encode_and_write(cw); #endif break; case NOENC: /* do nothing at all */ break; } /* switch */ } /* pretty print of a input value (milliseconds) as a string in the * form: hh:mm:ss or mm:ss or ss, depending on the length */ char *timestring (int ms) { int h = 0, m = 0, s = 0; static char t[32]; while (ms > 3600000) { /* hours */ h++; ms -= 3600000; } while (ms > 60000) { /* minutes */ m++; ms -= 60000; } while (ms > 1000) { /* seconds */ s++; ms -= 1000; } if (h) { snprintf(t, 31, "%d:%02d:%02d", h, m, s); } else if (m) { snprintf(t, 31, "%02d:%02d", m, s); } else { snprintf(t, 31, "%ds", s); } return t; } /* tries to guess the encoding (UTF8, ISO8859-1) of a file * * Indicator for UTF-8 (2-byte chars): 110xxxxx 10xxxxxx * */ void guessencoding (char *filename) { FILE *infile; unsigned int c; int is_iso = 1; if ((infile = fopen(filename, "r")) == NULL) { fprintf(stderr, "Error: Cannot open file %s. Exit.\n", filename); exit(EXIT_FAILURE); } printf("Guessed file format of %s: ", filename); while ((c = getc(infile)) != EOF) { if ((c & 224) == 192) { /* check if highest 3 bits are 110=224 */ c = getc(infile); /* next byte 10xxxxxx? */ if ((c & 192) == 128) { is_iso = 0; break; } } } printf("%s\n\n", (is_iso ? "ISO 8859-1" : "UTF-8")); exit(EXIT_SUCCESS); } /* Flush OGG stream. Originally this was in the openfile() * function but since openfile() is not called in CGI mode, * but this flushing is necessary, it needed * to be put in a separate function. */ void flush_ogg (CWP *cw) { #ifdef OGGV while (ogg_stream_flush(&os,&og)) { fwrite(og.header,1,og.header_len,cw->outfile); fwrite(og.body,1,og.body_len,cw->outfile); cw->outfile_length += og.header_len; cw->outfile_length += og.body_len; } #endif } /* * Add ms milliseconds of silence to the current file */ void add_silence (int ms, CWP *cw) { int i, pos; i = ms*cw->samplerate/1000.0; for (pos = 0; pos < i; pos++) { cw->inpcm[pos] = 0; } encode_buffer(i, cw); } /* readconfig calls this if * no config files were found in ~/.ebook2cw * but in DESTDIT/share/doc/ebook2cw. * They will then be compied to ~/.ebook2cw * * Return: Success NULL * Some failure -1 * * Moved from readfile to a separate function. */ int install_config_files (char *homedir, CWP *cw) { #if !__MINGW32__ int j = 0; char tmp[1024] = ""; printf("First run. Copying example configuration files to " "%s/.ebook2cw/\n\n", homedir); snprintf(tmp, 1024, "%s/.ebook2cw/", homedir); j = mkdir(tmp, 0777); if (j && (errno != EEXIST)) { printf("Failed to create %s. Resuming without config.",tmp); return -1; } /* ~/.ebook2cw/ created. Now copy ebook2cw.conf and map files */ snprintf(tmp, 1024, "install -m 644 "DESTDIR "/share/doc/ebook2cw/examples/ebook2cw.conf %s/.ebook2cw/", homedir); if (system(tmp)) { printf("Failed to create ~/.ebook2cw/ebook2cw.conf. " "Resuming without config."); return -1; } snprintf(tmp, 1024, "install -m 644 "DESTDIR "/share/doc/ebook2cw/examples/isomap.txt %s/.ebook2cw/", homedir); if (system(tmp)) { printf("Failed to create ~/.ebook2cw/isomap.txt. " "Resuming without config."); return -1; } snprintf(tmp, 1024, "install -m 644 "DESTDIR "/share/doc/ebook2cw/examples/utf8map.txt %s/.ebook2cw/", homedir); if (system(tmp)) { printf("Failed to create ~/.ebook2cw/utf8map.txt. " "Resuming without config."); return -1; } #endif return 0; } /* vim: noai:ts=4:sw=4 * */ ebook2cw-0.8.2/Makefile0000644000175000017500000000443612071564040014124 0ustar fabianfabian# ebook2cw Makefile -- Fabian Kurz, DJ1YFK -- http://fkurz.net/ham/ebook2cw.html # # $Id: Makefile 547 2012-12-29 21:07:53Z dj1yfk $ VERSION=0.8.2 DESTDIR ?= /usr # Set to NO to compile without Lame/Ogg-vorbis support USE_LAME?=YES USE_OGG?=YES CFLAGS:=$(CFLAGS) -D DESTDIR=\"$(DESTDIR)\" -D VERSION=\"$(VERSION)\" ifeq ($(USE_LAME), YES) CFLAGS:=$(CFLAGS) -D LAME LDFLAGS:=$(LDFLAGS) -lmp3lame endif ifeq ($(USE_OGG), YES) CFLAGS:=$(CFLAGS) -D OGGV LDFLAGS:=$(LDFLAGS) -lvorbis -lvorbisenc -logg endif all: ebook2cw ebook2cw: ebook2cw.c codetables.h gcc ebook2cw.c -pedantic -Wall -lm $(LDFLAGS) $(CFLAGS) -o ebook2cw cgi: ebook2cw.c codetables.h gcc -static ebook2cw.c $(LDFLAGS) -lm $(CFLAGS) -D CGI -o cw.cgi cgibuffered: ebook2cw.c codetables.h gcc -static ebook2cw.c $(LDFLAGS) -lm $(CFLAGS) -D CGI -D CGIBUFFERED -o cw.cgi static: gcc -static ebook2cw.c $(LDFLAGS) -lm $(CFLAGS) -o ebook2cw install: install -d -v $(DESTDIR)/share/man/man1/ install -d -v $(DESTDIR)/bin/ install -d -v $(DESTDIR)/share/doc/ebook2cw/ install -d -v $(DESTDIR)/share/doc/ebook2cw/examples/ install -s -m 0755 ebook2cw $(DESTDIR)/bin/ install -m 0644 ebook2cw.1 $(DESTDIR)/share/man/man1/ install -m 0644 README $(DESTDIR)/share/doc/ebook2cw/ install -m 0644 ebook2cw.conf $(DESTDIR)/share/doc/ebook2cw/examples/ install -m 0644 isomap.txt $(DESTDIR)/share/doc/ebook2cw/examples/ install -m 0644 utf8map.txt $(DESTDIR)/share/doc/ebook2cw/examples/ uninstall: rm -f $(DESTDIR)/bin/ebook2cw rm -f $(DESTDIR)/share/man/man1/ebook2cw.1 rm -rf $(DESTDIR)/share/doc/ebook2cw clean: rm -f ebook2cw *~ *.mp3 *.ogg *.cgi dist: sed 's/v[0-9].[0-9].[0-9]/v$(VERSION)/g' README > README2 rm -f README mv README2 README rm -f releases/ebook2cw-$(VERSION).tar.gz rm -rf releases/ebook2cw-$(VERSION) mkdir ebook2cw-$(VERSION) cp ebook2cw.c codetables.h ChangeLog ebook2cw.1 \ ebook2cw.conf isomap.txt utf8map.txt \ ebook2cw.bat \ README COPYING Makefile ebook2cw-$(VERSION) tar -zcf ebook2cw-$(VERSION).tar.gz ebook2cw-$(VERSION) mv ebook2cw-$(VERSION) releases/ mv ebook2cw-$(VERSION).tar.gz releases/ md5sum releases/*.gz > releases/md5sums.txt chmod a+r releases/* ebook2cw-0.8.2/ebook2cw.10000644000175000017500000001112012071564040014245 0ustar fabianfabian.TH ebook2cw 1 "DECEMBER 2012" Linux "User Manuals" .SH NAME ebook2cw \- Convert ebooks to Morse code audio files (MP3/OGG) .SH SYNOPSIS .B ebook2cw [OPTIONS] [INFILE] .SH DESCRIPTION .B ebook2cw ebook2cw is a command line program which converts a plain text ebook to Morse code audio files. It works on several platforms, including Windows and Linux. A number of CW and audio parameters can be changed from their default values, by command line switches or a config file (see below). These are (default values in brackets): .B -w wpm - CW speed in words per minute [25] .B -e wpm - Effective CW speed. If set, the spaces are sent at this speed instead of the character speed set by -w ("Farnsworth"). .B -W x - Extra Word spacing. Similar to -e, but only affects the inter-word spacing, not the inter-character spacing. .B -f freq - audio frequency in Hz [600] .B -T SINE|0|SAWTOOTH|1|SQUARE|2 - set waveform to sine, sawtooth, squarewave. [sine] .B -Q minutes - Increase CW speed (QRQ) by 1 WpM in intervals of `minutes'. Speed will be reset to the initial value at the start of each chapter. [0] .B -n - Disables resetting the speed when using the -Q option. .B -p - Disables the paragraph separator () .B -R risetime - risetime, in samples [50] .B -F falltime - falltime, samples [50] .B -O - Use OGG/Vorbis encoder instead of MP3 if compiled with OGG support .B -X - Do not encode, do not generate output files .B -s samplerate - samplerate for the OGG/MP3 file [11025] .B -b bitrate - MP3 bitrate, kbps [16] .B -q quality - MP3 quality, 1 (best) to 9 (worst). CW still sounds very good with the worst quality, encoding time is greatly reduced. [5] .B -c chapter separator - Split chapters at this string. [CHAPTER] .B -d duration - Splits output files after "duration" seconds; finishes the current sentence. .B -l wordlimit - Splits output files after "wordlimit" words; finished the current sentence. .B -o outfile-name - Output filename (chapter number and .mp3/.ogg will be appended) [Chapter] .B -a author - Author for the ID3 tag. Use quotes for strings with spaces (e.g. "JW Goethe") .B -t title - Title for the ID3 tag. Use quotes for strings with spaces (e.g. "Faust II") .B -k comment - Comment for the ID3 tag. Use quotes for strings with spaces. .B -y year - Year for the ID3 tag. .B -u - Switches input encoding format to UTF-8. Currently supported alphabets include Latin, Greek, Hebrew, Arabic and Cyrillic. Default is ISO 8859-1. .B -g file - Guesses the encoding of `file` (ISO 8859-1 / ASCII or UTF-8). .B -S [ISO|UTF] - Shows a table of all available morse symbols for the ISO 8859-1 and UTF-8 character sets. Output in HTML format. .B -N snr - When this option is used, a noise background is added to the file and the CW signal is scaled down to achieve a SNR (Signal to Noise ratio) of "snr" dB. Possible range of SNR: -10db to 10dB. Make sure to enclose the value in quotation marks if it's negative (i.e. -N "-3"). .B -B bandwidth in Hz - Sets the filter bandwidth if the -N / SNR option is used. Available filters are 100Hz, 500Hz, 1kHz and 2.1kHz. .B -C frequency in Hz - Sets the center frequency of the filter if the -N / SNR option is used. This should be set to the frequency of the Morse signal; currently implemented center frequencies: 800Hz .SH TEXT COMMANDS CW prosigns can be generated by enclosing arbitrary letters in angle brackets (e.g. , , ...). The tone frequency (f), speed (w), effective speed (e), volume (v, 1..100) waveform (T) and SNR (N) can be changed arbitrarily within the text by inserting commands, starting with a pipe symbol, followed by the parameter to change and the value. Example: |f400 changes the tone frequency to 400Hz, |w60 changes the speed to 60wpm, |T3 changes the waveform to squarewave. .SH CONFIG FILE AND CHARACTER MAPPINGS ebook2cw looks for a config file, ebook2cw.conf, in which all settings that can be changed by command line parameters can be set. Any settings made in the config file can be overridden by command line arguments. Additionally, two `map` files can be set in the config file, for ISO8859-1 and UTF-8. You can map characters in those files to a string, which may be useful to replace characters like the exclamation mark (!) to a period (.), which is more common in CW. A set of example config and map file and a description thereof can be found at DESTDIR/share/doc/ebook2cw/examples/. .SH MISC ebook2cw can also be compiled to run as a CGI to serve MP3 and OGG files on the fly for web applications. .SH AUTHOR Fabian Kurz, DJ1YFK http://fkurz.net/ham/ebook2cw.html .SH "SEE ALSO" .BR morse (1) ebook2cw-0.8.2/README0000644000175000017500000000332612071564040013341 0ustar fabianfabianebook2cw v0.8.2 - convert ebooks to morse code - Fabian Kurz, DJ1YFK --------------------------------------------------------------------- $Id: README 557 2013-01-03 10:41:23Z dj1yfk $ Website: http://fkurz.net/ham/ebook2cw.html ebook2cw is a command line program which converts a plain text ebook to morse code MP3 or OGG files. It works on several platforms, including Windows and Linux. It automatically splits and numbers the output files by chapters. For a detailled description, please refer to the man-page or the project website. INSTALL -------- 1) Binaries Statically compiled binaries are available at the project website, for Linux (i386) and Win32. Those should be suitable for most users. 2) Source A Makefile is included; it compiles both under Linux and Windows (with MinGW). DESTDIR is /usr by default (so the binary will be in /usr/bin/). Support for LAME and/or OGG can be disabled by USE_LAME=NO and USE_OGG=NO respectively. make [DESTDIR=..] [USE_OGG=NO] [USE_LAME=NO] make install CGI --- ebook2cw can also be compiled as a CGI, with "make cgi" or "make cgibuffered". The executable can then be used on a webserver and called in the format http://example.com/cgi-bin/cw.cgi?s=25&e=25&f=600&t=%20hello%20world which returns a MP3 file with "hello world" at the given speed etc. The order of the GET parameters must be used as shown above. Real-world examples of ebook2cw as a CGI can be found at http://lcwo.net/. The default cgi version operates "on the fly", the "cgibuffered" option first writes the whole MP3/OGG to a temporary file, so it can send a proper Content-Length: header which may be used with some clients. Contact ------- Fabian Kurz, DJ1YFK http://fkurz.net/ham/ebook2cw.html ebook2cw-0.8.2/codetables.h0000644000175000017500000004444512071564040014746 0ustar fabianfabian/* * ISO 8859-1 and UTF-8 to Morse code mappings * This file is part of ebook2cw and may be used under the same terms (GPL) * (C) 2008 Fabian Kurz, DJ1YFK * * $Id: codetables.h 209 2011-04-13 18:10:59Z dj1yfk $ * * Currently included: ISO 8859-1 * - complete (all that can somehow be mapped) * Unicode: * - Latin (basic, some extended) * - Cyrillic alphabet (KOI-7 + Serbian, Macedonian.. ) * - Greek * - Hebrew * * Any comments, additions or corrections are welcome: mail@fkurz.net * */ const static char *iso8859[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, " ", /* space */ "..--.", /* ! */ ".-..-.", /* " */ NULL, /* # */ "...-..-", /* $ */ NULL, /* % */ ". ...", /* & */ ".----.", /* ' */ "-.--.", /* ( */ "-.--.-", /* ) */ NULL, /* * */ ".-.-.", /* + */ "--..--", /* , */ "-....-", /* - */ ".-.-.-", /* . */ "-..-.", /* / */ "-----", /* 0 */ ".----", /* 1 */ "..---", /* 2 */ "...--", /* 3 */ "....-", /* 4 */ ".....", /* 5 */ "-....", /* 6 */ "--...", /* 7 */ "---..", /* 8 */ "----.", /* 9 */ "---...", /* : */ "-.-.-.", /* ; */ NULL, /* < */ "-...-", /* = */ NULL, /* < */ "..--..", /* ? */ ".--.-.", /* @ */ ".-", /* A */ "-...", /* B */ "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", /* Z */ NULL, /* [ */ "-..-.", /* \ */ NULL, /* ] */ NULL, /* ^ */ NULL, /* _ */ ".----.", /* ` */ ".-", /* a */ "-...", /* b */ "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", /* z */ NULL, /* { */ NULL, /* | */ NULL, /* } */ NULL, /* ~ */ NULL, /* DEL */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ".-..-.", /* « (angle quotes, <<, 171) */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ".-..-.", /* » (angle quotes, >>, 187) */ NULL, NULL, NULL, NULL, ".--.-", /* `A */ ".--.-", /* 'A */ ".-", /* ^A */ ".-", /* ~A */ ".-.-", /* "A */ ".--.-", /* °A */ ".- .", /* AE */ "-.-..", /* ,C */ "..-..", /* `E */ "..-..", /* 'E */ ".", /* ^E */ ".", /* "E */ "..", /* `I */ "..", /* 'I */ "..", /* ^I */ "..", /* "I */ "..--.", /* -D */ "--.--", /* ~N */ "---", /* `O */ "---", /* 'O */ "---", /* ^O */ "---", /* ~O */ "---.", /* "O */ NULL, /* x */ "---.", /* /O */ "..-", /* `U */ "..-", /* 'U */ "..-", /* ^U */ "..--", /* "U */ "-.--", /* 'Y */ ".--..", /* 'thorn' */ "...--..", /* sz */ ".--.-", /* `a */ ".--.-", /* 'a */ ".-", /* ^a */ ".-", /* ~a */ ".-.-", /* "a */ ".--.-", /* °a */ ".- .", /* ae */ "-.-..", /* ,c */ "..-..", /* `e */ "..-..", /* 'e */ ".", /* ^e */ ".", /* "e */ "..", /* `i */ "..", /* 'i */ "..", /* ^i */ "..", /* "i */ "..--.", /* -d */ "--.--", /* ~n */ "---", /* `o */ "---", /* 'o */ "---", /* ^o */ "---", /* ~o */ "---.", /* "o */ NULL, /* ./. */ "---.", /* /o */ "..-", /* `u */ "..-", /* 'u */ "..-", /* ^u */ "..--", /* "u */ "-.--", /* 'y */ ".--..", /* 'thorn' */ "-.--" /* "y */ }; const static char *utf8table[] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* first 128 are identical*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* to iso8859, so that */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* will be used instead */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* - 127 */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* control characters ...*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* -159 */ " ", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ".-..-.", NULL, NULL, NULL, NULL, /* 171 << */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ".-..-.", NULL, NULL, NULL, NULL, /* 187 >> */ /* same as in ISO8859 */ ".--.-", /* `A */ /* 192 ... */ ".--.-", /* 'A */ ".-", /* ^A */ ".-", /* ~A */ ".-.-", /* "A */ ".--.-", /* °A */ ".- .", /* AE */ "-.-..", /* ,C */ "..-..", /* `E */ "..-..", /* 'E */ ".", /* ^E */ ".", /* "E */ "..", /* `I */ "..", /* 'I */ "..", /* ^I */ "..", /* "I */ "..--.", /* -D according to Wikipedia */ "--.--", /* ~N */ "---", /* `O */ "---", /* 'O */ "---", /* ^O */ "---", /* ~O */ "---.", /* "O */ NULL, /* x */ "---.", /* /O */ "..-", /* `U */ "..-", /* 'U */ "..-", /* ^U */ "..--", /* "U */ "-.--", /* 'Y */ ".--..", /* 'thorn', acc to Wikipedia */ "...--..", /* sz */ ".--.-", /* `a */ ".--.-", /* 'a */ ".-", /* ^a */ ".-", /* ~a */ ".-.-", /* "a */ ".--.-", /* °a */ ".- .", /* ae */ "-.-..", /* ,c */ "..-..", /* `e */ "..-..", /* 'e */ ".", /* ^e */ ".", /* "e */ "..", /* `i */ "..", /* 'i */ "..", /* ^i */ "..", /* "i */ "..--.", /* -d Wiki */ "--.--", /* ~n */ "---", /* `o */ "---", /* 'o */ "---", /* ^o */ "---", /* ~o */ "---.", /* "o */ NULL, /* ./. */ "---.", /* /o */ "..-", /* `u */ "..-", /* 'u */ "..-", /* ^u */ "..--", /* "u */ "-.--", /* 'y */ ".--..", /* 'thorn' */ "-.--", /* "y */ /* 255 */ ".-", ".-", ".-", ".-", ".-", ".-", /* 256-261, As with different hats */ /* 262-269 Cs with different hats */ /* 264-265 -.-.. acc. to Wikipedia, Esperanto etc. */ "-.-.", "-.-.", "-.-..", "-.-..", "-.-.", "-.-.", "-.-.", "-.-.", "-..", "-..", "-..", "-..", /* 270-273 Ds with different stuff */ /* 274-283 different Es */ ".", ".", ".", ".", ".", ".", ".", ".", ".", ".", /* 284-291 different Gs, first 2 according to Wikipedia (Esperanto) */ "--.-.", "--.-.", "--.", "--.", "--.", "--.", "--.", "--.", /* 292-295 different Hs, first two Esperanto (was: -.--. before, but was * changed: "Originale, Hx estis -.--. sed tio kolizie estas "(" en ITU-T * F.1, do Hx nun prefere estas ----") */ "----", "----", "....", "....", /* 296-305 different Is */ "..", "..", "..", "..", "..", "..", "..", "..", "..", "..", /* 306-307 IJ ligatures */ ".. .---", ".. .---", /* 308-309 Js, from Wikipedia, Esperanto */ ".---.", ".---.", /* 310-312 Ks */ "-.-", "-.-", "-.-", /* 313-322 different Ls */ ".-..", ".-..", ".-..", ".-..", ".-..", ".-..", ".-..", ".-..", ".-..", ".-..", /* 323-331 different Ns */ "-.", "-.", "-.", "-.", "-.", "-.", "-.", "-.", "-.", /* 332-337 Os */ "---", "---", "---", "---", "---", "---", /* 338-339 OEs */ "---.", "---.", /* 340-345 Rs */ ".-.", ".-.", ".-.", ".-.", ".-.", ".-.", /* 346-353 Ss, Wikipedia */ "...", "...", "...-.", "...-.", "...", "...", "...", "...", /* 354-359 Ts */ "-", "-", "-", "-", "-", "-", /* 360-371 Us, 364. 365 Esperanto */ "..-", "..-", "..-", "..-", "..--", "..--", "..-", "..-", "..-", "..-", "..-", "..-", /* 372-373 Ws */ ".--", ".--", /* 374-377 Ys */ "-.--", "-.--", "-.--", /* 377-382 Zs */ "--..", "--..", "--..", "--..", "--..", "--..", /* 383 S */ "...", /* 384-389 Bs */ "-...", "-...", "-...", "-...", "-...", "-...", NULL, NULL, NULL, /* all kind of weird stuff */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* Standard Greek Alphabet */ ".-", "-..." , "--.", "-..", ".", "--..", "....", "-.-.", "..", "-.-", ".-..", "--", "-.", "-..-", "---", ".--.", ".-.", NULL, "...", "-", "-.--", "..-.", "----", "--.-", ".--", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 1023 */ /* 1024-1039, cyrillic (Serbian, Macedonian, Ukrainian) UC */ ".", ".", "-.. .---", "--. .---", ".", "-.. --..", "..", "..", ".---", ".-.. .---", "-. .---", "-.-.", "-.- .---", "..", "..-","-.. --..", /* 32 letters of Russian Cyrillic alphabet */ ".-", "-...", ".--", "--.", "-..", ".", "...-", /* 1040-1071 */ "--..", "..",".---", "-.-", ".-..", "--", "-.", /* uppercase */ "---", ".--.", ".-.", "...", "-", "..-", "..-.", /* cyrillic */ "....", "-.-.", "---.", "----", "--.-", "-..-", "-.--", "-..-", "..-..", "..--", ".-.-", ".-", "-...", ".--", "--.", "-..", ".", "...-", /* 1072-1103 */ "--..", "..",".---", "-.-", ".-..", "--", "-.", /* lowercase */ "---", ".--.", ".-.", "...", "-", "..-", "..-.", /* cyrillic */ "....", "-.-.", "---.", "----", "--.-", "-..-", "-.--", "-..-", "..-..", "..--", ".-.-", /* 1004-1119, cyrillic (Serbian, Macedonian, Ukrainian) UC */ ".", ".", "-.. .---", "--. .---", ".", "-.. --..", "..", "..", ".---", ".-.. .---", "-. .---", "-.-.", "-.- .---", "..", "..-","-.. --..", /* 1120 - 1487 to be done... */ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* 1488-1514 Hebrew according to Wikipedia */ ".-", "-...", "--.", "-..", "---", ".", "--..", "....", "..-", "..", NULL, "-.-", ".-..", NULL, "--", "-.", NULL, "-.-.", ".---", NULL, ".--.", NULL, ".--", "--.-", ".-.", "...", "-", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* Arabic Alphabet, as per Wikipedia. * Nobody is possibly ever going to use this :-) * 1569-1610 */ ".", NULL, NULL, NULL, NULL, NULL, ".-", "-...", NULL, "-", "-.-.", ".---", "....", "---", "-..", "--..", ".-.", "---.", "...", "----", "-..-", "...-", "..-", "-.--", ".-.-", "--.", NULL, NULL, NULL, NULL, NULL, NULL, "..-.", "--.-", "-.-", ".-..", "--", "-.", NULL, ".--", NULL, "..", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL /* 1920 */ }; ebook2cw-0.8.2/ebook2cw.conf0000644000175000017500000000273012071564040015041 0ustar fabianfabian# ebook2cw configuration file # # ebook2cw (c) 2008 by Fabian Kurz, DJ1YFK # http://fkurz.net/ham/ebook2cw.html # # $Id: ebook2cw.conf 214 2011-05-01 13:50:04Z dj1yfk $ # # In this file you can set the default parameters which ebook2cw # uses. These parameters can be overridden by command line parameters. # # If a parameter is neither specified in this file nor on the command # line, the 'factory default' is used. # # For all available parameters, consult the website or the man page; # they are the same as the command line parameters, and the format to # use in this file is: "x=y", one parameter per line, no spaces between # = and the values. # The parameters which don't require a value on the command line must # be set to 1 here (e.g. "u=1" instead of just "u"). [settings] w=25 f=700 # ebook2cw by default supports almost all known special characters in CW, # like umlauts, accented letters, etc. Complete tables are available at # http://fkurz.net/ham/codes.html (UTF-8) and # http://fkurz.net/ham/codes2.html (ISO 8859-1) # # Many of these symbols are pretty unusual though, like the exclamation # mark (! = ..--.) and you may prefer to replace them with a different # letter before generating CW. # # Below you can set arbitrary mappings between characters. The format of each # line is: "character to be replaced"="replacement". [mappings] # remove the "#" to activate the mapfiles #isomapfile=isomap.txt #utf8mapfile=utf8map.txt ebook2cw-0.8.2/COPYING0000644000175000017500000003542712071564040013523 0ustar fabianfabian GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS ebook2cw-0.8.2/ChangeLog0000644000175000017500000000721512071564040014234 0ustar fabianfabian0.8.2 / 2013-01-04 Fabian Kurz * Time of conversion and speed-up calculations * Fixed text command |T0 * Samplerate of output file now always according to -s parameter (no longer using LAME's own preference for the given bitrate) * New text command |v for volume control * Chapter splitting now possible by duration (-d seconds) and number of words (-l words) (suggested by DM3KPO) * Fix inconsistent numbers for waveforms (0 = sine, 1 = sawtooth, 2 = square) * Fix OGG/Vorbis headers in CGI mode * New CGI mode (make cgibuffered) where the whole sound file is first created temporarily and then sent to the client. This makes it possible to send the Content-Length header. * Code cleanup 0.8.1 / 2011-04-04 Fabian Kurz * Guessing of file encoding added (-g filename). * MP3 CGI fixed (crashed because OGG/Vorbis libs were called) * Chapter time now properly resetted after each chapter * Added -X switch (test mode: no encoder, no output files) * Lame or OGG support can be disabled in the Makefile 0.8.0 / 2011-01-25 Fabian Kurz * ebook2cw can now also be compiled to work as a CGI on a webserver * Support for OGG/Vorbis audio file format added * Time of created files is now calculated accurately * Option to add a noise floor with an user definable SNR added [-N] (very experimental) * Waveform can now be set to sine, sawtooth or squarewave. [-T] * Config files are searched in current directory, ~/.ebook2cw, and DESTDIR/share/doc/ebook2cw/examples now. ~/.ebook2cw is created if only the last is found. [Linux/Unix only] 0.7.0 / 2008-07-03 Fabian Kurz * Paragraph separator () can be disabled by -p command line switch (suggested by DJ3KU). * All command line parameters can now also be set in the config file ebook2cw.conf. * Arbitrary character mappings are now possible. 0.6.4 / 2008-05-20 Fabian Kurz * Added "Farnsworth" spacing (-e) and extra inter-word spacing (-W) [suggested by DL3OBQ] * Reset to original speed when using QRQ (-Q) at each new chapter can now be disabled (-n) [suggested by W2UP] 0.6.3 / 2008-03-10 Fabian Kurz * Added the Arabic morse code alphabet * Added/changed Unicode characters for Esperanto 0.6.2 / 2008-02-20 Fabian Kurz * Support for arbitrary prosigns added. To generate a prosign enclose the letters in angle brackets (e.g. , , ...). [tnx DL7YEC] 0.6.1 / 2008-02-09 Fabian Kurz * Added more Cyrillic characters, the Greek and the Hebrew alphabet to the Unicode table. Some small corrections to the existing characters. * Command line switch -S with option either ISO or UTF prints a table of the available character set and the CW symbols in HTML format. 0.6.0 / 2008-02-05 Fabian Kurz * Full ISO 8859-1 character set is now available * UTF-8 support by command line switch -u. Currently implemented: Latin, basic cyrillic. 0.5.1 / 2008-01-08 Fabian Kurz * Fixed ID3 title (chapter number) generation. 0.5.0 / 2007-12-19 Fabian Kurz * Added support for writing ID3 tags. * Added -Q command line switch: QRQ by 1 WpM every n minutes. 0.4.0 / 2007-12-17 Fabian Kurz * Implemented dynamic memory allocation. 0.3.0 / 2007-11-28 Fabian Kurz * Added forgotten characters: @ and /. 0.2.0 / 2007-11-27 Fabian Kurz * Fixed handling of umlauts * The chapter separator is now case sensitive. 0.1.0 / 2007-11-22 Fabian Kurz * Initial release of ebook2cw. ebook2cw-0.8.2/ebook2cw.bat0000644000175000017500000000150012071564040014654 0ustar fabianfabian@echo off echo ebook2cw - Batch file for Windows (obsolete; replaced by ebook2cwgui) echo - echo Usage: You will be promted for a filename and (at your option) echo additional parameters for ebook2cw (such as wpm, tone freq etc). echo - echo If a config file (ebook2cw.conf) was found in the current directory, echo the settings in this file are used, but any settings you specify echo here will override those. echo - echo - echo Enter the name of the text file to convert to CW. Note that you can echo simply drag and drop a file from the Windows Explorer to this window. echo - set /p file="Text file: " echo - echo Enter any additional command line parameters for ebook2cw, or leave echo just press enter to use the values from ebook2cw.conf. echo - set /p par="Parameters: " echo - ebook2cw.exe %par% %file% echo Done. pause ebook2cw-0.8.2/utf8map.txt0000644000175000017500000000040012071564040014574 0ustar fabianfabian# UTF-8 mapping example for ebook2cw.. # # The format of each line is: # x=yyy # # where x is the character to be mapped to the string yyy # # x is a single character, yyy is a string of up to 3 characters. ä=ae ü=ue ö=oe Ä=ae Ü=ue Ö=oe ß=sz