populate examples; update rodio version

This commit is contained in:
2021-11-27 11:41:32 +00:00
parent cd72d9d66d
commit 4734ae81f8
9 changed files with 638 additions and 54 deletions

Binary file not shown.

17
examples/from_bytes.rs Normal file
View File

@@ -0,0 +1,17 @@
use rodio::{OutputStream, Sink};
use rodio_xm::XMSource;
fn main() {
let source = XMSource::from_bytes(
include_bytes!("drozerix_-_chica-pop!.xm"),
44100
);
let (_stream, stream_handle) = OutputStream::try_default().unwrap();
let sink = Sink::try_new(&stream_handle).unwrap();
sink.append(source);
sink.play();
loop {}
}

19
examples/from_file.rs Normal file
View File

@@ -0,0 +1,19 @@
use std::path::PathBuf;
use rodio::{OutputStream, Sink};
use rodio_xm::XMSource;
fn main() {
let source = XMSource::from_file(
PathBuf::from("examples/drozerix_-_chica-pop!.xm"),
44100
);
let (_stream, stream_handle) = OutputStream::try_default().unwrap();
let sink = Sink::try_new(&stream_handle).unwrap();
sink.append(source);
sink.play();
loop {}
}

View File

@@ -0,0 +1,22 @@
use libxm::XMContext;
use rodio::{OutputStream, Sink};
use rodio_xm::XMSource;
const SAMPLE_RATE: u32 = 44100;
fn main() {
let xm_context = XMContext::new(
include_bytes!("drozerix_-_chica-pop!.xm"),
SAMPLE_RATE
).expect("Couldn't build XM context");
let source = XMSource::new(xm_context, SAMPLE_RATE);
let (_stream, stream_handle) = OutputStream::try_default().unwrap();
let sink = Sink::try_new(&stream_handle).unwrap();
sink.append(source);
sink.play();
loop {}
}