Skip to content

Commit

Permalink
small language tweaks to speed docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdsk committed Oct 10, 2024
1 parent d1bd852 commit a7f67b3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 17 deletions.
16 changes: 13 additions & 3 deletions src/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,20 @@ impl Sink {
*self.controls.volume.lock().unwrap() = value;
}

/// Gets the speed of the sound.
/// Changes the play speed of the sound. Does not adjust the samples, only the playback speed.
///
/// The value `1.0` is the "normal" speed (unfiltered input). Any value other than `1.0` will
/// change the play speed of the sound.
/// # Note:
/// 1. **Increasing the speed will increase the pitch by the same factor**
/// - If you set the speed to 0.5 this will halve the frequency of the sound
/// lowering its pitch.
/// - If you set the speed to 2 the frequency will double raising the
/// pitch of the sound.
/// 2. **Change in the speed affect the total duration inversely**
/// - If you set the speed to 0.5, the total duration will be twice as long.
/// - If you set the speed to 2 the total duration will be halve of what it
/// was.
///
/// See [`Speed`] for details
#[inline]
pub fn speed(&self) -> f32 {
*self.controls.speed.lock().unwrap()
Expand Down
22 changes: 12 additions & 10 deletions src/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,16 +411,18 @@ where
periodic::periodic(self, period, access)
}

/// Changes the play speed of the sound. Does not adjust the samples, only the play speed.
///
/// Creates a [`Speed`] struct that handles the speed control
/// #### Note:
/// 1. **Increasing the speed would also increase the pitch by the same factor**
/// - If you increased set the speed to 0.5, the frequency would be slower (0.5x the original frequency) .
/// - Also if you set the speed to 1.5 the frequency would be faster ( 1.5x the original frequency).
/// 2. **Change in the speed would affect your total duration inversely**
/// - if you set the speed by 0.5, your total duration would be (2x the original total duration) longer.
/// - Also if you set the speed to 2 the total duration would be (0.5 the original total_duration) shorter
/// Changes the play speed of the sound. Does not adjust the samples, only the playback speed.
///
/// # Note:
/// 1. **Increasing the speed will increase the pitch by the same factor**
/// - If you set the speed to 0.5 this will halve the frequency of the sound
/// lowering its pitch.
/// - If you set the speed to 2 the frequency will double raising the
/// pitch of the sound.
/// 2. **Change in the speed affect the total duration inversely**
/// - If you set the speed to 0.5, the total duration will be twice as long.
/// - If you set the speed to 2 the total duration will be halve of what it
/// was.
///
/// See [`Speed`] for details
#[inline]
Expand Down
18 changes: 14 additions & 4 deletions src/spatial_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,20 @@ impl SpatialSink {
self.sink.set_volume(value);
}

/// Gets the speed of the sound.
///
/// The value `1.0` is the "normal" speed (unfiltered input). Any value other than `1.0` will
/// change the play speed of the sound.
/// Changes the play speed of the sound. Does not adjust the samples, only the playback speed.
///
/// # Note:
/// 1. **Increasing the speed will increase the pitch by the same factor**
/// - If you set the speed to 0.5 this will halve the frequency of the sound
/// lowering its pitch.
/// - If you set the speed to 2 the frequency will double raising the
/// pitch of the sound.
/// 2. **Change in the speed affect the total duration inversely**
/// - If you set the speed to 0.5, the total duration will be twice as long.
/// - If you set the speed to 2 the total duration will be halve of what it
/// was.
///
/// See [`Speed`] for details
#[inline]
pub fn speed(&self) -> f32 {
self.sink.speed()
Expand Down

0 comments on commit a7f67b3

Please sign in to comment.