pub struct StreamParamsBuilder(/* private fields */);Implementations§
Source§impl StreamParamsBuilder
impl StreamParamsBuilder
Sourcepub fn new() -> StreamParamsBuilder
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(¶ms)
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}Sourcepub fn format(self, format: SampleFormat) -> StreamParamsBuilder
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(¶ms)
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}Sourcepub fn rate(self, rate: u32) -> StreamParamsBuilder
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(¶ms)
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}Sourcepub fn channels(self, channels: u32) -> StreamParamsBuilder
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(¶ms)
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}Sourcepub fn layout(self, layout: ChannelLayout) -> StreamParamsBuilder
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(¶ms)
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}pub fn prefs(self, prefs: StreamPrefs) -> StreamParamsBuilder
pub fn input_params( self, input_params: InputProcessingParams, ) -> StreamParamsBuilder
Sourcepub fn take(&self) -> StreamParams
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(¶ms)
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
impl Debug for StreamParamsBuilder
Source§impl Default for StreamParamsBuilder
impl Default for StreamParamsBuilder
Source§fn default() -> StreamParamsBuilder
fn default() -> StreamParamsBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for StreamParamsBuilder
impl RefUnwindSafe for StreamParamsBuilder
impl Send for StreamParamsBuilder
impl Sync for StreamParamsBuilder
impl Unpin for StreamParamsBuilder
impl UnsafeUnpin for StreamParamsBuilder
impl UnwindSafe for StreamParamsBuilder
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