added a working example,look in the main loop

master
dennisdebel 5 years ago
parent 6ad3583451
commit aa37eed02f

@ -0,0 +1,149 @@
// Talkie library
// Copyright 2011 Peter Knight
// Adafruit library modified by Jean-Luc Deladrière
// This code is released under GPLv2 license.
/*
* Pot1 & CV in1 : Reset the counter
* Pot2 & CV in2 : Change the Pitch
* Pot3 & CV in3 : Change the Speed
*
* CV in3 : Trigger the speech
*/
#include "talkie.h"
Talkie voice;
const uint8_t spTONE[] PROGMEM ={0x09,0x98,0xCA,0xD2,0x01,0x4B,0x5B,0x09,0x20,0xC4,0xB2,0x13,0x06,0x53,0x9D,0x22,0x59,0x6F,0xBC,0xE2,0xA0,0x7A,0x9C,0x25,0xED,0x48,0x82,0x9C,0x35,0xD2,0xA6,0x23,0x75,0x72,0x56,0xD9,0x92,0x96,0xCC,0xCA,0x5D,0x35,0x55,0x5A,0x2A,0x23,0xB7,0x2D,0xC8,0x4D,0xAA,0x1D,0xEF,0xF1,0x40,0xD7,0xA9,0xD5,0x76,0xD2,0x8D,0x62,0x87,0x4E,0xA6,0x0E,0x57,0x8E,0x9B,0x7A,0xA7,0xB3,0x82,0xDC,0x9E,0xEA,0x75,0xD5,0x62,0x09,0x3B,0xAA,0xB7,0x81,0x53,0xB9,0xDC,0xEA,0x5E,0xF5,0x2A,0xA8,0x1B,0x77,0x62,0x31,0x48,0xE7,0x6E,0x92,0x69,0xD8,0xC0,0x75,0x7A,0x58,0xBA,0x7E,0x00,0x00};
const uint8_t spTONE1[] PROGMEM = {0x8D,0xF2,0xDE,0xDD,0xDD,0x93,0x74,0xAA,0x53,0x9D,0xEA,0x54,0xA7,0x3A,0xD5,0xA9,0x4E,0x75,0xAA,0x53,0x9D,0xEA,0x54,0xA7,0x3A,0xD5,0xA9,0x4E,0x75,0xAA,0x53,0x9D,0xEA,0x54,0xA7,0x3A,0xD5,0xA9,0x4E,0x75,0xAA,0x53,0x9D,0xEA,0x54,0xA7,0x3A,0xD5,0xA9,0x4E,0x75,0xAA,0x53,0x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, 0x87, 0x13, 0x4C, 0x0D, 0xA7, 0x75, 0xAB, 0x7B, 0x3E, 0xE3, 0x19, 0x6F, 0x7F, 0xA7, 0xA7, 0xF9, 0xD0, 0x30, 0x5B, 0x1D, 0x9E, 0x9A, 0x34, 0x44, 0xBC, 0xB6, 0x7D, 0xFE, 0x1F};
const uint8_t spTWO[] PROGMEM = {0x06, 0xB8, 0x59, 0x34, 0x00, 0x27, 0xD6, 0x38, 0x60, 0x58, 0xD3, 0x91, 0x55, 0x2D, 0xAA, 0x65, 0x9D, 0x4F, 0xD1, 0xB8, 0x39, 0x17, 0x67, 0xBF, 0xC5, 0xAE, 0x5A, 0x1D, 0xB5, 0x7A, 0x06, 0xF6, 0xA9, 0x7D, 0x9D, 0xD2, 0x6C, 0x55, 0xA5, 0x26, 0x75, 0xC9, 0x9B, 0xDF, 0xFC, 0x6E, 0x0E, 0x63, 0x3A, 0x34, 0x70, 0xAF, 0x3E, 0xFF, 0x1F};
const uint8_t spTHREE[] PROGMEM = {0x0C, 0xE8, 0x2E, 0x94, 0x01, 0x4D, 0xBA, 0x4A, 0x40, 0x03, 0x16, 0x68, 0x69, 0x36, 0x1C, 0xE9, 0xBA, 0xB8, 0xE5, 0x39, 0x70, 0x72, 0x84, 0xDB, 0x51, 0xA4, 0xA8, 0x4E, 0xA3, 0xC9, 0x77, 0xB1, 0xCA, 0xD6, 0x52, 0xA8, 0x71, 0xED, 0x2A, 0x7B, 0x4B, 0xA6, 0xE0, 0x37, 0xB7, 0x5A, 0xDD, 0x48, 0x8E, 0x94, 0xF1, 0x64, 0xCE, 0x6D, 0x19, 0x55, 0x91, 0xBC, 0x6E, 0xD7, 0xAD, 0x1E, 0xF5, 0xAA, 0x77, 0x7A, 0xC6, 0x70, 0x22, 0xCD, 0xC7, 0xF9, 0x89, 0xCF, 0xFF, 0x03};
const uint8_t spFOUR[] PROGMEM = {0x08, 0x68, 0x21, 0x0D, 0x03, 0x04, 0x28, 0xCE, 0x92, 0x03, 0x23, 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, 0xDC, 0x45, 0x64, 0x03, 0x00, 0xC0, 0xFF, 0x03};
const uint8_t spFIF_[] PROGMEM = {0x08, 0x98, 0x31, 0x93, 0x02, 0x1C, 0xE0, 0x80, 0x07, 0x5A, 0xD6, 0x1C, 0x6B, 0x78, 0x2E, 0xBD, 0xE5, 0x2D, 0x4F, 0xDD, 0xAD, 0xAB, 0xAA, 0x6D, 0xC9, 0x23, 0x02, 0x56, 0x4C, 0x93, 0x00, 0x05, 0x10, 0x90, 0x89, 0x31, 0xFC, 0x3F};
const uint8_t sp_TEEN[] PROGMEM = {0x09, 0x58, 0x2A, 0x25, 0x00, 0xCB, 0x9F, 0x95, 0x6C, 0x14, 0x21, 0x89, 0xA9, 0x78, 0xB3, 0x5B, 0xEC, 0xBA, 0xB5, 0x23, 0x13, 0x46, 0x97, 0x99, 0x3E, 0xD6, 0xB9, 0x2E, 0x79, 0xC9, 0x5B, 0xD8, 0x47, 0x41, 0x53, 0x1F, 0xC7, 0xE1, 0x9C, 0x85, 0x54, 0x22, 0xEC, 0xFA, 0xDB, 0xDD, 0x23, 0x93, 0x49, 0xB8, 0xE6, 0x78, 0xFF, 0x3F};
const uint8_t spTWENTY[] PROGMEM = {0x0A, 0xE8, 0x4A, 0xCD, 0x01, 0xDB, 0xB9, 0x33, 0xC0, 0xA6, 0x54, 0x0C, 0xA4, 0x34, 0xD9, 0xF2, 0x0A, 0x6C, 0xBB, 0xB3, 0x53, 0x0E, 0x5D, 0xA6, 0x25, 0x9B, 0x6F, 0x75, 0xCA, 0x61, 0x52, 0xDC, 0x74, 0x49, 0xA9, 0x8A, 0xC4, 0x76, 0x4D, 0xD7, 0xB1, 0x76, 0xC0, 0x55, 0xA6, 0x65, 0xD8, 0x26, 0x99, 0x5C, 0x56, 0xAD, 0xB9, 0x25, 0x23, 0xD5, 0x7C, 0x32, 0x96, 0xE9, 0x9B, 0x20, 0x7D, 0xCB, 0x3C, 0xFA, 0x55, 0xAE, 0x99, 0x1A, 0x30, 0xFC, 0x4B, 0x3C, 0xFF, 0x1F};
const uint8_t spT[] PROGMEM = {0x01, 0xD8, 0xB6, 0xDD, 0x01, 0x2F, 0xF4, 0x38, 0x60, 0xD5, 0xD1, 0x91, 0x4D, 0x97, 0x84, 0xE6, 0x4B, 0x4E, 0x36, 0xB2, 0x10, 0x67, 0xCD, 0x19, 0xD9, 0x2C, 0x01, 0x94, 0xF1, 0x78, 0x66, 0x33, 0xEB, 0x79, 0xAF, 0x7B, 0x57, 0x87, 0x36, 0xAF, 0x52, 0x08, 0x9E, 0x6B, 0xEA, 0x5A, 0xB7, 0x7A, 0x94, 0x73, 0x45, 0x47, 0xAC, 0x5A, 0x9C, 0xAF, 0xFF, 0x07};
const uint8_t spHUNDRED[] PROGMEM = {0x04, 0xC8, 0x7E, 0x5C, 0x02, 0x0A, 0xA8, 0x62, 0x43, 0x03, 0xA7, 0xA8, 0x62, 0x43, 0x4B, 0x97, 0xDC, 0xF2, 0x14, 0xC5, 0xA7, 0x9B, 0x7A, 0xD3, 0x95, 0x37, 0xC3, 0x1E, 0x16, 0x4A, 0x66, 0x36, 0xF3, 0x5A, 0x89, 0x6E, 0xD4, 0x30, 0x55, 0xB5, 0x32, 0xB7, 0x31, 0xB5, 0xC1, 0x69, 0x2C, 0xE9, 0xF7, 0xBC, 0x96, 0x12, 0x39, 0xD4, 0xB5, 0xFD, 0xDA, 0x9B, 0x0F, 0xD1, 0x90, 0xEE, 0xF5, 0xE4, 0x17, 0x02, 0x45, 0x28, 0x77, 0x11, 0xD9, 0x40, 0x9E, 0x45, 0xDD, 0x2B, 0x33, 0x71, 0x7A, 0xBA, 0x0B, 0x13, 0x95, 0x2D, 0xF9, 0xF9, 0x7F};
const uint8_t spTHOUSAND[] PROGMEM = {0x0C, 0xE8, 0x2E, 0xD4, 0x02, 0x06, 0x98, 0xD2, 0x55, 0x03, 0x16, 0x68, 0x7D, 0x17, 0xE9, 0x6E, 0xBC, 0x65, 0x8C, 0x45, 0x6D, 0xA6, 0xE9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xAF, 0x5A, 0xDF, 0x60, 0xF4, 0x39, 0x69, 0xAB, 0x63, 0xD9, 0x3B, 0xD2, 0xBC, 0x24, 0xA5, 0xF5, 0xB6, 0x0F, 0x80, 0x01, 0x3E, 0x63, 0x65, 0xC0, 0x5F, 0x63, 0x12, 0x90, 0x80, 0x06, 0x24, 0x20, 0x01, 0x0E, 0xFC, 0x3F};
int count=0;
int reset1;
int preset1 = analogRead(1);
int reset2;
int preset2 =0;
/* Say any number between -999,999 and 999,999 */
void sayNumber(long n) {
if (n<0) {
voice.say(spMINUS);
sayNumber(-n);
} else if (n==0) {
voice.say(spZERO);
} else {
if (n>=1000) {
int thousands = n / 1000;
sayNumber(thousands);
voice.say(spTHOUSAND);
n %= 1000;
if ((n > 0) && (n<100)) voice.say(spAND);
}
if (n>=100) {
int hundreds = n / 100;
sayNumber(hundreds);
voice.say(spHUNDRED);
n %= 100;
if (n > 0) voice.say(spAND);
}
if (n>19) {
int tens = n / 10;
switch (tens) {
case 2: voice.say(spTWENTY); break;
case 3: voice.say(spTHIR_); voice.say(spT); break;
case 4: voice.say(spFOUR); voice.say(spT); break;
case 5: voice.say(spFIF_); voice.say(spT); break;
case 6: voice.say(spSIX); voice.say(spT); break;
case 7: voice.say(spSEVEN); voice.say(spT); break;
case 8: voice.say(spEIGHT); voice.say(spT); break;
case 9: voice.say(spNINE); voice.say(spT); break;
}
n %= 10;
}
switch(n) {
case 1: voice.say(spONE); break;
case 2: voice.say(spTWO); break;
case 3: voice.say(spTHREE); break;
case 4: voice.say(spFOUR); break;
case 5: voice.say(spFIVE); break;
case 6: voice.say(spSIX); break;
case 7: voice.say(spSEVEN); break;
case 8: voice.say(spEIGHT); break;
case 9: voice.say(spNINE); break;
case 10: voice.say(spTEN); break;
case 11: voice.say(spELEVEN); break;
case 12: voice.say(spTWELVE); break;
case 13: voice.say(spTHIR_); voice.say(sp_TEEN); break;
case 14: voice.say(spFOUR); voice.say(sp_TEEN);break;
case 15: voice.say(spFIF_); voice.say(sp_TEEN); break;
case 16: voice.say(spSIX); voice.say(sp_TEEN); break;
case 17: voice.say(spSEVEN); voice.say(sp_TEEN); break;
case 18: voice.say(spEIGHT); voice.say(sp_TEEN); break;
case 19: voice.say(spNINE); voice.say(sp_TEEN); break;
}
}
}
void counter()
{
reset2 = analogRead(2);
if((abs(reset2-preset2))>200)
{
count=0;
preset2=reset2;
}
count=count+1;
sayNumber(count);
}
void setup() {
}
void loop() {
//
// if(analogRead(3)>500)
// {
counter();
delay(500);
//while(analogRead(3)>500);
// }
}

