NetMD.Track (NetMD v0.1.0)

Copy Markdown View Source

A track to download to the recorder, ported from netmd-js's MDTrack.

Audio data must already be in the wire format: raw PCM (big-endian 16-bit stereo at 44100 Hz) or pre-encoded ATRAC3 for the LP modes. Packets are encrypted with a random key wrapped by the key encryption key, chained CBC across chunks.

Summary

Types

Wire format of the audio data.

t()

A track ready for download.

Functions

The content ID all open implementations use.

Default disc format byte for the track's wire format.

Number of frames in the (padded) data.

Frame size in bytes for the track's wire format.

The key encryption key all open implementations use.

Stream of {key, iv, encrypted_data} packets for NetMD.Interface.send_track/8.

Data size in bytes, padded up to a whole number of frames.

Wire format byte sent to the device.

Types

format()

@type format() :: :pcm | :l105kbps | :lp2 | :lp4

Wire format of the audio data.

t()

@type t() :: %NetMD.Track{
  chunk_size: pos_integer(),
  data: binary(),
  format: format(),
  full_width_title: String.t() | nil,
  raw_key: <<_::64>> | nil,
  title: String.t()
}

A track ready for download.

Functions

content_id()

@spec content_id() :: <<_::160>>

The content ID all open implementations use.

disc_format(track)

@spec disc_format(t()) :: byte()

Default disc format byte for the track's wire format.

frame_count(track)

@spec frame_count(t()) :: non_neg_integer()

Number of frames in the (padded) data.

frame_size(track)

@spec frame_size(t()) :: pos_integer()

Frame size in bytes for the track's wire format.

kek()

@spec kek() :: <<_::64>>

The key encryption key all open implementations use.

packets(track)

@spec packets(t()) :: Enumerable.t()

Stream of {key, iv, encrypted_data} packets for NetMD.Interface.send_track/8.

The data is encrypted with a random key (set :raw_key on the struct for a deterministic stream); the packet key is that key unwrapped with the KEK. The IV chains from the last ciphertext block of the previous chunk.

total_size(track)

@spec total_size(t()) :: pos_integer()

Data size in bytes, padded up to a whole number of frames.

wireformat(track)

@spec wireformat(t()) :: byte()

Wire format byte sent to the device.