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 audio info and 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.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§
- Aifc
Read Info - Audio info returned by
AifcReader
. - Aifc
Reader - AIFF / AIFF-C reader.
- Aifc
Write Info - Audio info for
AifcWriter
. - Aifc
Writer - AIFF / AIFF-C writer.
- Chunk
Ref - ChunkRef contains a chunk id, chunk start position and its size.
- Chunks
- Iterator to read chunks one by one.
- Comment
- Comment data.
- Comments
- Iterator to read comments from a slice of bytes.
- Instrument
- Instrument data.
- Loop
- Instrument loop values.
- Marker
- Marker data.
- Markers
- Iterator to read markers from a slice of bytes.
- Samples
- Iterator to read samples one by one.
Enums§
- Aifc
Error - Error values.
- File
Format - File format: AIFF or AIFF-C.
- Sample
- Sample data.
- Sample
Format - Sample format.
Constants§
- CHUNKID_
AESD - The audio recording “AESD” chunk id.
- CHUNKID_
ANNO - The annotation “ANNO” chunk id. A stream may contain multiple ANNO chunks.
- CHUNKID_
APPL - The application specific “APPL” chunk id. A stream may contain multiple APPL chunks.
- CHUNKID_
AUTH - The author “AUTH” chunk id.
- CHUNKID_
COMM - The common (header) “COMM” chunk id.
- CHUNKID_
COMT - The comments “COMT” chunk id.
- CHUNKID_
COPY - The copyright “(c) “ chunk id.
- CHUNKID_
FVER - The format version “FVER” chunk id.
- CHUNKID_
ID3 - The ID3 “ID3 “ data chunk id.
- CHUNKID_
INST - The instrument “INST” chunk id.
- CHUNKID_
MARK - The marker “MARK” chunk id.
- CHUNKID_
MIDI - The MIDI “MIDI” data chunk id. A stream may contain multiple MIDI chunks.
- CHUNKID_
NAME - The name “NAME” chunk id.
- CHUNKID_
SSND - The sound data “SSND” chunk id.
Functions§
- recognize
- Checks if the given data is the start of AIFF or AIFF-C.
Type Aliases§
- Aifc
Result - Library Result type.
- ChunkId
- A chunk id is a four byte identifier.
- Marker
Id - Marker id, which should be a positive number.