1use crate::Decodable;
2use bevy_asset::Asset;
3use bevy_reflect::TypePath;
4use rodio::{
5 source::{SineWave, TakeDuration},
6 Source,
7};
8
9#[derive(impl bevy_asset::Asset for Pitch {}
impl bevy_asset::VisitAssetDependencies for Pitch {
fn visit_dependencies(&self,
visit: &mut impl ::core::ops::FnMut(bevy_asset::UntypedAssetId)) {}
}Asset, #[automatically_derived]impl ::core::fmt::Debug for Pitch {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "Pitch",
"frequency", &self.frequency, "duration", &&self.duration)
}
}Debug, #[automatically_derived]impl ::core::clone::Clone for Pitch {
#[inline]
fn clone(&self) -> Self {
Pitch {
frequency: ::core::clone::Clone::clone(&self.frequency),
duration: ::core::clone::Clone::clone(&self.duration),
}
}
}Clone, const _: () =
{
#[allow(deprecated, reason =
"derives on a deprecated type shouldn't be considered a usage")]
impl bevy_reflect::TypePath for Pitch where {
fn type_path() -> &'static str { "bevy_audio::pitch::Pitch" }
fn short_type_path() -> &'static str { "Pitch" }
fn type_ident() -> ::core::option::Option<&'static str> {
::core::option::Option::Some("Pitch")
}
fn crate_name() -> ::core::option::Option<&'static str> {
::core::option::Option::Some("bevy_audio::pitch".split(':').next().unwrap())
}
fn module_path() -> ::core::option::Option<&'static str> {
::core::option::Option::Some("bevy_audio::pitch")
}
}
};TypePath)]
11pub struct Pitch {
12 pub frequency: f32,
14 pub duration: core::time::Duration,
16}
17
18impl Pitch {
19 pub fn new(frequency: f32, duration: core::time::Duration) -> Self {
21 Pitch {
22 frequency,
23 duration,
24 }
25 }
26}
27
28impl Decodable for Pitch {
29 type Decoder = TakeDuration<SineWave>;
30
31 fn decoder(&self) -> Self::Decoder {
32 SineWave::new(self.frequency).take_duration(self.duration)
33 }
34}