NetMD (NetMD v0.1.0)

Copy Markdown View Source

Drive MiniDisc recorders over NetMD USB.

A port of the NetMD protocol as implemented by netmd-js and libnetmd (linux-minidisc), on top of BodgeUSB.

{:ok, device} = NetMD.open()
{:ok, disc} = NetMD.list_content(device)
:ok = NetMD.play(device)

track = %NetMD.Track{title: "New Song", format: :lp2, data: atrac3_data}
{:ok, %{track: n}} = NetMD.download(device, track)

This module is a convenience facade; the layers underneath are usable on their own:

Summary

Functions

Close the device.

Device state (disc presence, playback state, position).

Eject the disc.

Erase the whole disc.

Erase a track (zero-based).

Enter factory mode for direct memory access and patching. Dangerous; see NetMD.Factory.

Fast-forward.

Seek to a track (zero-based).

List all connected NetMD devices. See NetMD.Device.list/1.

Move a track (both positions zero-based).

Skip to the next track.

Open the first NetMD device found. See NetMD.Device.open/1.

Pause playback.

Start playback.

Skip to the previous track.

Rename the disc, preserving groups. See NetMD.Commands.rename_disc/3.

Rename a track (zero-based).

Restart the current track.

Rewind.

Stop playback.

Subscribe to {:netmd_status, status} change events from the background poller. See NetMD.Device.subscribe/2.

Upload a track from the disc (MZ-RH1 only). See NetMD.Commands.upload/3.

Functions

close(device)

@spec close(NetMD.Device.t()) :: :ok

Close the device.

device_status(device)

@spec device_status(NetMD.Device.t()) :: {:ok, map()} | {:error, term()}

Device state (disc presence, playback state, position).

download(device, track, opts \\ [])

@spec download(NetMD.Device.t(), NetMD.Track.t(), keyword()) ::
  {:ok, map()} | {:error, term()}

Download a track to the disc. See NetMD.Commands.download/3.

eject_disc(device)

@spec eject_disc(NetMD.Device.t()) :: :ok | {:error, term()}

Eject the disc.

erase_disc(device)

@spec erase_disc(NetMD.Device.t()) :: :ok | {:error, term()}

Erase the whole disc.

erase_track(device, track)

@spec erase_track(NetMD.Device.t(), non_neg_integer()) :: :ok | {:error, term()}

Erase a track (zero-based).

factory(device)

@spec factory(NetMD.Device.t()) :: {:ok, NetMD.Factory.t()} | {:error, term()}

Enter factory mode for direct memory access and patching. Dangerous; see NetMD.Factory.

fast_forward(device)

@spec fast_forward(NetMD.Device.t()) :: :ok | {:error, term()}

Fast-forward.

goto_time(device, track, opts \\ [])

@spec goto_time(NetMD.Device.t(), non_neg_integer(), keyword()) ::
  :ok | {:error, term()}

Seek to a time within a track. See NetMD.Interface.goto_time/3.

goto_track(device, track)

@spec goto_track(NetMD.Device.t(), non_neg_integer()) ::
  {:ok, non_neg_integer()} | {:error, term()}

Seek to a track (zero-based).

list_content(device)

@spec list_content(NetMD.Device.t()) :: {:ok, NetMD.Disc.t()} | {:error, term()}

Full disc listing. See NetMD.Commands.list_content/1.

list_devices(opts \\ [])

@spec list_devices(keyword()) :: [NetMD.Device.listing()]

List all connected NetMD devices. See NetMD.Device.list/1.

move_track(device, source, dest)

@spec move_track(NetMD.Device.t(), non_neg_integer(), non_neg_integer()) ::
  :ok | {:error, term()}

Move a track (both positions zero-based).

next_track(device)

@spec next_track(NetMD.Device.t()) :: :ok | {:error, term()}

Skip to the next track.

open(opts \\ [])

@spec open(keyword()) :: {:ok, NetMD.Device.t()} | {:error, term()}

Open the first NetMD device found. See NetMD.Device.open/1.

pause(device)

@spec pause(NetMD.Device.t()) :: :ok | {:error, term()}

Pause playback.

play(device)

@spec play(NetMD.Device.t()) :: :ok | {:error, term()}

Start playback.

previous_track(device)

@spec previous_track(NetMD.Device.t()) :: :ok | {:error, term()}

Skip to the previous track.

rename_disc(device, name, opts \\ [])

@spec rename_disc(NetMD.Device.t(), String.t(), keyword()) :: :ok | {:error, term()}

Rename the disc, preserving groups. See NetMD.Commands.rename_disc/3.

rename_track(device, track, title, opts \\ [])

@spec rename_track(NetMD.Device.t(), non_neg_integer(), String.t(), keyword()) ::
  :ok | {:error, term()}

Rename a track (zero-based).

restart_track(device)

@spec restart_track(NetMD.Device.t()) :: :ok | {:error, term()}

Restart the current track.

rewind(device)

@spec rewind(NetMD.Device.t()) :: :ok | {:error, term()}

Rewind.

stop(device)

@spec stop(NetMD.Device.t()) :: :ok

Stop playback.

subscribe(device, pid \\ self())

@spec subscribe(NetMD.Device.t(), pid()) :: :ok | {:error, :status_events_unavailable}

Subscribe to {:netmd_status, status} change events from the background poller. See NetMD.Device.subscribe/2.

unsubscribe(device, pid \\ self())

@spec unsubscribe(NetMD.Device.t(), pid()) ::
  :ok | {:error, :status_events_unavailable}

Stop receiving status events. See NetMD.Device.unsubscribe/2.

upload(device, track, opts \\ [])

@spec upload(NetMD.Device.t(), non_neg_integer(), keyword()) ::
  {:ok, map()} | {:error, term()}

Upload a track from the disc (MZ-RH1 only). See NetMD.Commands.upload/3.