{
    "mode": "pydoc",
    "parameter": "sunau",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/pydoc/sunau/json",
    "generated": "2026-06-02T15:06:43Z",
    "sections": {
        "NAME": {
            "content": "sunau - Stuff to parse Sun and NeXT audio files.\n",
            "subsections": []
        },
        "MODULE REFERENCE": {
            "content": "https://docs.python.org/3.10/library/sunau.html\n\nThe following documentation is automatically generated from the Python\nsource files.  It may be incomplete, incorrect or include features that\nare considered implementation detail and may vary between Python\nimplementations.  When in doubt, consult the module reference at the\nlocation listed above.\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "An audio file consists of a header followed by the data.  The structure\nof the header is as follows.\n\n+---------------+\n| magic word    |\n+---------------+\n| header size   |\n+---------------+\n| data size     |\n+---------------+\n| encoding      |\n+---------------+\n| sample rate   |\n+---------------+\n| # of channels |\n+---------------+\n| info          |\n|               |\n+---------------+\n\nThe magic word consists of the 4 characters '.snd'.  Apart from the\ninfo field, all header fields are 4 bytes in size.  They are all\n32-bit unsigned integers encoded in big-endian byte order.\n\nThe header size really gives the start of the data.\nThe data size is the physical size of the data.  From the other\nparameters the number of frames can be calculated.\nThe encoding gives the way in which audio samples are encoded.\nPossible values are listed below.\nThe info field currently consists of an ASCII string giving a\nhuman-readable description of the audio file.  The info field is\npadded with NUL bytes to the header size.\n\nUsage.\n\nReading audio files:\nf = sunau.open(file, 'r')\nwhere file is either the name of a file or an open file pointer.\nThe open file pointer must have methods read(), seek(), and close().\nWhen the setpos() and rewind() methods are not used, the seek()\nmethod is not  necessary.\n\nThis returns an instance of a class with the following public methods:\ngetnchannels()  -- returns number of audio channels (1 for\nmono, 2 for stereo)\ngetsampwidth()  -- returns sample width in bytes\ngetframerate()  -- returns sampling frequency\ngetnframes()    -- returns number of audio frames\ngetcomptype()   -- returns compression type ('NONE' or 'ULAW')\ngetcompname()   -- returns human-readable version of\ncompression type ('not compressed' matches 'NONE')\ngetparams()     -- returns a namedtuple consisting of all of the\nabove in the above order\ngetmarkers()    -- returns None (for compatibility with the\naifc module)\ngetmark(id)     -- raises an error since the mark does not\nexist (for compatibility with the aifc module)\nreadframes(n)   -- returns at most n frames of audio\nrewind()        -- rewind to the beginning of the audio stream\nsetpos(pos)     -- seek to the specified position\ntell()          -- return the current position\nclose()         -- close the instance (make it unusable)\nThe position returned by tell() and the position given to setpos()\nare compatible and have nothing to do with the actual position in the\nfile.\nThe close() method is called automatically when the class instance\nis destroyed.\n\nWriting audio files:\nf = sunau.open(file, 'w')\nwhere file is either the name of a file or an open file pointer.\nThe open file pointer must have methods write(), tell(), seek(), and",
            "subsections": [
                {
                    "name": "close",
                    "content": "This returns an instance of a class with the following public methods:\nsetnchannels(n) -- set the number of channels\nsetsampwidth(n) -- set the sample width\nsetframerate(n) -- set the frame rate\nsetnframes(n)   -- set the number of frames\nsetcomptype(type, name)\n-- set the compression type and the\nhuman-readable compression type\nsetparams(tuple)-- set all parameters at once\ntell()          -- return current position in output file\nwriteframesraw(data)\n-- write audio frames without pathing up the\nfile header\nwriteframes(data)\n-- write audio frames and patch up the file header\nclose()         -- patch up the file header and close the\noutput file\nYou should set the parameters before the first writeframesraw or\nwriteframes.  The total number of frames does not need to be set,\nbut when it is set to the correct value, the header does not have to\nbe patched up.\nIt is best to first set all parameters, perhaps possibly the\ncompression type, and then write audio frames using writeframesraw.\nWhen all frames have been written, either call writeframes(b'') or"
                },
                {
                    "name": "close",
                    "content": "The close() method is called automatically when the class instance\nis destroyed.\n"
                }
            ]
        },
        "CLASSES": {
            "content": "builtins.Exception(builtins.BaseException)\nError\nbuiltins.object\nAuread\nAuwrite\n",
            "subsections": [
                {
                    "name": "class Au_read",
                    "content": "|  Auread(f)\n|\n|  Methods defined here:\n|\n|  del(self)\n|\n|  enter(self)\n|\n|  exit(self, *args)\n|\n|  init(self, f)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  close(self)\n|\n|  getcompname(self)\n|\n|  getcomptype(self)\n|\n|  getfp(self)\n|\n|  getframerate(self)\n|\n|  getmark(self, id)\n|\n|  getmarkers(self)\n|\n|  getnchannels(self)\n|\n|  getnframes(self)\n|\n|  getparams(self)\n|\n|  getsampwidth(self)\n|\n|  initfp(self, file)\n|\n|  readframes(self, nframes)\n|\n|  rewind(self)\n|\n|  setpos(self, pos)\n|\n|  tell(self)\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class Au_write",
                    "content": "|  Auwrite(f)\n|\n|  Methods defined here:\n|\n|  del(self)\n|\n|  enter(self)\n|\n|  exit(self, *args)\n|\n|  init(self, f)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  close(self)\n|\n|  getcompname(self)\n|\n|  getcomptype(self)\n|\n|  getframerate(self)\n|\n|  getnchannels(self)\n|\n|  getnframes(self)\n|\n|  getparams(self)\n|\n|  getsampwidth(self)\n|\n|  initfp(self, file)\n|\n|  setcomptype(self, type, name)\n|\n|  setframerate(self, framerate)\n|\n|  setnchannels(self, nchannels)\n|\n|  setnframes(self, nframes)\n|\n|  setparams(self, params)\n|\n|  setsampwidth(self, sampwidth)\n|\n|  tell(self)\n|\n|  writeframes(self, data)\n|\n|  writeframesraw(self, data)\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors defined here:\n|\n|  dict\n|      dictionary for instance variables (if defined)\n|\n|  weakref\n|      list of weak references to the object (if defined)\n"
                },
                {
                    "name": "class Error",
                    "content": "|  Method resolution order:\n|      Error\n|      builtins.Exception\n|      builtins.BaseException\n|      builtins.object\n|\n|  Data descriptors defined here:\n|\n|  weakref\n|      list of weak references to the object (if defined)\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.Exception:\n|\n|  init(self, /, *args, kwargs)\n|      Initialize self.  See help(type(self)) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Static methods inherited from builtins.Exception:\n|\n|  new(*args, kwargs) from builtins.type\n|      Create and return a new object.  See help(type) for accurate signature.\n|\n|  ----------------------------------------------------------------------\n|  Methods inherited from builtins.BaseException:\n|\n|  delattr(self, name, /)\n|      Implement delattr(self, name).\n|\n|  getattribute(self, name, /)\n|      Return getattr(self, name).\n|\n|  reduce(...)\n|      Helper for pickle.\n|\n|  repr(self, /)\n|      Return repr(self).\n|\n|  setattr(self, name, value, /)\n|      Implement setattr(self, name, value).\n|\n|  setstate(...)\n|\n|  str(self, /)\n|      Return str(self).\n|\n|  withtraceback(...)\n|      Exception.withtraceback(tb) --\n|      set self.traceback to tb and return self.\n|\n|  ----------------------------------------------------------------------\n|  Data descriptors inherited from builtins.BaseException:\n|\n|  cause\n|      exception cause\n|\n|  context\n|      exception context\n|\n|  dict\n|\n|  suppresscontext\n|\n|  traceback\n|\n|  args\n"
                }
            ]
        },
        "FUNCTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "open",
                    "content": ""
                }
            ]
        },
        "DATA": {
            "content": "AUDIOFILEENCODINGADPCMG721 = 23\nAUDIOFILEENCODINGADPCMG722 = 24\nAUDIOFILEENCODINGADPCMG7233 = 25\nAUDIOFILEENCODINGADPCMG7235 = 26\nAUDIOFILEENCODINGALAW8 = 27\nAUDIOFILEENCODINGDOUBLE = 7\nAUDIOFILEENCODINGFLOAT = 6\nAUDIOFILEENCODINGLINEAR16 = 3\nAUDIOFILEENCODINGLINEAR24 = 4\nAUDIOFILEENCODINGLINEAR32 = 5\nAUDIOFILEENCODINGLINEAR8 = 2\nAUDIOFILEENCODINGMULAW8 = 1\nAUDIOFILEMAGIC = 779316836\nAUDIOUNKNOWNSIZE = 4294967295\n",
            "subsections": []
        },
        "FILE": {
            "content": "/usr/lib/python3.10/sunau.py\n\n",
            "subsections": []
        }
    },
    "summary": "sunau - Stuff to parse Sun and NeXT audio files.",
    "flags": [],
    "examples": [],
    "see_also": []
}