SampleProcessor

Struct SampleProcessor 

Source
pub struct SampleProcessor { /* private fields */ }
Expand description

Prepares the samples of the fetcher for the crate::BarProcessor.

Implementations§

Source§

impl SampleProcessor

Source

pub fn new(fetcher: Box<dyn Fetcher>) -> Self

Creates a new instance with the given fetcher where the audio samples are fetched from.

Examples found in repository?
examples/simple.rs (line 4)
3fn main() {
4    let mut sample_processor = SampleProcessor::new(DummyFetcher::new(2));
5    sample_processor.process_next_samples();
6
7    let mut bar_processor = BarProcessor::new(&sample_processor, BarProcessorConfig::default());
8    bar_processor.process_bars(&sample_processor);
9}
More examples
Hide additional examples
examples/default_system_fetcher.rs (line 10)
6fn main() {
7    // Choose default settings
8    let descriptor = SystemAudioFetcherDescriptor::default();
9
10    let mut processor = SampleProcessor::new(SystemAudioFetcher::new(&descriptor).unwrap());
11    let mut bar_processor = BarProcessor::new(&processor, BarProcessorConfig::default());
12
13    // simply fetch
14    processor.process_next_samples();
15    bar_processor.process_bars(&processor);
16}
examples/custom_system_fetcher.rs (line 27)
7fn main() {
8    // get a list of all available devices
9    let available_output_devices = shady_audio::util::get_device_names(DeviceType::Output)
10        .expect("Output devices exists for the given host");
11
12    println!("{:#?}", available_output_devices);
13
14    // choose one
15    let device = shady_audio::util::get_device(
16        available_output_devices.first().unwrap(),
17        DeviceType::Output,
18    )
19    .unwrap()
20    .unwrap();
21
22    let descriptor = SystemAudioFetcherDescriptor {
23        device,
24        ..Default::default()
25    };
26
27    let mut sample_processor = SampleProcessor::new(SystemAudioFetcher::new(&descriptor).unwrap());
28    let mut bar_processor = BarProcessor::new(&sample_processor, BarProcessorConfig::default());
29
30    // start creating the bars
31    sample_processor.process_next_samples();
32    bar_processor.process_bars(&sample_processor);
33}
Source

pub fn process_next_samples(&mut self)

Tell the processor to take some samples of the fetcher and prepare them for the crate::BarProcessors.

Examples found in repository?
examples/simple.rs (line 5)
3fn main() {
4    let mut sample_processor = SampleProcessor::new(DummyFetcher::new(2));
5    sample_processor.process_next_samples();
6
7    let mut bar_processor = BarProcessor::new(&sample_processor, BarProcessorConfig::default());
8    bar_processor.process_bars(&sample_processor);
9}
More examples
Hide additional examples
examples/default_system_fetcher.rs (line 14)
6fn main() {
7    // Choose default settings
8    let descriptor = SystemAudioFetcherDescriptor::default();
9
10    let mut processor = SampleProcessor::new(SystemAudioFetcher::new(&descriptor).unwrap());
11    let mut bar_processor = BarProcessor::new(&processor, BarProcessorConfig::default());
12
13    // simply fetch
14    processor.process_next_samples();
15    bar_processor.process_bars(&processor);
16}
examples/custom_system_fetcher.rs (line 31)
7fn main() {
8    // get a list of all available devices
9    let available_output_devices = shady_audio::util::get_device_names(DeviceType::Output)
10        .expect("Output devices exists for the given host");
11
12    println!("{:#?}", available_output_devices);
13
14    // choose one
15    let device = shady_audio::util::get_device(
16        available_output_devices.first().unwrap(),
17        DeviceType::Output,
18    )
19    .unwrap()
20    .unwrap();
21
22    let descriptor = SystemAudioFetcherDescriptor {
23        device,
24        ..Default::default()
25    };
26
27    let mut sample_processor = SampleProcessor::new(SystemAudioFetcher::new(&descriptor).unwrap());
28    let mut bar_processor = BarProcessor::new(&sample_processor, BarProcessorConfig::default());
29
30    // start creating the bars
31    sample_processor.process_next_samples();
32    bar_processor.process_bars(&sample_processor);
33}

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,