2004-03-14 21:33:53 +00:00
|
|
|
|
/***************************************************************************
|
|
|
|
|
* __________ __ ___.
|
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2004 J<EFBFBD>rg Hohensohn
|
|
|
|
|
*
|
|
|
|
|
* This module collects the Talkbox and voice UI functions.
|
|
|
|
|
* (Talkbox reads directory names from mp3 clips called thumbnails,
|
|
|
|
|
* the voice UI lets menus and screens "talk" from a voicefont in memory.
|
|
|
|
|
*
|
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
|
*
|
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
|
* KIND, either express or implied.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef __TALK_H__
|
|
|
|
|
#define __TALK_H__
|
|
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
2007-10-07 08:12:01 +00:00
|
|
|
|
#include "time.h"
|
2004-03-14 21:33:53 +00:00
|
|
|
|
|
2004-03-19 22:15:53 +00:00
|
|
|
|
enum {
|
2006-09-26 17:44:43 +00:00
|
|
|
|
/* See array "unit_voiced" in talk.c function "talk_value" */
|
2004-03-19 22:15:53 +00:00
|
|
|
|
UNIT_INT = 1, /* plain number */
|
|
|
|
|
UNIT_SIGNED, /* number with mandatory sign (even if positive) */
|
|
|
|
|
UNIT_MS, /* milliseconds */
|
|
|
|
|
UNIT_SEC, /* seconds */
|
|
|
|
|
UNIT_MIN, /* minutes */
|
|
|
|
|
UNIT_HOUR, /* hours */
|
|
|
|
|
UNIT_KHZ, /* kHz */
|
|
|
|
|
UNIT_DB, /* dB, mandatory sign */
|
|
|
|
|
UNIT_PERCENT, /* % */
|
2004-03-20 16:49:58 +00:00
|
|
|
|
UNIT_MAH, /* milliAmp hours */
|
|
|
|
|
UNIT_PIXEL, /* pixels */
|
|
|
|
|
UNIT_PER_SEC, /* per second */
|
|
|
|
|
UNIT_HERTZ, /* hertz */
|
2006-07-22 17:23:05 +00:00
|
|
|
|
UNIT_MB, /* Megabytes */
|
2006-08-28 22:38:41 +00:00
|
|
|
|
UNIT_KBIT, /* kilobits per sec */
|
2007-08-18 23:03:03 +00:00
|
|
|
|
UNIT_PM_TICK, /* peak meter units per tick */
|
2004-03-19 22:15:53 +00:00
|
|
|
|
UNIT_LAST /* END MARKER */
|
|
|
|
|
};
|
|
|
|
|
|
2006-09-26 17:44:43 +00:00
|
|
|
|
#define UNIT_SHIFT (32-5) /* this many bits left from UNIT_xx enum */
|
2004-03-19 22:15:53 +00:00
|
|
|
|
|
|
|
|
|
/* make a "talkable" ID from number + unit
|
|
|
|
|
unit is upper 4 bits, number the remaining (in regular 2's complement) */
|
2005-02-12 11:26:36 +00:00
|
|
|
|
#define TALK_ID(n,u) (((long)(u))<<UNIT_SHIFT | ((n) & ~(-1L<<UNIT_SHIFT)))
|
2004-03-19 22:15:53 +00:00
|
|
|
|
|
2004-07-23 23:01:20 +00:00
|
|
|
|
/* convenience macro to have both virtual pointer and ID as arguments */
|
|
|
|
|
#define STR(id) ID2P(id), id
|
2004-03-19 22:15:53 +00:00
|
|
|
|
|
2004-10-21 18:34:48 +00:00
|
|
|
|
/* publish these strings, so they're stored only once (better than #define) */
|
2004-10-06 21:37:46 +00:00
|
|
|
|
extern const char* const dir_thumbnail_name; /* "_dirname.talk" */
|
2004-10-21 18:34:48 +00:00
|
|
|
|
extern const char* const file_thumbnail_ext; /* ".talk" for file voicing */
|
2004-03-19 22:15:53 +00:00
|
|
|
|
|
2004-03-14 21:33:53 +00:00
|
|
|
|
void talk_init(void);
|
2006-12-25 14:01:47 +00:00
|
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2006-08-15 18:01:42 +00:00
|
|
|
|
bool talk_voice_required(void); /* returns true if voice codec required */
|
2006-12-25 14:01:47 +00:00
|
|
|
|
#endif
|
2005-08-20 11:13:19 +00:00
|
|
|
|
int talk_get_bufsize(void); /* get the loaded voice file size */
|
2006-11-28 15:00:56 +00:00
|
|
|
|
/* talk_buffer_steal - on SWCODEC, for use by buffer functions only */
|
2004-03-14 21:33:53 +00:00
|
|
|
|
int talk_buffer_steal(void); /* claim the mp3 buffer e.g. for play/record */
|
2007-08-06 13:08:36 +00:00
|
|
|
|
bool is_voice_queued(void); /* Are there more voice clips to be spoken? */
|
2005-02-12 11:26:36 +00:00
|
|
|
|
int talk_id(long id, bool enqueue); /* play a voice ID from voicefont */
|
2004-08-18 01:09:31 +00:00
|
|
|
|
int talk_file(const char* filename, bool enqueue); /* play a thumbnail from file */
|
2005-02-12 11:26:36 +00:00
|
|
|
|
int talk_number(long n, bool enqueue); /* say a number */
|
|
|
|
|
int talk_value(long n, int unit, bool enqueue); /* say a numeric value */
|
2004-08-18 01:09:31 +00:00
|
|
|
|
int talk_spell(const char* spell, bool enqueue); /* spell a string */
|
2007-06-11 08:28:38 +00:00
|
|
|
|
bool talk_menus_enabled(void); /* returns true if menus should be voiced */
|
2007-06-11 08:34:42 +00:00
|
|
|
|
void talk_disable_menus(void); /* disable voice menus (temporarily, not persisted) */
|
|
|
|
|
void talk_enable_menus(void); /* re-enable voice menus */
|
2007-08-29 15:11:19 +00:00
|
|
|
|
int do_shutup(void); /* kill voice unconditionally */
|
2007-10-10 03:12:17 +00:00
|
|
|
|
int shutup(void); /* Interrupt voice, as when enqueue is false */
|
2007-08-06 15:01:45 +00:00
|
|
|
|
|
2007-10-07 08:12:01 +00:00
|
|
|
|
#if CONFIG_RTC
|
|
|
|
|
/* this is in talk.c which isnt compiled for hwcodec simulator */
|
|
|
|
|
#if !defined(SIMULATOR) || CONFIG_CODEC == SWCODEC
|
|
|
|
|
void talk_date_time(struct tm *time, bool speak_current_time_string);
|
|
|
|
|
#else
|
|
|
|
|
#define talk_date_time(t, s)
|
|
|
|
|
#endif
|
|
|
|
|
#endif /* CONFIG_RTC */
|
|
|
|
|
|
2007-08-06 15:01:45 +00:00
|
|
|
|
/* This (otherwise invalid) ID signals the end of the array. */
|
|
|
|
|
#define TALK_FINAL_ID LANG_LAST_INDEX_IN_ARRAY
|
|
|
|
|
|
|
|
|
|
/* We don't build talk.c for hwcodec sims so we need to define these as empty */
|
|
|
|
|
#if defined(SIMULATOR) && !(CONFIG_CODEC == SWCODEC)
|
|
|
|
|
#define talk_force_enqueue_next(...)
|
|
|
|
|
#define talk_idarray(...)
|
|
|
|
|
#define talk_ids(...)
|
|
|
|
|
#define cond_talk_ids(...)
|
|
|
|
|
#define cond_talk_ids_fq(...)
|
2007-10-10 03:12:17 +00:00
|
|
|
|
#define shutup(...)
|
2007-08-06 15:01:45 +00:00
|
|
|
|
#else
|
|
|
|
|
|
2007-08-06 13:08:36 +00:00
|
|
|
|
/* Enqueue next utterance even if enqueue parameter is false: don't
|
|
|
|
|
interrupt the current utterance. */
|
|
|
|
|
void talk_force_enqueue_next(void);
|
|
|
|
|
|
|
|
|
|
/* speaks one or more IDs (from an array)). */
|
|
|
|
|
int talk_idarray(long *idarray, bool enqueue);
|
|
|
|
|
/* This makes an initializer for the array of IDs and takes care to
|
|
|
|
|
put the final sentinel element at the end. */
|
|
|
|
|
#define TALK_IDARRAY(ids...) ((long[]){ids,TALK_FINAL_ID})
|
|
|
|
|
/* And this handy macro makes it look like a variadic function. */
|
|
|
|
|
#define talk_ids(enqueue, ids...) talk_idarray(TALK_IDARRAY(ids), enqueue)
|
|
|
|
|
/* This version talks only if talking menus are enabled, and does not
|
|
|
|
|
enqueue the initial id. */
|
|
|
|
|
#define cond_talk_ids(ids...) do { \
|
|
|
|
|
if (talk_menus_enabled()) \
|
|
|
|
|
talk_ids(false, ids); \
|
|
|
|
|
} while(0)
|
|
|
|
|
/* And a version that takes the array parameter... */
|
|
|
|
|
#define cond_talk_idarray(idarray) do { \
|
|
|
|
|
if (talk_menus_enabled() \
|
|
|
|
|
talk_idarray(idarray, false); \
|
|
|
|
|
} while(0)
|
|
|
|
|
/* Convenience macro to conditionally speak something and not have
|
|
|
|
|
it interrupted. */
|
|
|
|
|
#define cond_talk_ids_fq(ids...) do { \
|
|
|
|
|
if (talk_menus_enabled()) { \
|
|
|
|
|
talk_ids(false, ids); \
|
|
|
|
|
talk_force_enqueue_next(); \
|
|
|
|
|
} \
|
|
|
|
|
}while(0)
|
2007-08-06 15:01:45 +00:00
|
|
|
|
#endif /*defined(SIMULATOR) && !(CONFIG_CODEC == SWCODEC)*/
|
2004-03-14 21:33:53 +00:00
|
|
|
|
#endif /* __TALK_H__ */
|