### Install flacenc-bin (Nightly Rust) Source: https://github.com/yotarok/flacenc-rs/blob/main/flacenc-bin/README.md Installs the flacenc-bin CLI tool using the nightly Rust toolchain with the 'simd-nightly' feature for optimized performance. ```bash cargo +nightly install flacenc-bin --features "simd-nightly" ``` -------------------------------- ### Install flacenc-bin (Stable Rust) Source: https://github.com/yotarok/flacenc-rs/blob/main/flacenc-bin/README.md Installs the flacenc-bin CLI tool using the stable Rust toolchain. ```bash cargo install flacenc-bin ``` -------------------------------- ### Encode WAV to FLAC Source: https://github.com/yotarok/flacenc-rs/blob/main/flacenc-bin/README.md Encodes an input WAV file to FLAC format using the flacenc CLI. ```bash flacenc --output output.flac input.wav ``` -------------------------------- ### Generate Default Config File Source: https://github.com/yotarok/flacenc-rs/blob/main/flacenc-bin/README.md Generates a default configuration file (`config.toml`) for the flacenc encoder. ```bash flacenc --output output.flac --dump-config config.toml input.wav ``` -------------------------------- ### Decode FLAC to WAV Source: https://github.com/yotarok/flacenc-rs/blob/main/flacenc-bin/README.md Decodes a FLAC file to a WAV file using the experimental decoder mode of the flacenc CLI. ```bash flacenc decode --output output.wav input.flac ``` -------------------------------- ### Encode WAV to FLAC with Custom Config Source: https://github.com/yotarok/flacenc-rs/blob/main/flacenc-bin/README.md Encodes an input WAV file to FLAC format using a customized configuration file. ```bash flacenc --output output.flac --config config.toml input.wav ``` -------------------------------- ### Basic FLAC Encoding Example Source: https://github.com/yotarok/flacenc-rs/blob/main/README.md Demonstrates the simplest way to perform FLAC encoding using recorded samples stored in a slice of i32. It configures the encoder, creates a source from memory, encodes with a fixed block size, and writes the output to a byte sink. ```rust use flacenc::component::BitRepr; use flacenc::error::Verify; let samples: &[i32] = &[0i32; 4096]; // replace this with real samples. let (channels, bits_per_sample, sample_rate) = (2, 16, 44100); let config = flacenc::config::Encoder::default().into_verified().expect( "Config data error." ); let source = flacenc::source::MemSource::from_samples( samples, channels, bits_per_sample, sample_rate); let flac_stream = flacenc::encode_with_fixed_block_size( &config, source, config.block_size ).expect("Encode failed."); // `Stream` implements `BitRepr` so you can obtain the encoded stream via // `ByteSink` struct that implements `BitSink`. let mut sink = flacenc::bitsink::ByteSink::new(); flac_stream.write(&mut sink); // Then, e.g. you can write it to a file. std::fs::write("/dev/null", sink.as_slice()); // or you can write only a specific frame. let mut sink = flacenc::bitsink::ByteSink::new(); flac_stream.frame(0).unwrap().write(&mut sink); ``` -------------------------------- ### Rust Cargo Feature: simd-nightly Source: https://github.com/yotarok/flacenc-rs/blob/main/README.md Activates the 'portable-simd' feature of a Rust nightly toolchain for actual SIMD processing, replacing the default fake implementation. This feature is used in benchmarking scripts but not enabled by default in the example encoder. ```rust [features] simd-nightly = ["portable-simd"] ``` -------------------------------- ### Rust Cargo Feature: experimental Source: https://github.com/yotarok/flacenc-rs/blob/main/README.md Activates experimental coding algorithms that are typically slower. Specific activation details for these algorithms are not documented and may require exploring the 'flacenc::config' module or source code. ```rust [features] experimental = [] ``` -------------------------------- ### flacenc API: Encoder Configuration Source: https://github.com/yotarok/flacenc-rs/blob/main/README.md Provides details on the Encoder struct within the flacenc::config module. This struct is used to configure the FLAC encoder, allowing for customization of encoding parameters. Specific fields and their types would be detailed in the linked documentation. ```APIDOC flacenc::config::Encoder - Represents the configuration for the FLAC encoder. - Used to specify parameters for audio encoding. - Related to: `flacenc::config::Encoder::new()` - See also: [`flacenc::config::Encoder`](https://docs.rs/flacenc/latest/flacenc/config/struct.Encoder.html) ``` -------------------------------- ### flacenc API: Component Module Source: https://github.com/yotarok/flacenc-rs/blob/main/README.md References the component module in flacenc, which likely contains core data structures and types related to FLAC audio components. This module is crucial for understanding the internal representation of FLAC data. ```APIDOC flacenc::component - Module containing core FLAC data structures and types. - Includes definitions for audio samples, frames, and metadata. - See also: [`flacenc::component`](https://docs.rs/flacenc/latest/flacenc/component/index.html) ``` -------------------------------- ### Add flacenc to Cargo.toml (Nightly SIMD) Source: https://github.com/yotarok/flacenc-rs/blob/main/README.md Includes the flacenc crate with the 'simd-nightly' feature enabled in Cargo.toml. This allows the use of portable SIMD instructions for potential performance improvements, requiring a nightly Rust toolchain. ```toml flacenc = { version = "0.5.0", features = ["simd-nightly"] } ``` -------------------------------- ### flacenc API: Source Trait Source: https://github.com/yotarok/flacenc-rs/blob/main/README.md Defines the Source trait in the flacenc::source module. This trait is fundamental for providing audio data to the encoder, abstracting different input sources. Implementations of this trait handle reading audio samples. ```APIDOC flacenc::source::Source - Trait for audio data sources. - Defines methods for reading audio samples and metadata. - Essential for providing input to the encoder. - See also: [`flacenc::source::Source`](https://docs.rs/flacenc/latest/flacenc/source/trait.Source.html) ``` -------------------------------- ### Add flacenc to Cargo.toml (Stable) Source: https://github.com/yotarok/flacenc-rs/blob/main/README.md Specifies the dependency for the flacenc crate in a Rust project's Cargo.toml file for stable toolchains. This is the standard way to include the library. ```toml flacenc = "0.5.0" ``` -------------------------------- ### Rust Cargo Feature: log Source: https://github.com/yotarok/flacenc-rs/blob/main/README.md Enables logging capabilities, allowing applications to handle logs by linking a log-handler crate like 'env_logger'. The computational cost of this feature is considered negligible as logging is not performed in performance-critical code paths. This feature is enabled by default. ```rust [features] log = ["env_logger"] ``` -------------------------------- ### Rust Cargo Feature: serde Source: https://github.com/yotarok/flacenc-rs/blob/main/README.md Makes FLAC component datatypes serializable and deserializable, which is useful for analyzing FLAC streams. This feature enables integration with serialization frameworks. ```rust [features] serde = ["serde"] ``` -------------------------------- ### Rust Cargo Feature: decode Source: https://github.com/yotarok/flacenc-rs/blob/main/README.md Enables decoder-related features, including bit-stream parsing and component-to-signal conversion. Enabling this feature adds a dependency on the 'nom' crate for bitstream parsing. ```rust [features] decode = ["nom"] ``` -------------------------------- ### Rust Cargo Feature: mimalloc Source: https://github.com/yotarok/flacenc-rs/blob/main/README.md Enables the 'mimalloc' global allocator, which can potentially improve performance, especially in 'par'-mode. This feature adds a dependency on the 'mimalloc' crate. ```rust [features] mimalloc = ["mimalloc"] ``` -------------------------------- ### Rust Cargo Feature: par Source: https://github.com/yotarok/flacenc-rs/blob/main/README.md Enables multi-thread encoding in the 'encode_with_fixed_block_size' function when the 'config' argument is properly configured. If 'par' is enabled, multi-thread mode is enabled by default. This feature adds a dependency on the 'crossbeam-channel' crate. To disable multi-thread mode and reduce dependencies, use 'default-features = false'. This feature is enabled by default. ```rust [features] par = ["crossbeam-channel"] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.