项目作者: frabert

项目描述 :
Rust crate for doing IO on RIFF files
高级语言: Rust
项目地址: git://github.com/frabert/riff.git
创建时间: 2018-07-03T09:07:06Z
项目社区:https://github.com/frabert/riff

开源协议:MIT License

下载


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:

  1. let mut file = File::open("somefile.wav")?;
  2. let chunk = riff::Chunk::read(&mut file, 0)?;
  3. for child in chunk.iter(&mut file) {
  4. println!(child.id());
  5. }

Writing chunks:

  1. // Some ids to use while creating chunks
  2. let smpl_id: ChunkId = ChunkId { value: [0x73, 0x6D, 0x70, 0x6C] };
  3. let test_id: ChunkId = ChunkId { value: [0x74, 0x65, 0x73, 0x74] };
  4. let tst1_id: ChunkId = ChunkId { value: [0x74, 0x73, 0x74, 0x31] };
  5. let tst2_id: ChunkId = ChunkId { value: [0x74, 0x73, 0x74, 0x32] };
  6. let str1 = "hey this is a test".as_bytes().to_vec();
  7. let str2 = "hey this is another test".as_bytes().to_vec();
  8. let str3 = "final test".as_bytes().to_vec();
  9. let contents = ChunkContents::Children(
  10. riff::RIFF_ID,
  11. smpl_id,
  12. vec![
  13. ChunkContents::Children(
  14. riff::LIST_ID,
  15. tst1_id,
  16. vec![
  17. ChunkContents::Data(test_id, str1),
  18. ChunkContents::Data(test_id, str2)
  19. ]),
  20. ChunkContents::Children(
  21. riff::LIST_ID,
  22. tst2_id,
  23. vec![
  24. ChunkContents::Data(test_id, str3)
  25. ]
  26. )
  27. ]);
  28. let mut file = File::create("somefile.riff")?;
  29. contents.write(&mut file)?;