Quick and horrible speech engine
Revision 15:bad48ea4468b, committed 2019-01-05
- Comitter:
- spinal
- Date:
- Sat Jan 05 13:20:14 2019 +0000
- Parent:
- 14:f25c2f72b2aa
- Commit message:
- test1
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
speak.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r f25c2f72b2aa -r bad48ea4468b main.cpp --- a/main.cpp Sat Dec 01 13:57:52 2018 +0000 +++ b/main.cpp Sat Jan 05 13:20:14 2019 +0000 @@ -44,16 +44,17 @@ } -uint8_t playSound(const unsigned char *sound, uint16_t soundSize, int volume = 255, int speed=255){ +uint8_t playSound(const unsigned char *sound, uint32_t soundSize, int volume = 255, float speed=255){ - int channel=0; + int channel = 0; + float spd = (POK_AUD_FREQ / 11025); - snd[channel].currentSound = sound; - snd[channel].currentSoundSize = (soundSize*255)/speed; - snd[channel].soundPoint = 0; - snd[channel].playSample = 1; - snd[channel].volume = volume; - snd[channel].speed = speed; + snd[channel].currentSound = sound; // sound to play + snd[channel].currentSoundSize = (soundSize<<8)/speed; // length of sound array adjusted for speed change + snd[channel].volume = volume; // volume, best kept below 64 as louder will cause clipping when playing multiple samples + snd[channel].speed = (speed/spd); // recalculated above + snd[channel].soundPoint = 0; // where the current sound is upto + snd[channel].playSample = 1; // 1 to play this sound, 0 not to return channel; }
diff -r f25c2f72b2aa -r bad48ea4468b speak.h --- a/speak.h Sat Dec 01 13:57:52 2018 +0000 +++ b/speak.h Sat Jan 05 13:20:14 2019 +0000 @@ -1,3 +1,5 @@ + + const int sndSize[] = { // lowercase sizes