Skip to content

Commit

Permalink
feat: Add DSF Audio support
Browse files Browse the repository at this point in the history
- Adds support for DSF Audio
- Bumps patch version
  • Loading branch information
evensolberg committed May 8, 2022
1 parent 9305cc3 commit e5cd258
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "infer"
version = "0.7.0"
version = "0.7.1"
authors = ["Bojan <[email protected]>"]
edition = "2018"
description = "Small crate to infer file type based on magic number signatures"
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ assert_eq!(kind.extension(), "foo");
# }
```
*/

#![crate_name = "infer"]
#![doc(html_root_url = "https://docs.rs/infer/0.3.0")]
#![doc(html_root_url = "https://docs.rs/infer/latest")]
#![forbid(unsafe_code)]
#![cfg_attr(not(feature = "std"), no_std)]

Expand Down
6 changes: 6 additions & 0 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,12 @@ matcher_map!(
"aiff",
matchers::audio::is_aiff
),
(
MatcherType::Audio,
"audio/x-dsf",
"dsf",
matchers::audio::is_dsf
),
// Font
(
MatcherType::Font,
Expand Down
6 changes: 6 additions & 0 deletions src/matchers/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,9 @@ pub fn is_aiff(buf: &[u8]) -> bool {
&& buf[10] == 0x46
&& buf[11] == 0x46
}

/// Returns whether a buffer is DSF data.
pub fn is_dsf(buf: &[u8]) -> bool {
// ref: https://dsd-guide.com/sites/default/files/white-papers/DSFFileFormatSpec_E.pdf
buf.len() > 4 && buf[0] == b'D' && buf[1] == b'S' && buf[2] == b'D' && buf[3] == b' '
}
Binary file added testdata/sample.dsf
Binary file not shown.
1 change: 1 addition & 0 deletions tests/audio.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mod common;

test_format!(Audio, "audio/mpeg", "mp3", mp3, "sample.mp3");
test_format!(Audio, "audio/x-dsf", "dsf", dsf, "sample.dsf");

0 comments on commit e5cd258

Please sign in to comment.