Implement control for pitch

This commit is contained in:
Kovid Goyal 2023-01-28 14:07:46 +05:30
parent 9dd2b16fe9
commit 356af928ac
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -460,6 +460,16 @@ class Synthesizer {
synth.Options().SpeakingRate(val); synth.Options().SpeakingRate(val);
} }
double pitch() const {
return synth.Options().AudioPitch();
}
void pitch(double val) {
if (val < 0 || val > 2) throw std::out_of_range("Invalid pitch value must be between 0 and 2");
std::scoped_lock sl(recursive_lock);
synth.Options().AudioPitch(val);
}
}; };
@ -811,6 +821,13 @@ handle_stdin_message(winrt::hstring const &&msg) {
} }
output(cmd_id, "rate", {{"value", sx.rate()}}); output(cmd_id, "rate", {{"value", sx.rate()}});
} }
else if (command == L"pitch") {
if (parts.size()) {
auto rate = parse_double(parts[0].data());
sx.rate(rate);
}
output(cmd_id, "pitch", {{"pitch", sx.rate()}});
}
else if (command == L"save") { else if (command == L"save") {
handle_save(cmd_id, parts); handle_save(cmd_id, parts);
} }