2015-12-29 15:26:01 +00:00
|
|
|
#include "mouthAnimation.h"
|
2016-03-01 20:57:05 +00:00
|
|
|
#include "logging.h"
|
2015-11-20 21:20:19 +00:00
|
|
|
|
|
|
|
using std::map;
|
|
|
|
|
|
|
|
Shape getShape(Phone phone) {
|
|
|
|
switch (phone) {
|
|
|
|
case Phone::None:
|
|
|
|
case Phone::P:
|
|
|
|
case Phone::B:
|
|
|
|
case Phone::M:
|
|
|
|
return Shape::A;
|
|
|
|
|
|
|
|
case Phone::Unknown:
|
2016-01-31 20:39:49 +00:00
|
|
|
case Phone::IY:
|
2015-11-20 21:20:19 +00:00
|
|
|
case Phone::T:
|
|
|
|
case Phone::D:
|
|
|
|
case Phone::K:
|
|
|
|
case Phone::G:
|
|
|
|
case Phone::CH:
|
|
|
|
case Phone::JH:
|
|
|
|
case Phone::TH:
|
|
|
|
case Phone::DH:
|
|
|
|
case Phone::S:
|
|
|
|
case Phone::Z:
|
|
|
|
case Phone::SH:
|
|
|
|
case Phone::ZH:
|
|
|
|
case Phone::N:
|
|
|
|
case Phone::NG:
|
|
|
|
case Phone::R:
|
2016-01-31 20:39:49 +00:00
|
|
|
case Phone::Y:
|
2015-11-20 21:20:19 +00:00
|
|
|
return Shape::B;
|
|
|
|
|
2016-01-31 20:39:49 +00:00
|
|
|
case Phone::EH:
|
2015-11-20 21:20:19 +00:00
|
|
|
case Phone::IH:
|
2016-01-31 20:39:49 +00:00
|
|
|
case Phone::AH:
|
2015-11-20 21:20:19 +00:00
|
|
|
case Phone::EY:
|
|
|
|
case Phone::HH:
|
|
|
|
return Shape::C;
|
|
|
|
|
2016-01-31 20:39:49 +00:00
|
|
|
case Phone::AA:
|
2015-11-20 21:20:19 +00:00
|
|
|
case Phone::AE:
|
|
|
|
case Phone::AY:
|
|
|
|
case Phone::AW:
|
2016-01-31 20:39:49 +00:00
|
|
|
return Shape::D;
|
2015-11-20 21:20:19 +00:00
|
|
|
|
|
|
|
case Phone::AO:
|
2016-01-31 20:39:49 +00:00
|
|
|
case Phone::UH:
|
2015-11-20 21:20:19 +00:00
|
|
|
case Phone::OW:
|
2016-01-31 20:39:49 +00:00
|
|
|
case Phone::ER:
|
|
|
|
return Shape::E;
|
|
|
|
|
|
|
|
case Phone::UW:
|
|
|
|
case Phone::OY:
|
|
|
|
case Phone::W:
|
2015-11-20 21:20:19 +00:00
|
|
|
return Shape::F;
|
|
|
|
|
|
|
|
case Phone::F:
|
|
|
|
case Phone::V:
|
|
|
|
return Shape::G;
|
|
|
|
|
|
|
|
case Phone::L:
|
|
|
|
return Shape::H;
|
|
|
|
|
|
|
|
default:
|
|
|
|
throw std::runtime_error("Unexpected Phone value.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
map<centiseconds, Shape> animate(const map<centiseconds, Phone> &phones) {
|
|
|
|
map<centiseconds, Shape> shapes;
|
2015-11-25 21:00:24 +00:00
|
|
|
Shape lastShape = Shape::Invalid;
|
2016-03-01 20:57:05 +00:00
|
|
|
for (auto it = phones.cbegin(); it != phones.cend(); ++it) {
|
2015-12-01 21:28:29 +00:00
|
|
|
Shape shape = getShape(it->second);
|
|
|
|
if (shape != lastShape || next(it) == phones.cend()) {
|
|
|
|
shapes[it->first] = shape;
|
2015-11-25 21:00:24 +00:00
|
|
|
lastShape = shape;
|
|
|
|
}
|
2015-11-20 21:20:19 +00:00
|
|
|
}
|
2016-03-01 20:57:05 +00:00
|
|
|
|
|
|
|
for (auto it = shapes.cbegin(); it != shapes.cend(); ++it) {
|
|
|
|
if (next(it) == shapes.cend()) break;
|
|
|
|
logTimedEvent("shape", it->first, next(it)->first, shapeToString(it->second));
|
|
|
|
}
|
|
|
|
|
2015-11-20 21:20:19 +00:00
|
|
|
return shapes;
|
|
|
|
}
|