1 /* 2 * ============================================================================ 3 * Title: Intellivoice Emulation 4 * Author: J. Zbiciak 5 * ============================================================================ 6 * This is just a dummy object right now. 7 * ============================================================================ 8 */ 9 #ifndef IVOICE_H_ 10 #define IVOICE_H_ 11 12 typedef struct lpc12_t 13 { 14 int rpt, cnt; /* Repeat counter, Period down-counter. */ 15 uint32_t per, rng; /* Period, Amplitude, Random Number Generator */ 16 int amp; 17 int16_t f_coef[6]; /* F0 through F5. */ 18 int16_t b_coef[6]; /* B0 through B5. */ 19 int16_t z_data[6][2]; /* Time-delay data for the filter stages. */ 20 uint8_t r[16]; /* The encoded register set. */ 21 int interp; 22 } lpc12_t; 23 24 25 typedef struct ivoice_t 26 { 27 periph_t periph; /* Yup, this is a peripheral. :-) */ 28 snd_buf_t snd_buf; /* Sound circular buffer. */ 29 30 int16_t *cur_buf; /* Current sound buffer. */ 31 int cur_len; /* Fullness of current sound buffer. */ 32 33 int silent; /* Flag: Intellivoice is silent. */ 34 35 int16_t *scratch; /* Scratch buffer for audio. */ 36 uint32_t sc_head; /* Head/Tail pointer into scratch circular buf */ 37 uint32_t sc_tail; /* Head/Tail pointer into scratch circular buf */ 38 uint64_t sound_current; 39 int sample_frc, sample_int; 40 41 int *window; /* Sliding Window. */ 42 int wind_sum; /* Window sum. */ 43 int wind_ptr; /* Window pointer. */ 44 int rate, wind; /* Sample rate, Window size. */ 45 int pal_mode; /* PAL vs. NTSC */ 46 double time_scale; /* For --macho */ 47 double skipping; /* part of time-scale */ 48 49 lpc12_t filt; /* 12-pole filter */ 50 int lrq; /* Load ReQuest. == 0 if we can accept a load */ 51 int ald; /* Address LoaD. < 0 if no command pending. */ 52 int pc; /* Microcontroller's PC value. */ 53 int stack; /* Microcontroller's PC stack. */ 54 int fifo_sel; /* True when executing from FIFO. */ 55 int halted; /* True when CPU is halted. */ 56 uint32_t mode; /* Mode register. */ 57 uint32_t page; /* Page set by SETPAGE */ 58 59 uint32_t fifo_head; /* FIFO head pointer (where new data goes). */ 60 uint32_t fifo_tail; /* FIFO tail pointer (where data comes from). */ 61 uint32_t fifo_bitp; /* FIFO bit-pointer (for partial decles). */ 62 uint16_t fifo[64]; /* The 64-decle FIFO. */ 63 64 const uint8_t *rom[16]; /* 4K ROM pages. */ 65 66 char *smp_tname; /* File name template for samples. */ 67 char *smp_cname; /* File name template for samples. */ 68 FILE *smp_file; /* File to put Intellivoice samples in. */ 69 int smp_number; /* Sequence number for samples. */ 70 uint32_t *smp_cksum; /* Checksum history to avoid saving repeats. */ 71 uint32_t smp_cursum; /* Current checksum. */ 72 uint32_t smp_totsmp; /* total number of samples in sample file. */ 73 } ivoice_t; 74 75 /* ======================================================================== */ 76 /* IVOICE_INIT -- Makes a new Intellivoice */ 77 /* ======================================================================== */ 78 int ivoice_init 79 ( 80 ivoice_t *ivoice, /* Structure to initialize. */ 81 uint32_t addr, /* Base address of ivoice. */ 82 snd_t *snd, /* Sound device to register w/. */ 83 int rate, /* Desired sample rate. */ 84 int wind, /* Sliding window size. */ 85 const char *smp_tname, /* Sample file name template. */ 86 int pal_mode, 87 double time_scale 88 ); 89 90 #endif 91 /* ======================================================================== */ 92 /* This program is free software; you can redistribute it and/or modify */ 93 /* it under the terms of the GNU General Public License as published by */ 94 /* the Free Software Foundation; either version 2 of the License, or */ 95 /* (at your option) any later version. */ 96 /* */ 97 /* This program is distributed in the hope that it will be useful, */ 98 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 99 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 100 /* General Public License for more details. */ 101 /* */ 102 /* You should have received a copy of the GNU General Public License along */ 103 /* with this program; if not, write to the Free Software Foundation, Inc., */ 104 /* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ 105 /* ======================================================================== */ 106 /* Copyright (c) 1998-2000, Joseph Zbiciak */ 107 /* ======================================================================== */ 108