pub struct BarProcessor { /* private fields */ }Expand description
The struct which computates the bar values of the samples of the fetcher.
Implementations§
Source§impl BarProcessor
impl BarProcessor
Sourcepub fn new(processor: &SampleProcessor, config: BarProcessorConfig) -> Self
pub fn new(processor: &SampleProcessor, config: BarProcessorConfig) -> Self
Creates a new instance.
See the examples of this crate to see it’s usage.
Examples found in repository?
More examples
examples/custom_system_fetcher.rs (line 28)
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}Sourcepub fn process_bars(&mut self, processor: &SampleProcessor) -> &[Box<[f32]>]
pub fn process_bars(&mut self, processor: &SampleProcessor) -> &[Box<[f32]>]
Returns the bar values for each channel.
If you access the returned value like this: bar_processor.process_bars(&processor)[i][j] then this would mean:
You are accessing the jth bar value of the ith audio channel.
Examples found in repository?
More examples
examples/custom_system_fetcher.rs (line 32)
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}pub fn config(&self) -> &BarProcessorConfig
Sourcepub fn set_amount_bars(&mut self, amount_bars: NonZero<u16>)
pub fn set_amount_bars(&mut self, amount_bars: NonZero<u16>)
Change the amount of bars which should be returned.
§Example
use shady_audio::{SampleProcessor, BarProcessor, BarProcessorConfig, fetcher::DummyFetcher};
let mut sample_processor = SampleProcessor::new(DummyFetcher::new(1));
let mut bar_processor = BarProcessor::new(
&sample_processor,
BarProcessorConfig {
amount_bars: std::num::NonZero::new(10).unwrap(),
..Default::default()
}
);
sample_processor.process_next_samples();
let bars = bar_processor.process_bars(&sample_processor);
// the dummy just has one channel
assert_eq!(bars.len(), 1);
// but it should have ten bars
assert_eq!(bars[0].len(), 10);
// change the amount of bars
bar_processor.set_amount_bars(std::num::NonZero::new(20).unwrap());
let bars = bar_processor.process_bars(&sample_processor);
assert_eq!(bars.len(), 1);
assert_eq!(bars[0].len(), 20);Auto Trait Implementations§
impl Freeze for BarProcessor
impl !RefUnwindSafe for BarProcessor
impl !Send for BarProcessor
impl !Sync for BarProcessor
impl Unpin for BarProcessor
impl !UnwindSafe for BarProcessor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.