Skip to content

Commit e5cd258

Browse files
committed
feat: Add DSF Audio support
- Adds support for DSF Audio - Bumps patch version
1 parent 9305cc3 commit e5cd258

File tree

6 files changed

+16
-2
lines changed

6 files changed

+16
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "infer"
3-
version = "0.7.0"
3+
version = "0.7.1"
44
authors = ["Bojan <[email protected]>"]
55
edition = "2018"
66
description = "Small crate to infer file type based on magic number signatures"

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ assert_eq!(kind.extension(), "foo");
6565
# }
6666
```
6767
*/
68+
6869
#![crate_name = "infer"]
69-
#![doc(html_root_url = "https://docs.rs/infer/0.3.0")]
70+
#![doc(html_root_url = "https://docs.rs/infer/latest")]
7071
#![forbid(unsafe_code)]
7172
#![cfg_attr(not(feature = "std"), no_std)]
7273

src/map.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,12 @@ matcher_map!(
301301
"aiff",
302302
matchers::audio::is_aiff
303303
),
304+
(
305+
MatcherType::Audio,
306+
"audio/x-dsf",
307+
"dsf",
308+
matchers::audio::is_dsf
309+
),
304310
// Font
305311
(
306312
MatcherType::Font,

src/matchers/audio.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,9 @@ pub fn is_aiff(buf: &[u8]) -> bool {
7575
&& buf[10] == 0x46
7676
&& buf[11] == 0x46
7777
}
78+
79+
/// Returns whether a buffer is DSF data.
80+
pub fn is_dsf(buf: &[u8]) -> bool {
81+
// ref: https://dsd-guide.com/sites/default/files/white-papers/DSFFileFormatSpec_E.pdf
82+
buf.len() > 4 && buf[0] == b'D' && buf[1] == b'S' && buf[2] == b'D' && buf[3] == b' '
83+
}

testdata/sample.dsf

13.5 MB
Binary file not shown.

tests/audio.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
mod common;
22

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

0 commit comments

Comments
 (0)