BB2 C port
API reference: Blitz libraries in C and the shared code
Loading...
Searching...
No Matches
speaklib.c File Reference
#include "blitzlib.h"
#include "blitzexec.h"

Macros

#define LVO_Translate   (-30) /* translator: a0 = in, d0 = len, a1 = out, d1 = size */

Functions

void _setvoice (void)
void _voiceloc (void)
void speaklib_libinit (void)
void speaklib_libfinit (void)
ULONG _translate (UBYTE *s, const ULONG *lens)
 Translate$(string) - the phoneme translation of a text.
void _speak (const UBYTE *s, const ULONG *lens)
 Speak string - translate a text into phonemes and speak it.
void _phospeak (UBYTE *s, const ULONG *lens)
 PhoneticSpeak phonetic string - speak a string of phonemes.
static void libinit_c (void)
static void libfinit_c (void)
static void _setvoice_c (WORD rate, WORD pitch, UWORD mode, UWORD sex, WORD vol, WORD freq)
 SetVoice rate,pitch,expression,sex,volume,freq - set the narrator's voice for the following Speak/PhoneticSpeak.
 BLITZ_ALIAS (_setvoice, _setvoice_c)
static ULONG _voiceloc_c (void)
 VoiceLoc - the address of the request's V37 part (the newvoice fields).
 BLITZ_ALIAS (_voiceloc, _voiceloc_c)
static void translate (const UBYTE *s, ULONG len)
static void say (const UBYTE *data, ULONG len)

Variables

static struct Library * TransBase
struct { 
   struct IOStdReq   io 
   UWORD   rate 
   UWORD   pitch 
   UWORD   mode 
   UWORD   sex 
   UBYTE *   ch_masks 
   UWORD   nm_masks 
   UWORD   vol 
   UWORD   sampfreq 
   UBYTE   mouths 
   UBYTE   chanmask 
   UBYTE   numchan 
   UBYTE   v37 [19] 
} ioreq
static UBYTE audchan [4] = { 3, 5, 10, 12 }
static struct MsgPort port
static WORD initial
static UBYTE spkbuff [4096]
static const char report [] = "Failed To Open Speech Library"

Macro Definition Documentation

◆ LVO_Translate

#define LVO_Translate   (-30) /* translator: a0 = in, d0 = len, a1 = out, d1 = size */

Function Documentation

◆ _phospeak()

void _phospeak ( UBYTE * s,
const ULONG * lens )

PhoneticSpeak phonetic string - speak a string of phonemes.

Sends the string as it is to narrator.device (CMD_WRITE, SendIO, the popped length), after waiting for the previous one. Leaves a3 = its argument (not a bug: a statement, a3 has no meaning after it). DIFF: a2 stays unchanged (the original pops the string length).

Parameters
sd0: the phonemes
lensa2: the string length on the stack (long)

◆ _setvoice()

void _setvoice ( void )

◆ _setvoice_c()

void _setvoice_c ( WORD rate,
WORD pitch,
UWORD mode,
UWORD sex,
WORD vol,
WORD freq )
static

SetVoice rate,pitch,expression,sex,volume,freq - set the narrator's voice for the following Speak/PhoneticSpeak.

Clips the values and stores them in the request (MOVEM d0-d3,rate / MOVEM d4-d5,vol): rate 40-400, pitch 65-320, mode (expression) and sex & 1, volume at most 64, sample frequency 5000-28000. The values are signed words: -32768 is below every minimum.

Fixed (#279): the clipping compares signed (BGE/BLT); the original's word CMP and BPL/BMI (N flag only, no V) put large negative values whose difference to the limit overflows on the maximum.

Parameters
rated0: speaking rate (words per minute, default 150)
pitchd1: pitch in Hz (default 110)
moded2: expression, the narrator's mode (& 1, default 1)
sexd3: the narrator's sex (& 1: 0 male, 1 female)
vold4: volume (0-64, default 64)
freqd5: sample frequency (default 22200)

◆ _speak()

void _speak ( const UBYTE * s,
const ULONG * lens )

Speak string - translate a text into phonemes and speak it.

Translates the text (translator.library Translate, into a 1024 byte part of the 4K buffer) and sends the phonemes to narrator.device (CMD_WRITE, SendIO, length incl. the 0) without waiting; first waits for the previous Speak/PhoneticSpeak (WaitIO). DIFF: a2 stays unchanged (the original pops the string length).

Parameters
sd0: the text
lensa2: the string length on the stack (long)

◆ _translate()

ULONG _translate ( UBYTE * s,
const ULONG * lens )

Translate$(string) - the phoneme translation of a text.

Translates into the library's buffer and copies the phonemes over the argument (a3 = the argument's address); a3 ends on the 0. DIFF: a2 stays unchanged (the original pops the string length).

Fixed (#277): returns the length without the terminating 0 and leaves a3 on the 0; the original counted the 0 and left a3 behind it (the result one character too long, ending in the 0).

Parameters
sd0: the text (also the result buffer)
lensa2: the string length on the stack (long)
Returns
d0: the length of the phonemes; a3 on their 0

◆ _voiceloc()

void _voiceloc ( void )

◆ _voiceloc_c()

ULONG _voiceloc_c ( void )
static

VoiceLoc - the address of the request's V37 part (the newvoice fields).

The 19 bytes after numchan in the narrator request, at an odd address.

Returns
d0: the address of the V37 bytes of the request

◆ BLITZ_ALIAS() [1/2]

BLITZ_ALIAS ( _setvoice ,
_setvoice_c  )

◆ BLITZ_ALIAS() [2/2]

BLITZ_ALIAS ( _voiceloc ,
_voiceloc_c  )

◆ libfinit_c()

void libfinit_c ( void )
static

◆ libinit_c()

void libinit_c ( void )
static

◆ say()

void say ( const UBYTE * data,
ULONG len )
static

◆ speaklib_libfinit()

void speaklib_libfinit ( void )

◆ speaklib_libinit()

void speaklib_libinit ( void )

◆ translate()

void translate ( const UBYTE * s,
ULONG len )
static

Variable Documentation

◆ audchan

UBYTE audchan[4] = { 3, 5, 10, 12 }
static

◆ ch_masks

UBYTE* ch_masks

◆ chanmask

UBYTE chanmask

◆ initial

WORD initial
static

◆ io

struct IOStdReq io

◆ [struct]

struct { ... } ioreq

◆ mode

UWORD mode

◆ mouths

UBYTE mouths

◆ nm_masks

UWORD nm_masks

◆ numchan

UBYTE numchan

◆ pitch

UWORD pitch

◆ port

struct MsgPort port ( void )
static

◆ rate

UWORD rate

◆ report

const char report[] = "Failed To Open Speech Library"
static

◆ sampfreq

UWORD sampfreq

◆ sex

UWORD sex

◆ spkbuff

UBYTE spkbuff[4096]
static

◆ TransBase

struct Library* TransBase
static

◆ v37

UBYTE v37[19]

◆ vol

UWORD vol