Skip to main content

StreamParamsBuilder

Struct StreamParamsBuilder 

Source
pub struct StreamParamsBuilder(/* private fields */);

Implementations§

Source§

impl StreamParamsBuilder

Source

pub fn new() -> StreamParamsBuilder

Examples found in repository?
examples/tone.rs (line 24)
21fn main() {
22    let ctx = common::init("Cubeb tone example").expect("Failed to create cubeb context");
23
24    let params = cubeb::StreamParamsBuilder::new()
25        .format(STREAM_FORMAT)
26        .rate(SAMPLE_FREQUENCY)
27        .channels(1)
28        .layout(cubeb::ChannelLayout::MONO)
29        .take();
30
31    let mut position = 0u32;
32
33    let mut builder = cubeb::StreamBuilder::<Frame>::new();
34    builder
35        .name("Cubeb tone (mono)")
36        .default_output(&params)
37        .latency(0x1000)
38        .data_callback(move |_, output| {
39            // generate our test tone on the fly
40            for f in output.iter_mut() {
41                // North American dial tone
42                let t1 = (2.0 * PI * 350.0 * position as f32 / SAMPLE_FREQUENCY as f32).sin();
43                let t2 = (2.0 * PI * 440.0 * position as f32 / SAMPLE_FREQUENCY as f32).sin();
44
45                f.m = i16::from_float(0.5 * (t1 + t2));
46
47                position += 1;
48            }
49            output.len() as isize
50        })
51        .state_callback(|state| {
52            println!("stream {:?}", state);
53        });
54
55    let stream = builder.init(&ctx).expect("Failed to create cubeb stream");
56
57    stream.start().unwrap();
58    thread::sleep(Duration::from_millis(500));
59    stream.stop().unwrap();
60}
Source

pub fn format(self, format: SampleFormat) -> StreamParamsBuilder

Examples found in repository?
examples/tone.rs (line 25)
21fn main() {
22    let ctx = common::init("Cubeb tone example").expect("Failed to create cubeb context");
23
24    let params = cubeb::StreamParamsBuilder::new()
25        .format(STREAM_FORMAT)
26        .rate(SAMPLE_FREQUENCY)
27        .channels(1)
28        .layout(cubeb::ChannelLayout::MONO)
29        .take();
30
31    let mut position = 0u32;
32
33    let mut builder = cubeb::StreamBuilder::<Frame>::new();
34    builder
35        .name("Cubeb tone (mono)")
36        .default_output(&params)
37        .latency(0x1000)
38        .data_callback(move |_, output| {
39            // generate our test tone on the fly
40            for f in output.iter_mut() {
41                // North American dial tone
42                let t1 = (2.0 * PI * 350.0 * position as f32 / SAMPLE_FREQUENCY as f32).sin();
43                let t2 = (2.0 * PI * 440.0 * position as f32 / SAMPLE_FREQUENCY as f32).sin();
44
45                f.m = i16::from_float(0.5 * (t1 + t2));
46
47                position += 1;
48            }
49            output.len() as isize
50        })
51        .state_callback(|state| {
52            println!("stream {:?}", state);
53        });
54
55    let stream = builder.init(&ctx).expect("Failed to create cubeb stream");
56
57    stream.start().unwrap();
58    thread::sleep(Duration::from_millis(500));
59    stream.stop().unwrap();
60}
Source

pub fn rate(self, rate: u32) -> StreamParamsBuilder

Examples found in repository?
examples/tone.rs (line 26)
21fn main() {
22    let ctx = common::init("Cubeb tone example").expect("Failed to create cubeb context");
23
24    let params = cubeb::StreamParamsBuilder::new()
25        .format(STREAM_FORMAT)
26        .rate(SAMPLE_FREQUENCY)
27        .channels(1)
28        .layout(cubeb::ChannelLayout::MONO)
29        .take();
30
31    let mut position = 0u32;
32
33    let mut builder = cubeb::StreamBuilder::<Frame>::new();
34    builder
35        .name("Cubeb tone (mono)")
36        .default_output(&params)
37        .latency(0x1000)
38        .data_callback(move |_, output| {
39            // generate our test tone on the fly
40            for f in output.iter_mut() {
41                // North American dial tone
42                let t1 = (2.0 * PI * 350.0 * position as f32 / SAMPLE_FREQUENCY as f32).sin();
43                let t2 = (2.0 * PI * 440.0 * position as f32 / SAMPLE_FREQUENCY as f32).sin();
44
45                f.m = i16::from_float(0.5 * (t1 + t2));
46
47                position += 1;
48            }
49            output.len() as isize
50        })
51        .state_callback(|state| {
52            println!("stream {:?}", state);
53        });
54
55    let stream = builder.init(&ctx).expect("Failed to create cubeb stream");
56
57    stream.start().unwrap();
58    thread::sleep(Duration::from_millis(500));
59    stream.stop().unwrap();
60}
Source

pub fn channels(self, channels: u32) -> StreamParamsBuilder

