Tari.in
Soon on Cassette and Vinyl.
  • Nav
  • Bottom
  • Tux
  • Kowalski
  • Rico
  • Skipper
  • Private
  • Comment
  • Contact
  • Top
  • There are no visitor comments on this page

    Odio SACD (library)

    Intro

    The Odio SACD shared library is a decoding engine which takes a Super Audio CD source and extracts a 24-bit high resolution wave file. It handles both DST and DSD streams.

    The library reads the following input:

    Supported output sample rates:

    Usage

    Compilation

    #include <libodiosacd/libodiosacd.h>
    

    Linking

    LDFLAGS += -lodiosacd
    

    The API

    // 1. FUNCTIONS
    
    bool odiolibsacd_Open(char *sInFile, Area nArea)
    
    // Opens the decoder. You must call this before anything else.
    // Parameter sInFile: the path to the media
    // Parameter nArea: the disc area to decode
    // Returns: TRUE on error, FALSE otherwise
    
    DiscDetails* odiolibsacd_GetDiscDetails()
    
    // Returns information about the disc image.
    // Returns: a pointer to a DiscDetails structure
    
    int odiolibsacd_GetTrackCount(Area nArea)
    
    // Returns the track count for the requested area.
    // Parameter nArea: the disc area to query
    // Returns: -1 on error, the track count otherwise
    
    bool odiolibsacd_Convert(char *sOutDir, int nSampleRate, OnProgress pOnProgress, void *pUserData)
    
    // Start decoding the media.
    // Parameter sOutDir: the path to the output directory, or NULL to decode to the source directory
    // Parameter nSampleRate: the samplerate of the wave output - must be 88200 or 176400
    // Parameter pOnProgress: pointer to a progress callback function, or NULL
    // Parameter pUserData: pointer to any user data to pass to the progress callback function, or NULL
    // Returns: TRUE on error, FALSE otherwise
    
    void odiolibsacd_Close()
    
    // Closes the decoder. You must call this for every odiolibsacd_Open.
    
    // 2. THE PROGRESS CALLBACK
    
    bool funcName(float fProgress, char *sFilePath, int nTrack, void *pUserData)
    
    // If you pass this to odiolibsacd_Convert, it will be called every 1 second, plus every time an output file has completed.
    // Parameter fProgress: the percent completed so far
    // Parameter sFilePath: whenever an output file completes, it returns its path, otherwise NULL
    // Parameter nTrack: whenever an output file completes, it returns its track number, otherwise -1
    // Parameter pUserData: the user data you have passed to odiolibsacd_Convert
    // Returns: TRUE to continue, FALSE to calcel decoding
    
    // 3. PRE-DEFINED STRUCTURES
    
    typedef struct
    {
        char *sAlbumTitle; // The album title, check for empty and NULL
        char *sAlbumArtist; // The album artist, check for empty and NULL
        char *sAlbumPublisher; // The album publisher, check for empty and NULL
        char *sAlbumCopyright; // The album copyright, check for empty and NULL
        int nTwoChTracks; // The number of tracks in the stereo area
        int nMulChTracks; // The number of tracks in the multichannel area
        TrackDetails *lTwoChTrackDetails; // An array of TrackDetails for the stereo area, or NULL if nTwoChTracks is 0
        TrackDetails *lMulChTrackDetails; // An array of TrackDetails for the multichannel area, or NULL if nMulChTracks is 0
    
    } DiscDetails;
    
    typedef struct
    {
        char *sTrackTitle; // The track title, check for empty and NULL
        char *sTrackPerformer; // The track performer, check for empty and NULL
        int nChannels; // The number of channels
    
    } TrackDetails;
    
    // 4. PRE-DEFINED CONSTANTS
    
    typedef enum
    {
        AREA_BOTH = 0, // Both areas
        AREA_TWOCH = 1, // The stereo area
        AREA_MULCH = 2, // The multichannel area
        AREA_AUTO = 3 // The multichannel area, if it exists, otherwise the stereo area. If both areas exist and the track counts are not equal, then both areas.
    
    } Area;
    

    API bonus: a Python example

    #!/usr/bin/env python3
    # -*- coding: utf-8 -*-
    
    import sys
    import ctypes
    
    if __name__ == '__main__':
    
        AREA_TWOCH = 1
        AREA_MULCH = 2
        AREA_AUTO = 3
    
        class TrackDetails(ctypes.Structure):
    
            _fields_ = [('sTrackTitle', ctypes.c_char_p), ('sTrackPerformer', ctypes.c_char_p), ('nChannels', ctypes.c_int)]
    
        class DiscDetails(ctypes.Structure):
    
            _fields_ = [('sAlbumTitle', ctypes.c_char_p), ('sAlbumArtist', ctypes.c_char_p), ('sAlbumPublisher', ctypes.c_char_p), ('sAlbumCopyright', ctypes.c_char_p), ('nTwoChTracks', ctypes.c_int), ('nMulChTracks', ctypes.c_int), ('lTwoChTrackDetails', ctypes.POINTER(TrackDetails)), ('lMulChTrackDetails', ctypes.POINTER(TrackDetails))]
    
        OnProgress = ctypes.CFUNCTYPE(ctypes.c_bool, ctypes.c_float, ctypes.c_char_p, ctypes.c_int, ctypes.c_void_p)
    
    
        def onProgress(fProgress, sFilePath, nTrack, pUserData = None):
    
            print(fProgress, sFilePath, nTrack, pUserData)
    
            return True
    
        sInPath = b'/path/to/an/sacd.iso'
        sOutPath = b'/path/to/outdir'
        nSampleRate = 88200
        pOnProgress = OnProgress(onProgress)
        pUserData = None
    
        oLibOdioSacd = ctypes.cdll.LoadLibrary('/usr/lib/libodiosacd.so')
        bError = oLibOdioSacd.odiolibsacd_Open(sInPath, AREA_AUTO)
        oLibOdioSacd.odiolibsacd_GetDiscDetails.restype = ctypes.POINTER(DiscDetails)
    
        pDiscDetails = oLibOdioSacd.odiolibsacd_GetDiscDetails(sInPath).contents
        print(pDiscDetails.lTwoChTrackDetails[5].sTrackTitle)
    
        bError = oLibOdioSacd.odiolibsacd_Convert(sOutPath, nSampleRate, pOnProgress, pUserData)
        oLibOdioSacd.odiolibsacd_Close()
    
        sys.exit(0)
    

    Installation

    Arch > Manjaro > etc.

    pamac build libodiosacd
    

    From source

    Dependencies [1][2]

    [1] The package names may slightly vary among various Linux flavours
    [2] Some Linux flavours package development libraries separately, while some have them as part of the base package.

    git clone https://github.com/tari01/libodiosacd.git
    cd libodiosacd
    mkdir build
    cd build
    cmake ..
    make
    sudo make install
    

    Links

    Report a bug/request a feature/ask a question
    Browse the source code

    Comments

    If you only wish to leave a comment, do so by using the button at the top of this page.

    Add your comment to this page

    Note: If you wish to report a bug, request a feature, or ask a question about an application - please do so by using the appropriate GitHub link on the application's page.

    1 + 9 =
    Please wait, this could take a second...