# mp3 without id3 header
- Let sequence be the resource header, where sequence[s] is byte s in sequence and sequence[0] is the first byte in sequence.
- Let length be the number of bytes in sequence.
- Initialize s to 0.
- If the result of the operation "match mp3 header" is false, return undefined
- Execute the operation "mp3 parse".
- Let `skipped-bytes` the return value of the execution of "mp3 framesize"
- if `skipped-bytes` is less than 4, or `skipped-bytes` is greater than `s -
  length`, return undefined.
- Increment s by `skipped-bytes`.
- If th result of the operation "match mp3 header" operation is false, return
  undefined, else, return "audio/mp3".

## Match mp3 header
- If length is less than 4, return false.
- If sequence[s] is not equal to 0xff and the result of a bitwise AND
  between sequence[s + 1] and 0xe0 is not equal to 0xe0, return false.
- Let `layer` be the result of a bitwise AND between sequence[s + 1] and 0x06
- If the result of a bitwise right shift of one bit on `layer` is not 0, return
- Let `bitrate` be the result of a bitwise AND between sequence[s + 2] and 0xf0
- If the result of a bitwise right shift of four bits on `bitrate` is not 15,
  return false.
- Let `samplerate` be the result of a bitwise AND between sequence[s + 3] and
  0x0c.
- If the result of a bitwise right shift of two bits on `samplerate` is not 3,
  return false.
- Let `final-layer` be the result of 4 - (sequence[s + 1])
- Apply a bitwise AND to `final-layer` and 0x06, and apply a bitwise right shift
of one bit to the result. If this value is not 3, return false.
- Return true.

## mp3 framesize
- If header-version is 1, let `scale` be 72, else, let `scale` be 144.
- Let size be `bitrate` times `scale` divided by `freq`.
- If `pad` is True, increment `size` by 1.

## mp3 parse
- Let version be the result of the bitwise AND between sequence[s + 1] and 0x18,
bitwise shifted to the right by 3 bits.
- Let `bitrate-index` be the result of the bitwise AND between sequence[s + 2]
and 0xf0, bitwise shifted to the right by four bits.
- If the result of the bitwise AND of version and 0x01 is non-zero, let `bitrate`
be the value given by `bitrate-index` in the table mp2.5-rates
- If the result of the bitwise AND of version and 0x01 is zero, let `bitrate`
be the value given by `bitrate-index` in the table mp3-rates
- Let `samplerate-index` be the result of a bitwise AND between sequence[s + 2]
and 0x0c, bitwise shifted to the right by two bits.
- Let `samplerate` be the value given by `samplerate-index` in the `samplerate` table.
- Let `pad` be the result of a bitwise and between sequence[s + 2] and 0x02,
bitwise shifter by one bit.

index | mp3-rates
------+------------
 0    | 0
 1    | 32000
 2    | 40000
 3    | 48000
 4    | 56000
 5    | 64000
 6    | 80000
 7    | 96000
 8    | 112000
 9    | 128000
10    | 160000
11    | 192000
12    | 224000
13    | 256000
14    | 320000

index | mp2.5-rates
------+------------
 0    | 0
 1    | 8000
 2    | 16000
 3    | 24000
 4    | 32000
 5    | 40000
 6    | 48000
 7    | 56000
 8    | 64000
 9    | 80000
10    | 96000
11    | 112000
12    | 128000
13    | 144000
14    | 160000

index | samplerate
------+-----------
 0    | 44100
 1    | 48000
 2    | 32000
