Skip to main content

sim_lib_stream_file/
lib.rs

1#![forbid(unsafe_code)]
2#![deny(missing_docs)]
3//! File-backed source and sink adapters for STREAM 6.
4//!
5//! The crate keeps host filesystem access behind explicit stream file
6//! capabilities: reads require `fs/read`, writes require `fs/write`, and
7//! compatibility `stream.file.*` aliases are accepted by the gates. Each read or
8//! write is recorded as a KERNEL 6 filesystem effect. SMF support reuses the
9//! in-tree MIDI file codec; WAV support is limited to canonical little-endian
10//! PCM16 RIFF/WAVE because that is the PCM packet format implemented by the
11//! stream audio layer. Bounded float-to-PCM16 conversion, finite channel
12//! matrices, seeded TPDF/noise-shaped dither, and their clipping reports live
13//! here beside that canonical WAV owner rather than in analysis or devices.
14
15mod cap;
16mod cassette;
17mod effect_io;
18mod midi;
19mod pcm_convert;
20mod wav;
21
22pub use cap::{stream_file_read_capability, stream_file_write_capability};
23pub use cassette::{
24    cassette_expr_to_stream, cassette_to_stream, stream_to_cassette, stream_to_cassette_expr,
25    validate_cassette_fixture_path,
26};
27pub use midi::{
28    read_smf_stream, smf_bytes_to_stream, smf_file_to_stream, stream_to_smf_bytes,
29    stream_to_smf_file, write_smf_stream,
30};
31pub use pcm_convert::{
32    ChannelMatrix, DitherPolicy, Pcm16Conversion, PcmConversionError, PcmConversionReport,
33    QuantizationPolicy, convert_f32_to_pcm16,
34};
35pub use wav::{
36    WavStream, convert_f32_to_wav_bytes, pcm_buffers_to_wav_bytes, pcm16_samples_to_wav_bytes,
37    read_wav_stream, stream_to_wav_bytes, wav_bytes_to_stream, write_wav_stream,
38};
39
40/// Cookbook recipes for this lib, embedded at build time.
41pub static RECIPES: sim_cookbook::EmbeddedDir =
42    include!(concat!(env!("OUT_DIR"), "/cookbook_recipes.rs"));
43
44#[cfg(test)]
45mod tests;