another update to the soundlib interface
sound_verbal(char *text, int32_t gender, int32_t tone, int32_t vol,
int32_t moreinfo);
-- NetHack will call this function when it wants to pass text of
spoken language by a character or creature within the game.
-- text is a transcript of what has been spoken.
-- gender indicates MALE or FEMALE sounding voice.
-- tone indicates the tone of the voice.
-- vol is the volume (1% - 100%) for the sound.
-- moreinfo is used to provide additional information to the soundlib.
-- there may be some accessibility uses for this function.
It may be useful for accessibility purposes too.
A preliminary implementation has been attempted for macsound to test
the interface on macOS. No tinkering of the voices has been done.
Use of the test implementation requires the following at build time with make.
WANT_SPEECH=1
That needs to be included on the make command line to enable the test code,
otherwise just the interface update is compiled in.
I don't know for certain when AVSpeechSynthesizer went into macOS, but older versions
likely don't support it, and would just leave off the WANT_SPEECH=1.
If built with WANT_SPEECH=1, the 'voices' NetHack option needs to be enabled.
It was a bit strange, when I first started up the test, to hear Asidonhopo,
the shopkeeper, talking to me as I entered his shop and interacted with him.
This commit is contained in:
@@ -1588,6 +1588,9 @@ struct instance_globals_v {
|
||||
coordxy *viz_rmax; /* max could see indices */
|
||||
boolean vision_full_recalc;
|
||||
|
||||
/* new stuff */
|
||||
struct sound_voice voice;
|
||||
|
||||
boolean havestate;
|
||||
unsigned long magic; /* validate that structure layout is preserved */
|
||||
};
|
||||
|
||||
@@ -1012,6 +1012,7 @@ extern char *strip_newline(char *);
|
||||
extern char *stripchars(char *, const char *, const char *);
|
||||
extern char *stripdigits(char *);
|
||||
extern char *eos(char *);
|
||||
extern const char *c_eos(const char *);
|
||||
extern unsigned Strlen_(const char *, const char *, int);
|
||||
extern boolean str_start_is(const char *, const char *, boolean);
|
||||
extern boolean str_end_is(const char *, const char *);
|
||||
@@ -2620,6 +2621,8 @@ extern char *get_sound_effect_filename(int32_t seidint,
|
||||
char *buf, size_t bufsz, int32_t);
|
||||
#endif
|
||||
extern char *base_soundname_to_filename(char *, char *, size_t, int32_t);
|
||||
extern void set_voice(struct monst *, int32_t, int32_t, int32_t);
|
||||
extern void sound_speak(const char *);
|
||||
|
||||
/* ### sp_lev.c ### */
|
||||
|
||||
|
||||
@@ -277,6 +277,7 @@ struct instance_flags {
|
||||
long hilite_delta; /* number of moves to leave a temp hilite lit */
|
||||
long unhilite_deadline; /* time when oldest temp hilite should be unlit */
|
||||
#endif
|
||||
boolean voices; /* enable text-to-speech or other talking */
|
||||
boolean zerocomp; /* write zero-compressed save files */
|
||||
boolean rlecomp; /* alternative to zerocomp; run-length encoding
|
||||
* compression of levels when writing savefile */
|
||||
|
||||
@@ -497,6 +497,8 @@ typedef uint32_t mmflags_nht; /* makemon MM_ flags */
|
||||
#define OVERRIDE_MSGTYPE 2
|
||||
#define SUPPRESS_HISTORY 4
|
||||
#define URGENT_MESSAGE 8
|
||||
#define PLINE_VERBALIZE 16
|
||||
#define PLINE_SPEECH 32
|
||||
|
||||
/* get_count flags */
|
||||
#define GC_NOFLAGS 0
|
||||
|
||||
@@ -662,6 +662,8 @@ static int optfn_##a(int, int, boolean, char *, char *);
|
||||
NHOPTC(video_height, Advanced, 10, opt_in, set_gameview,
|
||||
No, Yes, No, No, NoAlias, "video height")
|
||||
#endif
|
||||
NHOPTB(voices, Advanced, 0, opt_in, set_in_game,
|
||||
Off, Yes, No, No, NoAlias, &iflags.voices, Term_Off)
|
||||
#ifdef TTY_TILES_ESCCODES
|
||||
NHOPTB(vt_tiledata, Advanced, 0, opt_in, set_in_config,
|
||||
Off, Yes, No, No, NoAlias, &iflags.vt_tiledata, Term_False)
|
||||
|
||||
@@ -53,6 +53,18 @@ struct sound_procs {
|
||||
void (*sound_play_usersound)(char *filename, int32_t volume, int32_t idx);
|
||||
void (*sound_ambience)(int32_t ambience_action, int32_t ambienceid,
|
||||
int32_t proximity);
|
||||
void (*sound_verbal)(char *text, int32_t gender, int32_t tone,
|
||||
int32_t vol, int32_t moreinfo);
|
||||
};
|
||||
|
||||
struct sound_voice {
|
||||
int32_t serialno;
|
||||
int32_t gender;
|
||||
int32_t tone;
|
||||
int32_t volume;
|
||||
int32_t moreinfo;
|
||||
struct monst *mon;
|
||||
const char *nameid;
|
||||
};
|
||||
|
||||
extern struct sound_procs sndprocs;
|
||||
@@ -67,7 +79,8 @@ extern struct sound_procs sndprocs;
|
||||
#define SOUND_TRIGGER_ACHIEVEMENTS 0x0004L
|
||||
#define SOUND_TRIGGER_SOUNDEFFECTS 0x0008L
|
||||
#define SOUND_TRIGGER_AMBIENCE 0x0010L
|
||||
/* 27 free bits */
|
||||
#define SOUND_TRIGGER_VERBAL 0x0020L
|
||||
/* 26 free bits */
|
||||
|
||||
extern struct sound_procs soundprocs;
|
||||
|
||||
@@ -334,6 +347,15 @@ enum ambiences {
|
||||
amb_noambience,
|
||||
};
|
||||
|
||||
enum voice_moreinfo {
|
||||
voice_nothing_special,
|
||||
voice_talking_artifact = 0x0001,
|
||||
voice_deity = 0x0002,
|
||||
voice_oracle = 0x0004,
|
||||
voice_throne = 0x0008,
|
||||
voice_death = 0x0010
|
||||
};
|
||||
|
||||
enum achievements_arg2 {
|
||||
sa2_zero_invalid, sa2_splashscreen, sa2_newgame_nosplash, sa2_restoregame,
|
||||
sa2_xplevelup, sa2_xpleveldown, number_of_sa2_entries
|
||||
@@ -396,8 +418,6 @@ SoundAchievement(0, sa2_xpleveldown, level);
|
||||
(*soundprocs.sound_hero_playnotes)((instrument), (str), (vol)); \
|
||||
} while(0)
|
||||
|
||||
/* void (*sound_achievement)(schar, schar, int32_t); */
|
||||
|
||||
/* Player's perspective, not the hero's; no Deaf suppression */
|
||||
#define SoundAchievement(arg1, arg2, avals) \
|
||||
do { \
|
||||
@@ -406,6 +426,21 @@ SoundAchievement(0, sa2_xpleveldown, level);
|
||||
(*soundprocs.sound_achievement)((arg1), (arg2), (avals)); \
|
||||
} while(0)
|
||||
|
||||
/* sound_speak is in sound.c */
|
||||
#define SoundSpeak(text) \
|
||||
do { \
|
||||
if ((gp.pline_flags & (PLINE_VERBALIZE | PLINE_SPEECH)) != 0 \
|
||||
&& soundprocs.sound_verbal && iflags.voices \
|
||||
&& ((soundprocs.sound_triggers & SOUND_TRIGGER_VERBAL) != 0)) \
|
||||
sound_speak(text); \
|
||||
} while(0)
|
||||
|
||||
/* set_voice is in sound.c */
|
||||
#define SetVoice(mon, tone, vol, moreinfo) \
|
||||
do { \
|
||||
set_voice(mon, tone, vol, moreinfo); \
|
||||
} while(0)
|
||||
|
||||
/* void (*sound_achievement)(schar, schar, int32_t); */
|
||||
|
||||
#ifdef SOUNDLIBONLY
|
||||
@@ -420,6 +455,8 @@ SoundAchievement(0, sa2_xpleveldown, level);
|
||||
#define Soundeffect(seid, vol)
|
||||
#define Hero_playnotes(instrument, str, vol)
|
||||
#define SoundAchievement(arg1, arg2, avals)
|
||||
#define SoundSpeak(text)
|
||||
#define SetVoice(mon, tone, vol, moreinfo)
|
||||
#ifdef SOUNDLIBONLY
|
||||
#undef SOUNDLIBONLY
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user