riff

Crate for doing IO on RIFF-formatted files

This crate provides utility methods for reading and writing formats such as Microsoft Wave, Audio Video Interleave or Downloadable Sounds.

Examples

Reading chunks:

````rust let mut file = File::open("somefile.wav")?; let chunk = riff::Chunk::read(&mut file, 0)?;

for child in chunk.iter(&mut file) { println!(child.id()); } ````

Writing chunks:

````rust // Some ids to use while creating chunks let smplid: ChunkId = ChunkId { value: [0x73, 0x6D, 0x70, 0x6C] }; let testid: ChunkId = ChunkId { value: [0x74, 0x65, 0x73, 0x74] }; let tst1id: ChunkId = ChunkId { value: [0x74, 0x73, 0x74, 0x31] }; let tst2id: ChunkId = ChunkId { value: [0x74, 0x73, 0x74, 0x32] };

let str1 = "hey this is a test".asbytes().tovec(); let str2 = "hey this is another test".asbytes().tovec(); let str3 = "final test".asbytes().tovec();

let contents = ChunkContents::Children( riff::RIFFID, smplid, vec![ ChunkContents::Children( riff::LISTID, tst1id, vec![ ChunkContents::Data(testid, str1), ChunkContents::Data(testid, str2) ]), ChunkContents::Children( riff::LISTID, tst2id, vec![ ChunkContents::Data(test_id, str3) ] ) ]);

let mut file = File::create("somefile.riff")?; contents.write(&mut file)?; ````