Expand description
§AIFF and AIFF-C Audio Format Reader and Writer
This crate contains AifcReader and AifcWriter for Audio Interchange File Formats
AIFF and AIFF-C. This crate supports uncompressed sample data,
μ-law, A-law and IMA ADPCM (“ima4”) compressed sample data.
These audio formats are made of chunks, which contain header data (the COMM chunk), audio sample data (the SSND chunk) and other data, such as marker data (the MARK chunk).
§Examples
Reading samples:
let mut stream = std::io::BufReader::new(std::fs::File::open("test.aiff")?);
let mut reader = aifc::AifcReader::new(&mut stream)?;
let info = reader.read_info()?;
for sample in reader.samples()? {
println!("Got sample {:?}", sample.expect("Sample read error"));
}Writing AIFF-C with the default 2 channels, sample rate 44100 and signed 16-bit integer samples:
let mut stream = std::io::BufWriter::new(std::fs::File::create("test.aiff")?);
let info = aifc::AifcWriteInfo::default();
let mut writer = aifc::AifcWriter::new(&mut stream, &info)?;
writer.write_samples_i16(&[ 0, 10, -10, 0 ])?;
writer.finalize()?;§Text decoding
AIFF and AIFF-C originally support ASCII only text in their metadata chunks (NAME, ANNO, etc.). In addition to ASCII, older apps may have used ISO-8859-1 and newer apps may have used UTF-8.
A text decoder could try to decode UTF-8 first with
String::from_utf8() and if it fails, try to decode ISO-8859-1,
and if it fails, decode ASCII. Or it could just assume that everything is UTF-8 and
call String::from_utf8_lossy().
When writing new files, the ID3 chunk has proper support for UTF-8 text and can be used as a replacement for most metadata chunks.
Structs§
- Audio info returned by
AifcReader. - AIFF / AIFF-C reader.
- Audio info for
AifcWriter. - AIFF / AIFF-C writer.
- ChunkRef contains a chunk id, chunk start position and its size.
- Iterator to read chunks one by one.
- Comment data.
- Iterator to read comments from a slice of bytes.
- Instrument data.
- Instrument loop values.
- Marker data.
- Iterator to read markers from a slice of bytes.
- Iterator to read samples one by one.
Enums§
- Error values.
- File format: AIFF or AIFF-C.
- Sample data.
- Sample format.
Constants§
- The audio recording “AESD” chunk id.
- The annotation “ANNO” chunk id. A stream may contain multiple ANNO chunks.
- The application specific “APPL” chunk id. A stream may contain multiple APPL chunks.
- The author “AUTH” chunk id.
- The common (header) “COMM” chunk id.
- The comments “COMT” chunk id.
- The copyright “(c) “ chunk id.
- The format version “FVER” chunk id.
- The ID3 “ID3 “ data chunk id.
- The instrument “INST” chunk id.
- The marker “MARK” chunk id.
- The MIDI “MIDI” data chunk id. A stream may contain multiple MIDI chunks.
- The name “NAME” chunk id.
- The sound data “SSND” chunk id.
Functions§
- Checks if the given data is the start of AIFF or AIFF-C.
Type Aliases§
- Library Result type.
- A chunk id is a four byte identifier.
- Marker id, which should be a positive number.