mirror of
https://github.com/lightsoutgames/godot-tts
synced 2024-11-23 13:05:57 +00:00
Add Rust implementation of volume
This commit is contained in:
parent
8d95b3b5de
commit
2537d27886
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,5 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
64
src/lib.rs
64
src/lib.rs
|
@ -61,6 +61,70 @@ impl TTS {
|
|||
}
|
||||
|
||||
fn register(builder: &ClassBuilder<Self>) {
|
||||
builder
|
||||
.add_property("volume")
|
||||
.with_getter(|this: &TTS, _| match this.0.get_volume() {
|
||||
Ok(volume) => volume,
|
||||
_ => 0.,
|
||||
})
|
||||
.with_setter(|this: &mut TTS, _, v: f32| {
|
||||
let Features {
|
||||
volume: volume_supported,
|
||||
..
|
||||
} = this.0.supported_features();
|
||||
if volume_supported {
|
||||
let mut v = v;
|
||||
if v < this.0.min_volume() {
|
||||
v = this.0.min_volume();
|
||||
} else if v > this.0.max_volume() {
|
||||
v = this.0.max_volume();
|
||||
}
|
||||
this.0.set_volume(v).expect("Failed to set volume");
|
||||
}
|
||||
})
|
||||
.done();
|
||||
builder
|
||||
.add_property("min_volume")
|
||||
.with_getter(|this: &TTS, _| {
|
||||
let Features {
|
||||
volume: volume_supported,
|
||||
..
|
||||
} = this.0.supported_features();
|
||||
if volume_supported {
|
||||
this.0.min_volume()
|
||||
} else {
|
||||
0.
|
||||
}
|
||||
})
|
||||
.done();
|
||||
builder
|
||||
.add_property("max_volume")
|
||||
.with_getter(|this: &TTS, _| {
|
||||
let Features {
|
||||
volume: volume_supported,
|
||||
..
|
||||
} = this.0.supported_features();
|
||||
if volume_supported {
|
||||
this.0.max_volume()
|
||||
} else {
|
||||
0.
|
||||
}
|
||||
})
|
||||
.done();
|
||||
builder
|
||||
.add_property("normal_volume")
|
||||
.with_getter(|this: &TTS, _| {
|
||||
let Features {
|
||||
volume: volume_supported,
|
||||
..
|
||||
} = this.0.supported_features();
|
||||
if volume_supported {
|
||||
this.0.normal_volume()
|
||||
} else {
|
||||
0.
|
||||
}
|
||||
})
|
||||
.done();
|
||||
builder
|
||||
.add_property("rate")
|
||||
.with_getter(|this: &TTS, _| match this.0.get_rate() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user