fn main() { let ctx = common::init("Cubeb tone example").expect("Failed to create cubeb context");
let params = cubeb::StreamParamsBuilder::new()
.format(STREAM_FORMAT)
.rate(SAMPLE_FREQUENCY)
.channels(1)
.layout(cubeb::ChannelLayout::MONO)
.take();
letmut position = 0u32;
letmut builder = cubeb::StreamBuilder::<Frame>::new();
builder
.name("Cubeb tone (mono)")
.default_output(¶ms)
.latency(0x1000)
.data_callback(move |_, output| { // generate our test tone on the fly for f in output.iter_mut() { // North American dial tone let t1 = (2.0 * PI * 350.0 * position as f32 / SAMPLE_FREQUENCY as f32).sin(); let t2 = (2.0 * PI * 440.0 * position as f32 / SAMPLE_FREQUENCY as f32).sin();
f.m = i16::from_float(0.5 * (t1 + t2));
position += 1;
}
output.len() as isize
})
.state_callback(|state| {
println!("stream {:?}", state);
});
let stream = builder.init(&ctx).expect("Failed to create cubeb stream");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.