Enum screech::core::Signal [−][src]
Expand description
Most fundamental type for carrying signals throughout the library. Each component that has a sound source should be sampleable and be able to produce a Signal
Variants
Mono(Point)
Mono signal containing one stream
Tuple Fields of Mono
0: Point
Stereo signal containing two streams, left and right respectively
Implementations
Generate a silent signal
use screech::core::Signal;
assert_eq!(Signal::silence(), Signal::Mono(0.0));
Generate a mono signal from a point
use screech::core::Signal;
assert_eq!(Signal::point(0.0), Signal::Mono(0.0));
Generate a stereo signal from two points
use screech::core::Signal;
assert_eq!(Signal::points(0.1, 0.2), Signal::Stereo(0.1, 0.2));
Transform inner points, technically this is not a real map, since you can only manipulate the point to another point
use screech::core::Signal;
let mono = Signal::point(0.1).map(|p| p * 2.0);
let stereo = Signal::points(0.1, 0.2).map(|p| p * 2.0);
assert_eq!(mono, Signal::Mono(0.2));
assert_eq!(stereo, Signal::Stereo(0.2, 0.4));
Transform inner pointss for left and right channels individually. When given a mono channel it applies the transformation only to the left channel
use screech::core::Signal;
let signal = Signal::points(0.1, 0.2)
.map_stereo(|left| left * 2.0, |right| right / 2.0);
assert_eq!(signal, Signal::Stereo(0.2, 0.1));
Transform inner pointss for left and right channels individually. When given a mono channel it converts it to stereo by cloning left onto right
use screech::core::Signal;
let signal = Signal::point(0.2)
.map_to_stereo(|left, right| (left * 2.0, right / 2.0));
assert_eq!(signal, Signal::Stereo(0.4, 0.1));
Mix signals into existing signal
note on mono channels will sum the right channel to the left
use screech::core::Signal;
let signals = [
&Signal::point(0.1),
&Signal::points(0.4, 0.6),
];
let signal = Signal::point(0.4).mix_into(&signals);
assert_eq!(signal, Signal::Mono(1.0));
Mix signals together into a new signal, if only supplied mono signals it stays mono, otherwise it switches the signal to stereo putting mono signals across both channels
use screech::core::Signal;
let signal = Signal::mix(&[
&Signal::point(0.1),
&Signal::point(0.2),
&Signal::Stereo(0.3, 0.2),
]);
assert_eq!(signal, Signal::Stereo(0.6, 0.5))
match channels for current Signal based on passed Signal
using Signal::sum_to_mono
for stereo to mono conversion
use screech::core::Signal;
let mono_signal = Signal::silence();
let stereo_signal = Signal::silence().to_stereo();
assert_eq!(Signal::silence().match_channels(&mono_signal).is_mono(), true);
assert_eq!(Signal::silence().match_channels(&stereo_signal).is_stereo(), true);
Returns true if the enum instance is of Signal::Mono
type
use screech::core::Signal;
let mono_signal = Signal::silence();
let stereo_signal = Signal::silence().to_stereo();
assert_eq!(mono_signal.is_mono(), true);
assert_eq!(stereo_signal.is_mono(), false);
Returns true if the enum instance is of Signal::Stereo
type
use screech::core::Signal;
let mono_signal = Signal::silence();
let stereo_signal = Signal::silence().to_stereo();
assert_eq!(mono_signal.is_stereo(), false);
assert_eq!(stereo_signal.is_stereo(), true);
Convert a stereo point to mono by summing the left and right channel
use screech::traits::FromPoints;
use screech::core::{Signal, Stream};
let stereo_signal = Signal::Stereo(0.1, -0.1);
assert_eq!(
stereo_signal.sum_to_mono(),
Signal::Mono(0.0),
)
Convert a stereo point to mono by ditching the right channel
use screech::core::Signal;
let stereo_signal = Signal::points(0.1, 0.2);
assert_eq!(
stereo_signal.to_mono(),
Signal::Mono(0.1),
)
Convert a mono stream to stereo by cloning the signal to both channels
use screech::core::Signal;
let mono_signal = Signal::point(0.1);
assert_eq!(
mono_signal.to_stereo(),
Signal::Stereo(0.1, 0.1),
)
Get the inner point, or the left point if it is a stereo signal
Get the inner point if mono, and sum left and right together (after -3dB) for stereo signals
Get the inner right point if available
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Signal
impl UnwindSafe for Signal
Blanket Implementations
Mutably borrows from an owned value. Read more