mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implement rate control
This commit is contained in:
parent
96de7a653d
commit
ae3c33ec8c
@ -442,12 +442,27 @@ class Synthesizer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double volume() const { return synth.Options().AudioVolume(); }
|
double volume() const {
|
||||||
|
return synth.Options().AudioVolume();
|
||||||
|
}
|
||||||
|
|
||||||
void volume(double val) {
|
void volume(double val) {
|
||||||
if (val < 0 || val > 1) throw std::out_of_range("Invalid volume value must be between 0 and 1");
|
if (val < 0 || val > 1) throw std::out_of_range("Invalid volume value must be between 0 and 1");
|
||||||
|
std::scoped_lock sl(recursive_lock);
|
||||||
synth.Options().AudioVolume(val);
|
synth.Options().AudioVolume(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double rate() const {
|
||||||
|
return synth.Options().SpeakingRate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void rate(double val) {
|
||||||
|
if (val < 0.5 || val > 6.0) throw std::out_of_range("Invalid rate value must be between 0.5 and 6");
|
||||||
|
std::scoped_lock sl(recursive_lock);
|
||||||
|
synth.Options().SpeakingRate(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static Synthesizer sx;
|
static Synthesizer sx;
|
||||||
@ -789,6 +804,13 @@ handle_stdin_message(winrt::hstring const &&msg) {
|
|||||||
}
|
}
|
||||||
output(cmd_id, "volume", {{"value", sx.volume()}});
|
output(cmd_id, "volume", {{"value", sx.volume()}});
|
||||||
}
|
}
|
||||||
|
else if (command == L"rate") {
|
||||||
|
if (parts.size()) {
|
||||||
|
auto rate = parse_double(parts[0].data());
|
||||||
|
sx.rate(rate);
|
||||||
|
}
|
||||||
|
output(cmd_id, "rate", {{"value", sx.rate()}});
|
||||||
|
}
|
||||||
else if (command == L"save") {
|
else if (command == L"save") {
|
||||||
handle_save(cmd_id, parts);
|
handle_save(cmd_id, parts);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user