Examples found in repository?
examples/tone.rs (line 27)
21fn main() {
22    let ctx = common::init("Cubeb tone example").expect("Failed to create cubeb context");
23
24    let params = cubeb::StreamParamsBuilder::new()
25        .format(STREAM_FORMAT)
26        .rate(SAMPLE_FREQUENCY)
27        .channels(1)
28        .layout(cubeb::ChannelLayout::MONO)
29        .take();
30
31    let mut position = 0u32;
32
33    let mut builder = cubeb::StreamBuilder::<Frame>::new();
34    builder
35        .name("Cubeb tone (mono)")
36        .default_output(&params)
37        .latency(0x1000)
38        .data_callback(move |_, output| {
39            // generate our test tone on the fly
40            for f in output.iter_mut() {
41                // North American dial tone
42                let t1 = (2.0 * PI * 350.0 * position as f32 / SAMPLE_FREQUENCY as f32).sin();
43                let t2 = (2.0 * PI * 440.0 * position as f32 / SAMPLE_FREQUENCY as f32).sin();
44
45                f.m = i16::from_float(0.5 * (t1 + t2));
46
47                position += 1;
48            }
49            output.len() as isize
50        })
51        .state_callback(|state| {
52            println!("stream {:?}", state);
53        });
54
55    let stream = builder.init(&ctx).expect("Failed to create cubeb stream");
56
57    stream.start().unwrap();
58    thread::sleep(Duration::from_millis(500));
59    stream.stop().unwrap();
60}
Source

pub fn layout(self, layout: ChannelLayout) -> StreamParamsBuilder

Examples found in repository?
examples/tone.rs (line 28)
21fn main() {
22    let ctx = common::init("Cubeb tone example").expect("Failed to create cubeb context");
23
24    let params = cubeb::StreamParamsBuilder::new()
25        .format(STREAM_FORMAT)
26        .rate(SAMPLE_FREQUENCY)
27        .channels(1)
28        .layout(cubeb::ChannelLayout::MONO)
29        .take();
30
31    let mut position = 0u32;
32
33    let mut builder = cubeb::StreamBuilder::<Frame>::new();
34    builder
35        .name("Cubeb tone (mono)")
36        .default_output(&params)
37        .latency(0x1000)
38        .data_callback(move |_, output| {
39            // generate our test tone on the fly
40            for f in output.iter_mut() {
41                // North American dial tone
42                let t1 = (2.0 * PI * 350.0 * position as f32 / SAMPLE_FREQUENCY as f32).sin();
43                let t2 = (2.0 * PI * 440.0 * position as f32 / SAMPLE_FREQUENCY as f32).sin();
44
45                f.m = i16::from_float(0.5 * (t1 + t2));
46
47                position += 1;
48            }
49            output.len() as isize
50        })
51        .state_callback(|state| {
52            println!("stream {:?}", state);
53        });
54
55    let stream = builder.init(&ctx).expect("Failed to create cubeb stream");
56
57    stream.start().unwrap();
58    thread::sleep(Duration::from_millis(500));
59    stream.stop().unwrap();
60}
Source

pub fn prefs(self, prefs: StreamPrefs) -> StreamParamsBuilder

Source

pub fn input_params( self, input_params: InputProcessingParams, ) -> StreamParamsBuilder

Source

pub fn take(&self) -> StreamParams

Examples found in repository?
examples/tone.rs (line 29)
21fn main() {
22    let ctx = common::init("Cubeb tone example").expect("Failed to create cubeb context");
23
24    let params = cubeb::StreamParamsBuilder::new()
25        .format(STREAM_FORMAT)
26        .rate(SAMPLE_FREQUENCY)
27        .channels(1)
28        .layout(cubeb::ChannelLayout::MONO)
29        .take();
30
31    let mut position = 0u32;
32
33    let mut builder = cubeb::StreamBuilder::<Frame>::new();
34    builder
35        .name("Cubeb tone (mono)")
36        .default_output(&params)
37        .latency(0x1000)
38        .data_callback(move |_, output| {
39            // generate our test tone on the fly
40            for f in output.iter_mut() {
41                // North American dial tone
42                let t1 = (2.0 * PI * 350.0 * position as f32 / SAMPLE_FREQUENCY as f32).sin();
43                let t2 = (2.0 * PI * 440.0 * position as f32 / SAMPLE_FREQUENCY as f32).sin();
44
45                f.m = i16::from_float(0.5 * (t1 + t2));
46
47                position += 1;
48            }
49            output.len() as isize
50        })
51        .state_callback(|state| {
52            println!("stream {:?}", state);
53        });
54
55    let stream = builder.init(&ctx).expect("Failed to create cubeb stream");
56
57    stream.start().unwrap();
58    thread::sleep(Duration::from_millis(500));
59    stream.stop().unwrap();
60}

Trait Implementations§

Source§

impl Debug for StreamParamsBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for StreamParamsBuilder

Source§

fn default() -> StreamParamsBuilder

Returns the “default value” for a type. Read more

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<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, 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.