netmd++  1.0.4
C++ API to access NetMD devices
netmd++ Documentation

netmd++

This C++ API was written to ease the handling of NetMD devices. It is a synchronous API. So, function calls might block your program flow. If you want to use this API in an GUI app, better put the API calls into a background thread.

Supported Devices

Manufacturer Manufacturer ID Device ID Name Type
Sony 0x054c 0x0034 Sony PCLK-XX NetMD
0x054c 0x0036 Sony NetMD Walkman NetMD
0x054c 0x006F Sony NW-E7 NetMD
0x054c 0x0075 Sony MZ-N1 NetMD
0x054c 0x007c Sony NetMD Walkman NetMD
0x054c 0x0080 Sony LAM-1 NetMD
0x054c 0x0081 Sony MDS-JE780/JB980 NetMD
0x054c 0x0084 Sony MZ-N505 NetMD
0x054c 0x0085 Sony MZ-S1 NetMD
0x054c 0x0086 Sony MZ-N707 NetMD
0x054c 0x008e Sony CMT-C7NT NetMD
0x054c 0x0097 Sony PCGA-MDN1 NetMD
0x054c 0x00ad Sony CMT-L7HD NetMD
0x054c 0x00c6 Sony MZ-N10 NetMD
0x054c 0x00c7 Sony MZ-N910 NetMD
0x054c 0x00c8 Sony MZ-N710/NE810/NF810 NetMD
0x054c 0x00c9 Sony MZ-N510/NF610 NetMD
0x054c 0x00ca Sony MZ-NE410/DN430/NF520 NetMD
0x054c 0x00e7 Sony CMT-M333NT/M373NT NetMD
0x054c 0x00eb Sony MZ-NE810/NE910 NetMD
0x054c 0x0101 Sony LAM NetMD
Aiwa 0x054c 0x0113 Aiwa AM-NX1 NetMD
Sony 0x054c 0x011a Sony CMT-SE7 NetMD
0x054c 0x0119 Sony CMT-SE9 NetMD
0x054c 0x013f Sony MDS-S500 NetMD
0x054c 0x0148 Sony MDS-A1 NetMD
Aiwa 0x054c 0x014c Aiwa AM-NX9 NetMD
Sony 0x054c 0x017e Sony MZ-NH1 HiMD
0x054c 0x0180 Sony MZ-NH3D HiMD
0x054c 0x0182 Sony MZ-NH900 HiMD
0x054c 0x0184 Sony MZ-NH700/800 HiMD
0x054c 0x0186 Sony MZ-NH600 HiMD
0x054c 0x0187 Sony MZ-NH600D HiMD
0x054c 0x0188 Sony MZ-N920 NetMD
0x054c 0x018a Sony LAM-3 NetMD
0x054c 0x01e9 Sony MZ-DH10P HiMD
0x054c 0x0219 Sony MZ-RH10 HiMD
0x054c 0x021b Sony MZ-RH910 HiMD
0x054c 0x021d Sony CMT-AH10 HiMD
0x054c 0x022c Sony CMT-AH10 HiMD
0x054c 0x023c Sony DS-HMD1 HiMD
0x054c 0x0286 Sony MZ-RH1 HiMD
Sharp 0x04dd 0x7202 Sharp IM-MT880H/MT899H NetMD
0x04dd 0x9013 Sharp IM-DR400/DR410 NetMD
0x04dd 0x9014 Sharp IM-DR80/DR420/DR580 NetMD
Panasonic 0x04da 0x23b3 Panasonic SJ-MR250 NetMD
0x04da 0x23b6 Panasonic SJ-MR270 NetMD
Kenwood 0x0b28 0x1004 Kenwood MDX-J9 NetMD

Namespace

This API uses the namespace netmd.

Usage

  • include the header file into your project:
    #include "path/to/netmd++.h"
  • create an instance of the API:
  • initialize the first found NetMD device:
    if (pNetMd != nullptr)
    {
    pNetMd->initHotPlug();
    }
  • If you change or re-plug the device, it should be recognized by the hotplug implementation!

Examples

Track transfer

Check for on-the-fly support and transfer a WAVE file to NetMD with on-the-fly encoding (LP2) or w/o encoding (SP).

#include <netmd++.h>
int main()
{
if (pNetMd != nullptr)
{
pNetMd->initHotPlug();
{
if (pNetMd->otfEncodeSupported())
{
pNetMd->sendAudioFile("/path/to/nice/audio.wav", "Very nice Audio file (LP2)", netmd::NETMD_DISKFORMAT_LP2);
}
else
{
pNetMd->sendAudioFile("/path/to/nice/audio.wav", "Very nice Audio file (SP)", netmd::NO_ONTHEFLY_CONVERSION);
}
}
}
return 0;
}

### Erase disc and set new title

#include <netmd++.h>
int main()
{
if (pNetMd != nullptr)
{
pNetMd->initHotPlug();
{
pNetMd->eraseDisc();
pNetMd->setDiscTitle("Amazing MD");
}
}
return 0;
}

MDs UTOC

For the UTOC structure please have a look at this great site on minidisc.org

Addressing in UTOC

The disc start and end addresses each consist of a cluster, sector, and sound group, all packed into 3 bytes. The smallest unit is a sound frame, representing 11.6ms of mono audio (212 bytes), while the smallest addressable unit is the sound group, containing 2 sound frames. A sector contains 11 sound frames / 5.5 sound groups. Addressing must be done through sound group. Sound groups are numbered 0 ... 10. Sound groups 0 ... 5 are part of the even sector, while sound groups 5 ... 10 are part of the odd sector. Group 5 overlaps both even and odd sectors and can therefore be addressed on both sectors.

+-------------------------------------------+
|                sector pair                |
+---------------------+---------------------+
|   even sector (2n)  |  odd sector (2n+1)  |
+---+---+---+---+---+-+-+---+---+---+---+---+
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| <- sound groups
+---+---+---+---+---+---+---+---+---+---+---+

A cluster is an aggregate of 32 audio sectors (176 sound groups) representing 2.04 seconds of stereo audio; it is the smallest unit of data that can be written to a MiniDisc. In the 3 byte packing, there are 14 bits allocated to the cluster number, 6 bits to the sector, and 4 bits to the soundgroup; this arrangement allows addressing of up to 9.2 hours of stereo audio.

Modifying the UTOC

  1. download the UTOC sectors 0 ... 2 from NetMD Device:
    pNetMd->prepareTOCManip();
    for (int i = 0; i < 3; i++)
    {
    tocData += pNetMd->readUTOCSector(static_cast<UTOCSector>(i));
    }
  2. create toc class instance and add some track data
    uint8_t *pData = new uint8_t[tocData.size()];
    for(size_t i = 0; i < tocData.size(); i++)
    {
    pData[i] = toc.at(i);
    }
    time_t now = 0;
    time(&now);
    netmd::CNetMdTOC utoc(8, 459'000, pData);
    utoc.addTrack(1, 60'000, "Funky Track One Minute Part #1", now);
    utoc.addTrack(2, 60'000, "Funky Track One Minute Part #2", now);
  3. upload changed TOC data to NetMD
    bool doit = true;
    for (int x = 0; x < 3; x++)
    {
    tocData.clear();
    addArrayData(tocData, &pData[2352 * x], 2352);
    if (pNetMD->writeUTOCSector(static_cast<UTOCSector>(x), tocData) == NETMDERR_NO_ERROR)
    {
    std::cout << "TOC sector " << x << " written!" << std::endl;
    }
    else
    {
    doit = false;
    }
    }
    if (doit)
    {
    pNetMD->finalizeTOC();
    }
    delete [] pData;