76 #define normalize_to_16bit(n) if (n > SMAX) n = SMAX; else if (n < SMIN) n = SMIN; 79 #pragma warning(disable:4706) 83 0x00c9, 0x025b, 0x03ed, 0x057f, 0x0711, 0x08a2, 0x0a33, 0x0bc4,
84 0x0d54, 0x0ee4, 0x1073, 0x1201, 0x138f, 0x151c, 0x16a8, 0x1833,
85 0x19be, 0x1b47, 0x1cd0, 0x1e57, 0x1fdd, 0x2162, 0x22e5, 0x2467,
86 0x25e8, 0x2768, 0x28e5, 0x2a62, 0x2bdc, 0x2d55, 0x2ecc, 0x3042,
87 0x31b5, 0x3327, 0x3497, 0x3604, 0x3770, 0x38d9, 0x3a40, 0x3ba5,
88 0x3d08, 0x3e68, 0x3fc6, 0x4121, 0x427a, 0x43d1, 0x4524, 0x4675,
89 0x47c4, 0x490f, 0x4a58, 0x4b9e, 0x4ce1, 0x4e21, 0x4f5e, 0x5098,
90 0x51cf, 0x5303, 0x5433, 0x5560, 0x568a, 0x57b1, 0x58d4, 0x59f4,
91 0x5b10, 0x5c29, 0x5d3e, 0x5e50, 0x5f5e, 0x6068, 0x616f, 0x6272,
92 0x6371, 0x646c, 0x6564, 0x6657, 0x6747, 0x6832, 0x691a, 0x69fd,
93 0x6add, 0x6bb8, 0x6c8f, 0x6d62, 0x6e31, 0x6efb, 0x6fc2, 0x7083,
94 0x7141, 0x71fa, 0x72af, 0x735f, 0x740b, 0x74b3, 0x7556, 0x75f4,
95 0x768e, 0x7723, 0x77b4, 0x7840, 0x78c8, 0x794a, 0x79c9, 0x7a42,
96 0x7ab7, 0x7b27, 0x7b92, 0x7bf9, 0x7c5a, 0x7cb7, 0x7d0f, 0x7d63,
97 0x7db1, 0x7dfb, 0x7e3f, 0x7e7f, 0x7eba, 0x7ef0, 0x7f22, 0x7f4e,
98 0x7f75, 0x7f98, 0x7fb5, 0x7fce, 0x7fe2, 0x7ff1, 0x7ffa, 0x7fff
136 memset(ts, 0,
sizeof(*ts));
224 if (map->
freqs[0] > 0) {
225 for (freqlen = 0; freqlen < TELETONE_MAX_TONES && map->
freqs[freqlen]; freqlen++) {
243 for (j = 0; j < TELETONE_MAX_TONES && map->
freqs[j]; j++) {
252 for (i = 0; i < freqlen; i++) {
274 if (map->
freqs[0] <= 0) {
275 fprintf(ts->
debug_stream,
"wait %d (%dms)\n", wait, wait / (ts->
rate / 1000));
279 for (i = 0; i < TELETONE_MAX_TONES && map->
freqs[i]; i++) {
284 ") [volume %0.2fdB; samples %d(%dms) x %d channel%s; wait %d(%dms); decay_factor %0.2fdB; decay_step %d(%dms); wrote %d bytes]\n",
287 duration / (ts->
rate / 1000),
291 wait / (ts->
rate / 1000),
304 size_t len = strlen (s) + 1;
305 void *
new = malloc (len);
311 return (
char *) memcpy (
new, s, len);
316 char *data = NULL, *
cur = NULL, *end = NULL;
331 if (*cur ==
' ' || *cur ==
'\r' || *cur ==
'\n') {
336 if ((end = strchr(cur,
';')) != 0) {
340 if (*(cur + 1) ==
'=') {
346 ts->
rate = atoi(cur + 2);
353 float vol = (float)atof(cur + 2);
371 ts->
wait = atoi(cur + 2) * (ts->
rate / 1000);
374 ts->
loops = atoi(cur + 2);
379 if ((L = atoi(cur + 2)) > 0) {
388 char *p = NULL, *e = NULL;
391 if (*cur ==
' ' || *cur ==
'\r' || *cur ==
'\n') {
399 memset(&mymap, 0,
sizeof(mymap));
401 if (*(cur + 1) ==
'(') {
406 if ((e = strchr(p,
')')) != 0) {
410 #if (_MSC_VER == 1600) 415 if ((next = strchr(p,
',')) != 0) {
425 mymap.
freqs[i++ - 2] = atof(p);
430 if (i > 2 && *cur ==
'%') {
432 }
else if ((i != 2 || *cur ==
'%')) {
443 mapp = &ts->
TONES[(int)*cur];
445 fprintf(ts->
debug_stream,
"Map [%c] Out Of Range!\n", *cur);
450 if (mapp->
freqs[0]) {
460 fprintf(ts->
debug_stream,
"Ignoring Empty Map [%c]!\n", *cur);
#define TELETONE_API_DATA
static __inline__ int16_t teletone_dds_state_modulate_sample(teletone_dds_state_t *dds, uint32_t pindex)
#define TELETONE_MAX_TONES
An abstraction to store a tone mapping.
static char * my_strdup(const char *s)
teletone_audio_t * buffer
double teletone_process_t
int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *map)
Execute a single tone generation instruction.
int teletone_destroy_session(teletone_generation_session_t *ts)
Free the buffer allocated by a tone generation session.
static __inline__ int teletone_dds_state_set_tone(teletone_dds_state_t *dds, teletone_process_t tone, uint32_t rate, uint32_t pindex)
#define TELETONE_API(type)
teletone_tone_map_t TONES[TELETONE_TONE_RANGE]
int teletone_run(teletone_generation_session_t *ts, const char *cmd)
Execute a tone generation script and call callbacks after each instruction.
#define TELETONE_VOL_DB_MIN
int teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_handler handler, void *user_data)
Initilize a tone generation session.
static __inline__ void teletone_dds_state_set_tx_level(teletone_dds_state_t *dds, float tx_level)
teletone_process_t freqs[TELETONE_MAX_TONES]
int teletone_set_tone(teletone_generation_session_t *ts, int index,...)
Assign a set of tones to a tone_session indexed by a paticular index/character.
static int ensure_buffer(teletone_generation_session_t *ts, int need)
switch_byte_t switch_byte_t uint32_t buflen
int(* tone_handler)(struct teletone_generation_session *ts, teletone_tone_map_t *map)
#define TELETONE_TONE_RANGE
An abstraction to store a tone generation session.
int teletone_set_map(teletone_tone_map_t *map,...)
Assign a set of tones to a single tone map.
int16_t TELETONE_SINES[SINE_TABLE_MAX]