Registry / Framework

framework · v0.1.2
Audio Preroll
Prime a playback buffer and recover from underrun without emitting premature play commands.
Use Audio Preroll
use vendor::audio_preroll::audio_preroll;
Run the example
nest demo audio_preroll@0.1.2
blyxc native-run audio_preroll-demo/main.blyx
Example source and expected output
use std::cli;
use std::text;
use vendor::audio_preroll::audio_preroll;
fn main() {
let arguments = cli_args();
if args_len(arguments) > 0 {
if args_len(arguments) % 2 != 0 {
stderr_line("Expected event and value pairs");
process_exit(2);
}
let mut live = audio_preroll_start();
let mut i = 0;
while i < args_len(arguments) {
let input = args_at(arguments, i + 1);
if !text_is_number(input) {
stderr_line("Expected a whole numeric event value");
process_exit(2);
}
live = audio_preroll_step(live, args_at(arguments, i), text_number(input));
let command = audio_preroll_command(live);
println!(command);
if command == "reject" { process_exit(1); }
i += 2;
}
return;
}
let mut state = audio_preroll_start();
state = audio_preroll_step(state, "prime", 8.0);
println!(audio_preroll_command(state));
state = audio_preroll_step(state, "fill", 3.0);
println!(audio_preroll_command(state));
state = audio_preroll_step(state, "fill", 5.0);
println!(audio_preroll_command(state));
state = audio_preroll_step(state, "underrun", 2.0);
println!(audio_preroll_command(state));
state = audio_preroll_step(state, "fill", 4.0);
println!(audio_preroll_command(state));
state = audio_preroll_step(state, "stop", 0.0);
println!(audio_preroll_command(state));
}
Expected output
request_frames
accept_frames
start_audio
pause_and_refill
start_audio
release_device
Published versions
| Version | Package | Source commit | SHA-256 |
|---|---|---|---|
| 0.1.2 | Download ZIP · Browse files | 5e84cd2fbc | 6f6a9b142390504b2b8881ef885288e9fb3b15ea7c08181c60b4a69ca11bb105 |
| 0.1.1 | Download ZIP · Browse files | ce3273484d | b3e17ac87a1e132520cf9d2b1c2f15d4d0bca7e7ae6a4e43c108c6f930279ea3 |
| 0.1.0 | Download ZIP · Browse files | 6349f23784 | 744c26793580342f69e1e7399e47358d01806876462ff36e20d6ae5bfe2bf676 |