Skip to content

Commit

Permalink
Add AIFF support (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesbraun committed Jan 9, 2022
1 parent 808d421 commit af75c5a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ true
| audio/x-wav | wav |
| audio/amr | amr |
| audio/aac | aac |
| audio/aiff | aiff |

### Document

Expand Down
1 change: 1 addition & 0 deletions lib/matchers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ defmodule Infer.Matchers do
%Infer.Type{matcher_type: :audio, mime_type: "audio/x-wav", extension: "wav", matcher: &Infer.Audio.is_wav/1},
%Infer.Type{matcher_type: :audio, mime_type: "audio/amr", extension: "amr", matcher: &Infer.Audio.is_amr/1},
%Infer.Type{matcher_type: :audio, mime_type: "audio/aac", extension: "aac", matcher: &Infer.Audio.is_aac/1},
%Infer.Type{matcher_type: :audio, mime_type: "audio/x-aiff", extension: "aiff", matcher: &Infer.Audio.is_aiff/1},
# Font
%Infer.Type{matcher_type: :font, mime_type: "application/font-woff", extension: "woff", matcher: &Infer.Font.is_woff/1},
%Infer.Type{matcher_type: :font, mime_type: "application/font-woff2", extension: "woff2", matcher: &Infer.Font.is_woff2/1},
Expand Down
7 changes: 7 additions & 0 deletions lib/matchers/audio.ex
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,11 @@ defmodule Infer.Audio do
@spec is_aac(binary()) :: boolean()
def is_aac(<<0xFF, 0xF1, 0xF9, _rest::binary>>), do: true
def is_aac(_binary), do: false

@doc """
Takes the binary file contents as arguments. Returns `true` if it's an aiff.
"""
@spec is_aiff(binary()) :: boolean()
def is_aiff(<<0x46, 0x4F, 0x52, 0x4D, _data::binary-size(4), 0x41, 0x49, 0x46, 0x46, _rest::binary>>), do: true
def is_aiff(_binary), do: false
end

0 comments on commit af75c5a

Please sign in to comment.