@ -0,0 +1,308 @@
// Talkie library
// Copyright 2011 Peter Knight
// Adafruit library modified by Jean-Luc Deladrière
// This code is released under GPLv2 license.
// Though the Wave Shield DAC pins are configurable, much else in this code
// is still very Uno-specific; the timers and timer control registers, the
// PWM output pin, etc. Compatibility with other boards is not guaranteed.
#include "talkie.h"
#define PIEZO // If set, connect piezo on pins 3 & 11, is louder
//#define FS 8000 // Speech engine sample rate
#define FS map(analogRead(1),0,1023,4000,16000)
//#define TICKS (FS / 40) // Speech data rate
#define TICKS 20 // Speech data rate
//#define TICKS map(analogRead(0),0,700,20,800)
// Some of these variables could go in the Talkie object, but the hardware
// specificity (reliance on certain timers and/or PWM pins) kills any point
// in multiple instances; there can be only one. So they're declared as
// static here to keep the header simple and self-documenting.
//#if TICKS < 255
//static volatile uint8_t interruptCount;
//#else
static volatile uint16_t interruptCount;
static volatile uint16_t slower;
//#endif
static volatile uint8_t *csPort, *clkPort, *datPort;
static volatile uint16_t synthEnergy;
static volatile int16_t synthK1, synthK2;
static volatile int8_t synthK3, synthK4, synthK5, synthK6,
synthK7, synthK8, synthK9, synthK10;
static uint16_t buf, synthRand = 1;
static int16_t x0, x1, x2, x3, x4, x5, x6, x7, x8, x9;
static uint8_t periodCounter, nextPwm = 0x80,
synthPeriod, bufBits,
csBitMask, clkBitMask, datBitMask;
static const uint8_t *ptrAddr;
static const int16_t PROGMEM
tmsK1[] = {0x82C0,0x8380,0x83C0,0x8440,0x84C0,0x8540,0x8600,0x8780,
0x8880,0x8980,0x8AC0,0x8C00,0x8D40,0x8F00,0x90C0,0x92C0,
0x9900,0xA140,0xAB80,0xB840,0xC740,0xD8C0,0xEBC0,0x0000,
0x1440,0x2740,0x38C0,0x47C0,0x5480,0x5EC0,0x6700,0x6D40},
tmsK2[] = {0xAE00,0xB480,0xBB80,0xC340,0xCB80,0xD440,0xDDC0,0xE780,
0xF180,0xFBC0,0x0600,0x1040,0x1A40,0x2400,0x2D40,0x3600,
0x3E40,0x45C0,0x4CC0,0x5300,0x5880,0x5DC0,0x6240,0x6640,
0x69C0,0x6CC0,0x6F80,0x71C0,0x73C0,0x7580,0x7700,0x7E80};
static const int8_t PROGMEM
tmsK3[] = {0x92,0x9F,0xAD,0xBA,0xC8,0xD5,0xE3,0xF0,
0xFE,0x0B,0x19,0x26,0x34,0x41,0x4F,0x5C},
tmsK4[] = {0xAE,0xBC,0xCA,0xD8,0xE6,0xF4,0x01,0x0F,
0x1D,0x2B,0x39,0x47,0x55,0x63,0x71,0x7E},
tmsK5[] = {0xAE,0xBA,0xC5,0xD1,0xDD,0xE8,0xF4,0xFF,
0x0B,0x17,0x22,0x2E,0x39,0x45,0x51,0x5C},
tmsK6[] = {0xC0,0xCB,0xD6,0xE1,0xEC,0xF7,0x03,0x0E,
0x19,0x24,0x2F,0x3A,0x45,0x50,0x5B,0x66},
tmsK7[] = {0xB3,0xBF,0xCB,0xD7,0xE3,0xEF,0xFB,0x07,
0x13,0x1F,0x2B,0x37,0x43,0x4F,0x5A,0x66},
tmsK8[] = {0xC0,0xD8,0xF0,0x07,0x1F,0x37,0x4F,0x66},
tmsK9[] = {0xC0,0xD4,0xE8,0xFC,0x10,0x25,0x39,0x4D},
tmsK10[] = {0xCD,0xDF,0xF1,0x04,0x16,0x20,0x3B,0x4D},
chirp[] = {0x00,0x2A,0xD4,0x32,0xB2,0x12,0x25,0x14,
0x02,0xE1,0xC5,0x02,0x5F,0x5A,0x05,0x0F,
0x26,0xFC,0xA5,0xA5,0xD6,0xDD,0xDC,0xFC,
0x25,0x2B,0x22,0x21,0x0F,0xFF,0xF8,0xEE,
0xED,0xEF,0xF7,0xF6,0xFA,0x00,0x03,0x02,0x01};
static const uint8_t PROGMEM
tmsEnergy[] = {0x00,0x02,0x03,0x04,0x05,0x07,0x0A,0x0F,
0x14,0x20,0x29,0x39,0x51,0x72,0xA1,0xFF},
tmsPeriod[] = {0x00,0x10,0x11,0x12,0x13,0x14,0x15,0x16,
0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,
0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26,
0x27,0x28,0x29,0x2A,0x2B,0x2D,0x2F,0x31,
0x33,0x35,0x36,0x39,0x3B,0x3D,0x3F,0x42,
0x45,0x47,0x49,0x4D,0x4F,0x51,0x55,0x57,
0x5C,0x5F,0x63,0x66,0x6A,0x6E,0x73,0x77,
0x7B,0x80,0x85,0x8A,0x8F,0x95,0x9A,0xA0};
// Constructor for PWM mode
Talkie::Talkie(void) {
#if defined(__AVR_ATmega32U4__)
pinMode(5, OUTPUT); // !OC4A
#else
pinMode(3, OUTPUT); // OC2B
#endif
#ifdef PIEZO
pinMode(11, OUTPUT); // OC2A
#endif
csBitMask = 0; // DAC not in use
}
// Constructor for DAC mode
Talkie::Talkie(uint8_t cs, uint8_t clk, uint8_t dat) {
csPort = portOutputRegister(digitalPinToPort(cs));
csBitMask = digitalPinToBitMask(cs);
clkPort = portOutputRegister(digitalPinToPort(clk));
clkBitMask = digitalPinToBitMask(clk);
datPort = portOutputRegister(digitalPinToPort(dat));
datBitMask = digitalPinToBitMask(dat);
pinMode(cs , OUTPUT);
pinMode(clk, OUTPUT);
pinMode(dat, OUTPUT);
*csPort |= csBitMask; // Deselect
*clkPort &= ~clkBitMask; // Clock low
}
void Talkie::say(const uint8_t *addr, boolean block) {
// Enable the speech system whenever say() is called.
if(!csBitMask) {
#if defined(__AVR_ATmega32U4__)
// Set up Timer4 for fast PWM on !OC4A
PLLFRQ = (PLLFRQ & 0xCF) | 0x30; // Route PLL to async clk
TCCR4A = _BV(COM4A0) | _BV(PWM4A); // Clear on match, PWMA on
TCCR4B = _BV(PWM4X) |_BV(CS40); // PWM invert, 1:1 prescale
TCCR4D = 0; // Fast PWM mode
TCCR4E = 0; // Not enhanced mode
TC4H = 0; // Not 10-bit mode
DT4 = 0; // No dead time
OCR4C = 255; // TOP
OCR4A = 127; // 50% duty to start
#else
// Set up Timer2 for 8-bit, 62500 Hz PWM on OC2B
TCCR2A = _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
TCCR2B = _BV(CS20); // No prescale
TIMSK2 = 0; // No interrupt
OCR2B = 0x80; // 50% duty cycle
#ifdef PIEZO
OCR2A = 0x80;
TCCR2A |= _BV(COM2A1) | _BV(COM2A0); // OC2A inverting mode
#endif
#endif
}
// Reset synth state and 'ROM' reader
x0 = x1 = x2 = x3 = x4 = x5 = x6 = x7 = x8 =
periodCounter = buf = bufBits = 0;
ptrAddr = addr;
interruptCount = TICKS; // modif rate
// Set up Timer1 to trigger periodic synth calc at 'FS' Hz
TCCR1A = 0; // No output
TCCR1B = _BV(WGM12) | _BV(CS10); // CTC mode, no prescale
//OCR1A = ((F_CPU + (FS / 2)) / FS) - 1; // 'FS' Hz (w/rounding)
OCR1A = F_CPU / FS;
TCNT1 = 0; // Reset counter
TIMSK1 = _BV(OCIE1A); // Compare match interrupt on
if(block) while(TIMSK1 & _BV(OCIE1A));
slower= map(analogRead(0),0,1023,600,0);
}
boolean Talkie::talking(void) {
return TIMSK1 & _BV(OCIE1A);
}
static inline uint8_t rev(uint8_t a) { // Reverse bit sequence in 8-bit value
a = ( a >> 4) | ( a << 4); // 76543210 -> 32107654
a = ((a & 0xCC) >> 2) | ((a & 0x33) << 2); // 32107654 -> 10325476
a = ((a & 0xAA) >> 1) | ((a & 0x55) << 1); // 10325476 -> 01234567
return a;
}
static uint8_t getBits(uint8_t bits) {
uint8_t value;
if(bits > bufBits) {
buf |= rev(pgm_read_byte(ptrAddr)) << (8 - bufBits);
bufBits += 8;
ptrAddr++; // Don't post-inc in pgm_read_byte! Is a macro.
}
value = buf >> (16 - bits);
buf <<= bits;
bufBits -= bits;
return value;
}
static void dacOut(uint8_t value) {
uint8_t bit;
*csPort &= ~csBitMask; // Select DAC
// Clock out 4 bits DAC config (not in loop because it's constant)
*datPort &= ~datBitMask; // 0 = Select DAC A, unbuffered
*clkPort |= clkBitMask; *clkPort &= ~clkBitMask;
*clkPort |= clkBitMask; *clkPort &= ~clkBitMask;
*datPort |= datBitMask; // 1X gain, enable = 1
*clkPort |= clkBitMask; *clkPort &= ~clkBitMask;
*clkPort |= clkBitMask; *clkPort &= ~clkBitMask;
// Output is expanded from 8 to 12 bits for DAC. Perhaps the
// synthesizer math could be fiddled to generate 12-bit values.
for(bit=0x80; bit; bit>>=1) { // Clock out first 8 bits of data
if(value & bit) *datPort |= datBitMask;
else *datPort &= ~datBitMask;
*clkPort |= clkBitMask; *clkPort &= ~clkBitMask;
}
for(bit=0x80; bit >= 0x10; bit>>=1) { // Low 4 bits = repeat hi 4
if(value & bit) *datPort |= datBitMask;
else *datPort &= ~datBitMask;
*clkPort |= clkBitMask; *clkPort &= ~clkBitMask;
}
*csPort |= csBitMask; // Unselect DAC
}
#define read8(base, bits) pgm_read_byte(&base[getBits(bits)]);
#define read16(base, bits) pgm_read_word(&base[getBits(bits)]);
ISR(TIMER1_COMPA_vect) {
int16_t u0;
if(csBitMask) dacOut(nextPwm);
#if defined(__AVR_ATmega32U4__)
else OCR4A = nextPwm;
#else
#ifdef PIEZO
else OCR2A = OCR2B = nextPwm;
#else
else OCR2B = nextPwm;
#endif
#endif
if(++interruptCount >= TICKS+slower){
// Read speech data, processing the variable size frames
uint8_t energy;
if((energy = getBits(4)) == 0) { // Rest frame
synthEnergy = 0;
} else if(energy == 0xF) { // Stop frame; silence
TIMSK1 &= ~_BV(OCIE1A); // Stop interrupt
nextPwm = 0x80; // Neutral
if(csBitMask) {
dacOut(nextPwm);
} else {
// Stop PWM out:
#if defined(__AVR_ATmega32U4__)
TCCR4A = 0;
#else
//TCCR2A = 0; // to avoid "Plop" between speech
#endif
}
return;
} else {
synthEnergy = pgm_read_byte(&tmsEnergy[energy]);
uint8_t repeat = getBits(1);
synthPeriod = pgm_read_byte(&tmsPeriod[getBits(6)]);
if(!repeat) { // A repeat frame uses last coefficients
synthK1 = read16(tmsK1, 5); // All frames
synthK2 = read16(tmsK2, 5); // use the first
synthK3 = read8( tmsK3, 4); // 4 coefficients
synthK4 = read8( tmsK4, 4);
if(synthPeriod) {
synthK5 = read8(tmsK5 , 4); // Voiced
synthK6 = read8(tmsK6 , 4); // frames
synthK7 = read8(tmsK7 , 4); // use
synthK8 = read8(tmsK8 , 3); // six
synthK9 = read8(tmsK9 , 3); // extra
synthK10 = read8(tmsK10, 3); // coeffs
}
}
}
interruptCount = 0;
}
if(synthPeriod) { // Voiced source
if(++periodCounter >= synthPeriod) periodCounter = 0;
u0 = (periodCounter >= sizeof(chirp)) ? 0 :
(pgm_read_byte(&chirp[periodCounter]) *
(uint32_t)synthEnergy) >> 8;
} else { // Unvoiced source
synthRand = (synthRand >> 1) ^ ((synthRand & 1) ? 0xB800 : 0);
u0 = (synthRand & 1) ? synthEnergy : -synthEnergy;
}
u0 -= ((synthK10 * x9) +
(synthK9 * x8)) >> 7;
x9 = x8 + ((synthK9 * u0 ) >> 7);
u0 -= ((synthK8 * x7 ) >> 7);
x8 = x7 + ((synthK8 * u0 ) >> 7);
u0 -= ((synthK7 * x6 ) >> 7);
x7 = x6 + ((synthK7 * u0 ) >> 7);
u0 -= ((synthK6 * x5 ) >> 7);
x6 = x5 + ((synthK6 * u0 ) >> 7);
u0 -= ((synthK5 * x4 ) >> 7);
x5 = x4 + ((synthK5 * u0 ) >> 7);
u0 -= ((synthK4 * x3 ) >> 7);
x4 = x3 + ((synthK4 * u0 ) >> 7);
u0 -= ((synthK3 * x2 ) >> 7);
x3 = x2 + ((synthK3 * u0 ) >> 7);
u0 -= ((synthK2 * (int32_t)x1 ) >> 15);
x2 = x1 + ((synthK2 * (int32_t)u0 ) >> 15);
u0 -= ((synthK1 * (int32_t)x0 ) >> 15);
x1 = x0 + ((synthK1 * (int32_t)u0 ) >> 15);
if( u0 > 511) u0 = 511; // Output clamp
else if(u0 < -512) u0 = -512;
x0 = u0;
nextPwm = (u0 >> 2) + 0x80;
}

@ -0,0 +1,20 @@
// Talkie library
// Copyright 2011 Peter Knight
// Adafruit library modified by Jean-Luc Deladrière
// This code is released under GPLv2 license.
#ifndef _Talkie_h_
#define _Talkie_h_
#include <Arduino.h>
class Talkie {
public:
Talkie(void); // PWM
Talkie(uint8_t cs, uint8_t clk, uint8_t dat); // DAC
void say(const uint8_t *address, boolean block=true);
boolean talking(void); // Poll this when block=false
};
#endif
Loading…
Cancel
Save