NetMDPython is a collection of Python scripts which allow to control NetMD devices on Linux, Unix and MacOS X (Windows is unfortunately not yet supported since libusb is too old on Windows). With NetMD Python, you can upload tracks from standard MDs with the help of the MZ-RH1 Walkman to your PC, list the contents of any standard MD with any NetMD device and control and record tracks over analog input with any NetMD device. A recently added and therefore still very hacky script called "downloadhack.py" allows to download tracks to a NetMD.
Before the Python code for NetMD can be used, git, libusb-1 and python 2.4+ with ctypes need to be installed. A development version of ffmpeg is required to convert uploaded ATRAC tracks to other formats. In order to be able to obtain this version of ffmpeg, subversion must be installed (which is the case on MacOS X by default but not on Ubuntu for example). Depending on your operating system, the installation is slightly different:
Download and install Macports: http://www.macports.org.
After installing macports, you'll need to modify your .bashrc in your home-directory by adding "/opt/local/bin" to the PATH-environment. In a terminal (Applications→Utilities→Terminal), as normal user, type:
echo "PATH=$PATH:/opt/local/bin" >> ~/.bashrc
Then install the ports git-core and libusb from Macports:
sudo port install libusb git-core py26-crypto sox
sudo apt-get install python2.6 libusb-dev git-core subversion python-crypto sox
Download and install Python2.6, PyCrypto and sox.
Download zadig.exe (WinUSB device driver installer), connect your NetMD device and run zadig.exe.
Click Options→List all devices, choose your NetMD device an choose Install Driver. NOTE: SonicStage will not be able to communicate with your NetMD device anymore. If you want to use SonicStage again, you will have to uninstall WinUSB device driver first. (To uninstall the driver, run Windows "Device Manager", choose your device and uninstall it, you can find it at "libusb (WinUSB) devices". Then unplug and reconnect your device).
Download latest version of python-libusb1 and replace usb1.py and libusb1.py in the netmd subdirectory of your linux-minidisc folder with the python-libusb1 versions. These versions can find and open libusb Windows DLL which has not been implemented in usb1.py and libusb1.py of current main source repository yet.
Download and extract libusb windows backend and copy libusb1.0.dll to your windows/system32 folder (usually C:\WINDOWS\system32). Use the version according to your version of Windows, the mingw32 version should work on Windows XP 32-bit.
Open a command prompt (Click Start→Run, type cmd and press enter) and type
set PATH=<sox install dir>;%PATH%
to add the path of sox directory temporarily. (<sox install dir> means the path to your sox installation directory, usually C:\sox-14-3-1). To use it permanently you can add the path to your system variables.
If you want to use ffmpeg to convert uploaded files, you can download Windows binaries of ffmpeg. Extract it to a place of your choice and add the path of bin subdirectory to your PATH environment variable as described above.
set PATH=<ffmpeg install dir>\bin;%PATH%
To use the tools, change into netmd subdirectory of your linux-minidisc folder and run the scripts by their name (just type "dump_md.py", "upload.py", …) with parameters if required. See how_to_use_the_tools below.
To get the code, clone it with git as shown on the homepage.
The Python libnetmd can be found in the netmd subdirectory:
cd linux-minidisc/netmd
$ ./lsmd.py -h Usage: lsmd.py [options] Options: -h, --help show this help message and exit -b BUS, --bus=BUS -d DEVICE, --device=DEVICE
$ sudo ./lsmd.py Disk (writable media, write-protected) 'Disc title ascii' DISC title wchar Time used: 01:10:26+026 (94.55%) 20 tracks 000: 00:03:06+017 sp stereo unprotected 'Track title ascii' Track title wchar [...]
Automated extraction of tracks from a MD. It does analog extraction, as there is no known way to extract tracks digitally (except for MZ-RH1 player).
It encodes tracks into ogg in a subfolder of working directory named after disc title. Tracks are named as "%n - %t.ogg
", %n
being 2-digit track number starting at 01
and %t
being the track title.
Note on wchar: If there is wchar version of a title set, it will take precedence over ascii title. This works for both disc and track titles.
$ ./dump_md.py -h Usage: dump_md.py [options] Options: -h, --help show this help message and exit -b BUS, --bus=BUS -d DEVICE, --device=DEVICE -t TRACK_RANGE, --track-range=TRACK_RANGE
$ sudo ./dump_md.py -t 1-3 Storing in DISC title wchar Recording 01 - Track title wchar.ogg ( 00:03:06.033 ) Waiting for MD... Input File : 'default' (alsa) Channels : 2 Sample Rate : 48000 Precision : 16-bit Sample Encoding: 16-bit Signed Integer PCM In:0.00% 00:00:01.49 [00:00:00.00] Out:0 [ | ] Clip:0 [...]
This tool is used for digital upload of non-protected tracks (lsmd lists them as "unprotected"). It works with the MZ-RH1 HiMD Walkman only. Invocation has the same syntax as the dump_md
utility, but the output format will be ".aea" for SP tracks (a format implemented by very recent versions of ffmpeg) and ".wav" for LP2/LP4 tracks. NOTE: While the files are really Windows-compatible WAV files, they still do contain the ATRAC3 encoded audio. To play them you need an ATRAC3 decoder. For Windows, that means you have to install the ATRAC3 decoder (acm file) in order for it work with Windows Media Player. Alternatively, you can install a recent version of VLC. On Linux, the ffmpeg project (and everything based on it) supports ATRAC3 encoded audio as well as ATRAC SP (version 0.6 or later).
This tool will silently skip protected tracks, so if you don't get the files you expect, check their protection status. There is no known way to unprotect a track using NetMD or HiMD players. All tracks uploaded by Sonic Stage are protected. Surprisingly, tracks uploaded by MD Simple Burner are not. To transfer tracks to the NetMD as unprotected, our "downloadhack.py" may be used as well.
sudo port install ffmpeg-devel
svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg cd ffmpeg ./configure --prefix=/opt/local make sudo make install
cd linux-minidisc/netmd ./upload.py
ffmpeg -i <filename of MD track to be converted> <name of WAV output file>
find . -type f | while read filename; do ffmpeg -i "$filename" -ab 256k "${filename%aea}mp4" ; done
apt-cache show ffmpeg |grep Version Version: 5:0.6~svn20100603-0.0 Version: 4:0.5.2-1
sudo apt-get install ffmpeg
sudo apt-get build-dep ffmpeg cd /usr/src svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg cd ffmpeg ./configure make sudo make install
cd ~/linux-minidisc/netmd ./upload.py
ffmpeg -i <filename of MD track to be converted> <name of WAV output file>
find . -type f | while read filename; do ffmpeg -i "$filename" -ab 256k "${filename%aea}mp4" ; done
Use this script download tracks to your NetMD Walkman. Note: This requires the NetMD root key from Sony which is not (yet) part of the official repository due to legal reasons.
This is in a more-than-primitive state. It is supposed to export all functions of libnetmd.py for easy command-line use. Currently, it's a brain-dead wrapper around a pdb shell. Use only if you know Python.
This is just a toy to test usb1.py and libusb1.py. It looks a bit like regular lsusb, but fetches all its data from the USB device itself ("real" lsusb maintains a device/manufacturer list asides), which is much less readable (many devices are not correctly defined internally). Useful (…maybe not even) as a sample code using usb1.py.
Important notes regarding all tools:
Most (all ?) those tools will iterate over all connected MD devices. They (should) offer -b
and -d
parameters to allow you to specify the usb bus and the device number you want to affect independently of others.
Library documentation (…once written ) can be accessed by python regular documentation system:
pydoc libnetmd