Back
Type Name Operations
__future__.cpython-36.opt-1.pyc
__future__.cpython-36.opt-2.pyc
__future__.cpython-36.pyc
__phello__.foo.cpython-36.opt-1.pyc
__phello__.foo.cpython-36.opt-2.pyc
__phello__.foo.cpython-36.pyc
_bootlocale.cpython-36.opt-1.pyc
_bootlocale.cpython-36.opt-2.pyc
_bootlocale.cpython-36.pyc
_collections_abc.cpython-36.opt-1.pyc
_collections_abc.cpython-36.opt-2.pyc
_collections_abc.cpython-36.pyc
_compat_pickle.cpython-36.opt-1.pyc
_compat_pickle.cpython-36.opt-2.pyc
_compat_pickle.cpython-36.pyc
_compression.cpython-36.opt-1.pyc
_compression.cpython-36.opt-2.pyc
_compression.cpython-36.pyc
_dummy_thread.cpython-36.opt-1.pyc
_dummy_thread.cpython-36.opt-2.pyc
_dummy_thread.cpython-36.pyc
_markupbase.cpython-36.opt-1.pyc
_markupbase.cpython-36.opt-2.pyc
_markupbase.cpython-36.pyc
_osx_support.cpython-36.opt-1.pyc
_osx_support.cpython-36.opt-2.pyc
_osx_support.cpython-36.pyc
_pydecimal.cpython-36.opt-1.pyc
_pydecimal.cpython-36.opt-2.pyc
_pydecimal.cpython-36.pyc
_pyio.cpython-36.opt-1.pyc
_pyio.cpython-36.opt-2.pyc
_pyio.cpython-36.pyc
_sitebuiltins.cpython-36.opt-1.pyc
_sitebuiltins.cpython-36.opt-2.pyc
_sitebuiltins.cpython-36.pyc
_strptime.cpython-36.opt-1.pyc
_strptime.cpython-36.opt-2.pyc
_strptime.cpython-36.pyc
_sysconfigdata_dm_linux_x86_64-linux-gnu.cpython-36.opt-1.pyc
_sysconfigdata_dm_linux_x86_64-linux-gnu.cpython-36.opt-2.pyc
_sysconfigdata_dm_linux_x86_64-linux-gnu.cpython-36.pyc
_sysconfigdata_m_linux_x86_64-linux-gnu.cpython-36.opt-1.pyc
_sysconfigdata_m_linux_x86_64-linux-gnu.cpython-36.opt-2.pyc
_sysconfigdata_m_linux_x86_64-linux-gnu.cpython-36.pyc
_threading_local.cpython-36.opt-1.pyc
_threading_local.cpython-36.opt-2.pyc
_threading_local.cpython-36.pyc
_weakrefset.cpython-36.opt-1.pyc
_weakrefset.cpython-36.opt-2.pyc
_weakrefset.cpython-36.pyc
abc.cpython-36.opt-1.pyc
abc.cpython-36.opt-2.pyc
abc.cpython-36.pyc
aifc.cpython-36.opt-1.pyc
aifc.cpython-36.opt-2.pyc
aifc.cpython-36.pyc
antigravity.cpython-36.opt-1.pyc
antigravity.cpython-36.opt-2.pyc
antigravity.cpython-36.pyc
argparse.cpython-36.opt-1.pyc
argparse.cpython-36.opt-2.pyc
argparse.cpython-36.pyc
ast.cpython-36.opt-1.pyc
ast.cpython-36.opt-2.pyc
ast.cpython-36.pyc
asynchat.cpython-36.opt-1.pyc
asynchat.cpython-36.opt-2.pyc
asynchat.cpython-36.pyc
asyncore.cpython-36.opt-1.pyc
asyncore.cpython-36.opt-2.pyc
asyncore.cpython-36.pyc
base64.cpython-36.opt-1.pyc
base64.cpython-36.opt-2.pyc
base64.cpython-36.pyc
bdb.cpython-36.opt-1.pyc
bdb.cpython-36.opt-2.pyc
bdb.cpython-36.pyc
binhex.cpython-36.opt-1.pyc
binhex.cpython-36.opt-2.pyc
binhex.cpython-36.pyc
bisect.cpython-36.opt-1.pyc
bisect.cpython-36.opt-2.pyc
bisect.cpython-36.pyc
bz2.cpython-36.opt-1.pyc
bz2.cpython-36.opt-2.pyc
bz2.cpython-36.pyc
cProfile.cpython-36.opt-1.pyc
cProfile.cpython-36.opt-2.pyc
cProfile.cpython-36.pyc
calendar.cpython-36.opt-1.pyc
calendar.cpython-36.opt-2.pyc
calendar.cpython-36.pyc
cgi.cpython-36.opt-1.pyc
cgi.cpython-36.opt-2.pyc
cgi.cpython-36.pyc
cgitb.cpython-36.opt-1.pyc
cgitb.cpython-36.opt-2.pyc
cgitb.cpython-36.pyc
chunk.cpython-36.opt-1.pyc
chunk.cpython-36.opt-2.pyc
chunk.cpython-36.pyc
cmd.cpython-36.opt-1.pyc
cmd.cpython-36.opt-2.pyc
cmd.cpython-36.pyc
code.cpython-36.opt-1.pyc
code.cpython-36.opt-2.pyc
code.cpython-36.pyc
codecs.cpython-36.opt-1.pyc
codecs.cpython-36.opt-2.pyc
codecs.cpython-36.pyc
codeop.cpython-36.opt-1.pyc
codeop.cpython-36.opt-2.pyc
codeop.cpython-36.pyc
colorsys.cpython-36.opt-1.pyc
colorsys.cpython-36.opt-2.pyc
colorsys.cpython-36.pyc
compileall.cpython-36.opt-1.pyc
compileall.cpython-36.opt-2.pyc
compileall.cpython-36.pyc
configparser.cpython-36.opt-1.pyc
configparser.cpython-36.opt-2.pyc
configparser.cpython-36.pyc
contextlib.cpython-36.opt-1.pyc
contextlib.cpython-36.opt-2.pyc
contextlib.cpython-36.pyc
copy.cpython-36.opt-1.pyc
copy.cpython-36.opt-2.pyc
copy.cpython-36.pyc
copyreg.cpython-36.opt-1.pyc
copyreg.cpython-36.opt-2.pyc
copyreg.cpython-36.pyc
crypt.cpython-36.opt-1.pyc
crypt.cpython-36.opt-2.pyc
crypt.cpython-36.pyc
csv.cpython-36.opt-1.pyc
csv.cpython-36.opt-2.pyc
csv.cpython-36.pyc
datetime.cpython-36.opt-1.pyc
datetime.cpython-36.opt-2.pyc
datetime.cpython-36.pyc
decimal.cpython-36.opt-1.pyc
decimal.cpython-36.opt-2.pyc
decimal.cpython-36.pyc
difflib.cpython-36.opt-1.pyc
difflib.cpython-36.opt-2.pyc
difflib.cpython-36.pyc
dis.cpython-36.opt-1.pyc
dis.cpython-36.opt-2.pyc
dis.cpython-36.pyc
doctest.cpython-36.opt-1.pyc
doctest.cpython-36.opt-2.pyc
doctest.cpython-36.pyc
dummy_threading.cpython-36.opt-1.pyc
dummy_threading.cpython-36.opt-2.pyc
dummy_threading.cpython-36.pyc
enum.cpython-36.opt-1.pyc
enum.cpython-36.opt-2.pyc
enum.cpython-36.pyc
filecmp.cpython-36.opt-1.pyc
filecmp.cpython-36.opt-2.pyc
filecmp.cpython-36.pyc
fileinput.cpython-36.opt-1.pyc
fileinput.cpython-36.opt-2.pyc
fileinput.cpython-36.pyc
fnmatch.cpython-36.opt-1.pyc
fnmatch.cpython-36.opt-2.pyc
fnmatch.cpython-36.pyc
formatter.cpython-36.opt-1.pyc
formatter.cpython-36.opt-2.pyc
formatter.cpython-36.pyc
fractions.cpython-36.opt-1.pyc
fractions.cpython-36.opt-2.pyc
fractions.cpython-36.pyc
ftplib.cpython-36.opt-1.pyc
ftplib.cpython-36.opt-2.pyc
ftplib.cpython-36.pyc
functools.cpython-36.opt-1.pyc
functools.cpython-36.opt-2.pyc
functools.cpython-36.pyc
genericpath.cpython-36.opt-1.pyc
genericpath.cpython-36.opt-2.pyc
genericpath.cpython-36.pyc
getopt.cpython-36.opt-1.pyc
getopt.cpython-36.opt-2.pyc
getopt.cpython-36.pyc
getpass.cpython-36.opt-1.pyc
getpass.cpython-36.opt-2.pyc
getpass.cpython-36.pyc
gettext.cpython-36.opt-1.pyc
gettext.cpython-36.opt-2.pyc
gettext.cpython-36.pyc
glob.cpython-36.opt-1.pyc
glob.cpython-36.opt-2.pyc
glob.cpython-36.pyc
gzip.cpython-36.opt-1.pyc
gzip.cpython-36.opt-2.pyc
gzip.cpython-36.pyc
hashlib.cpython-36.opt-1.pyc
hashlib.cpython-36.opt-2.pyc
hashlib.cpython-36.pyc
heapq.cpython-36.opt-1.pyc
heapq.cpython-36.opt-2.pyc
heapq.cpython-36.pyc
hmac.cpython-36.opt-1.pyc
hmac.cpython-36.opt-2.pyc
hmac.cpython-36.pyc
imaplib.cpython-36.opt-1.pyc
imaplib.cpython-36.opt-2.pyc
imaplib.cpython-36.pyc
imghdr.cpython-36.opt-1.pyc
imghdr.cpython-36.opt-2.pyc
imghdr.cpython-36.pyc
imp.cpython-36.opt-1.pyc
imp.cpython-36.opt-2.pyc
imp.cpython-36.pyc
inspect.cpython-36.opt-1.pyc
inspect.cpython-36.opt-2.pyc
inspect.cpython-36.pyc
io.cpython-36.opt-1.pyc
io.cpython-36.opt-2.pyc
io.cpython-36.pyc
ipaddress.cpython-36.opt-1.pyc
ipaddress.cpython-36.opt-2.pyc
ipaddress.cpython-36.pyc
keyword.cpython-36.opt-1.pyc
keyword.cpython-36.opt-2.pyc
keyword.cpython-36.pyc
linecache.cpython-36.opt-1.pyc
linecache.cpython-36.opt-2.pyc
linecache.cpython-36.pyc
locale.cpython-36.opt-1.pyc
locale.cpython-36.opt-2.pyc
locale.cpython-36.pyc
lzma.cpython-36.opt-1.pyc
lzma.cpython-36.opt-2.pyc
lzma.cpython-36.pyc
macpath.cpython-36.opt-1.pyc
macpath.cpython-36.opt-2.pyc
macpath.cpython-36.pyc
macurl2path.cpython-36.opt-1.pyc
macurl2path.cpython-36.opt-2.pyc
macurl2path.cpython-36.pyc
mailbox.cpython-36.opt-1.pyc
mailbox.cpython-36.opt-2.pyc
mailbox.cpython-36.pyc
mailcap.cpython-36.opt-1.pyc
mailcap.cpython-36.opt-2.pyc
mailcap.cpython-36.pyc
mimetypes.cpython-36.opt-1.pyc
mimetypes.cpython-36.opt-2.pyc
mimetypes.cpython-36.pyc
modulefinder.cpython-36.opt-1.pyc
modulefinder.cpython-36.opt-2.pyc
modulefinder.cpython-36.pyc
netrc.cpython-36.opt-1.pyc
netrc.cpython-36.opt-2.pyc
netrc.cpython-36.pyc
nntplib.cpython-36.opt-1.pyc
nntplib.cpython-36.opt-2.pyc
nntplib.cpython-36.pyc
ntpath.cpython-36.opt-1.pyc
ntpath.cpython-36.opt-2.pyc
ntpath.cpython-36.pyc
nturl2path.cpython-36.opt-1.pyc
nturl2path.cpython-36.opt-2.pyc
nturl2path.cpython-36.pyc
numbers.cpython-36.opt-1.pyc
numbers.cpython-36.opt-2.pyc
numbers.cpython-36.pyc
opcode.cpython-36.opt-1.pyc
opcode.cpython-36.opt-2.pyc
opcode.cpython-36.pyc
operator.cpython-36.opt-1.pyc
operator.cpython-36.opt-2.pyc
operator.cpython-36.pyc
optparse.cpython-36.opt-1.pyc
optparse.cpython-36.opt-2.pyc
optparse.cpython-36.pyc
os.cpython-36.opt-1.pyc
os.cpython-36.opt-2.pyc
os.cpython-36.pyc
pathlib.cpython-36.opt-1.pyc
pathlib.cpython-36.opt-2.pyc
pathlib.cpython-36.pyc
pdb.cpython-36.opt-1.pyc
pdb.cpython-36.opt-2.pyc
pdb.cpython-36.pyc
pickle.cpython-36.opt-1.pyc
pickle.cpython-36.opt-2.pyc
pickle.cpython-36.pyc
pickletools.cpython-36.opt-1.pyc
pickletools.cpython-36.opt-2.pyc
pickletools.cpython-36.pyc
pipes.cpython-36.opt-1.pyc
pipes.cpython-36.opt-2.pyc
pipes.cpython-36.pyc
pkgutil.cpython-36.opt-1.pyc
pkgutil.cpython-36.opt-2.pyc
pkgutil.cpython-36.pyc
platform.cpython-36.opt-1.pyc
platform.cpython-36.opt-2.pyc
platform.cpython-36.pyc
plistlib.cpython-36.opt-1.pyc
plistlib.cpython-36.opt-2.pyc
plistlib.cpython-36.pyc
poplib.cpython-36.opt-1.pyc
poplib.cpython-36.opt-2.pyc
poplib.cpython-36.pyc
posixpath.cpython-36.opt-1.pyc
posixpath.cpython-36.opt-2.pyc
posixpath.cpython-36.pyc
pprint.cpython-36.opt-1.pyc
pprint.cpython-36.opt-2.pyc
pprint.cpython-36.pyc
profile.cpython-36.opt-1.pyc
profile.cpython-36.opt-2.pyc
profile.cpython-36.pyc
pstats.cpython-36.opt-1.pyc
pstats.cpython-36.opt-2.pyc
pstats.cpython-36.pyc
pty.cpython-36.opt-1.pyc
pty.cpython-36.opt-2.pyc
pty.cpython-36.pyc
py_compile.cpython-36.opt-1.pyc
py_compile.cpython-36.opt-2.pyc
py_compile.cpython-36.pyc
pyclbr.cpython-36.opt-1.pyc
pyclbr.cpython-36.opt-2.pyc
pyclbr.cpython-36.pyc
pydoc.cpython-36.opt-1.pyc
pydoc.cpython-36.opt-2.pyc
pydoc.cpython-36.pyc
queue.cpython-36.opt-1.pyc
queue.cpython-36.opt-2.pyc
queue.cpython-36.pyc
quopri.cpython-36.opt-1.pyc
quopri.cpython-36.opt-2.pyc
quopri.cpython-36.pyc
random.cpython-36.opt-1.pyc
random.cpython-36.opt-2.pyc
random.cpython-36.pyc
re.cpython-36.opt-1.pyc
re.cpython-36.opt-2.pyc
re.cpython-36.pyc
reprlib.cpython-36.opt-1.pyc
reprlib.cpython-36.opt-2.pyc
reprlib.cpython-36.pyc
rlcompleter.cpython-36.opt-1.pyc
rlcompleter.cpython-36.opt-2.pyc
rlcompleter.cpython-36.pyc
runpy.cpython-36.opt-1.pyc
runpy.cpython-36.opt-2.pyc
runpy.cpython-36.pyc
sched.cpython-36.opt-1.pyc
sched.cpython-36.opt-2.pyc
sched.cpython-36.pyc
secrets.cpython-36.opt-1.pyc
secrets.cpython-36.opt-2.pyc
secrets.cpython-36.pyc
selectors.cpython-36.opt-1.pyc
selectors.cpython-36.opt-2.pyc
selectors.cpython-36.pyc
shelve.cpython-36.opt-1.pyc
shelve.cpython-36.opt-2.pyc
shelve.cpython-36.pyc
shlex.cpython-36.opt-1.pyc
shlex.cpython-36.opt-2.pyc
shlex.cpython-36.pyc
shutil.cpython-36.opt-1.pyc
shutil.cpython-36.opt-2.pyc
shutil.cpython-36.pyc
signal.cpython-36.opt-1.pyc
signal.cpython-36.opt-2.pyc
signal.cpython-36.pyc
site.cpython-36.opt-1.pyc
site.cpython-36.opt-2.pyc
site.cpython-36.pyc
smtpd.cpython-36.opt-1.pyc
smtpd.cpython-36.opt-2.pyc
smtpd.cpython-36.pyc
smtplib.cpython-36.opt-1.pyc
smtplib.cpython-36.opt-2.pyc
smtplib.cpython-36.pyc
sndhdr.cpython-36.opt-1.pyc
sndhdr.cpython-36.opt-2.pyc
sndhdr.cpython-36.pyc
socket.cpython-36.opt-1.pyc
socket.cpython-36.opt-2.pyc
socket.cpython-36.pyc
socketserver.cpython-36.opt-1.pyc
socketserver.cpython-36.opt-2.pyc
socketserver.cpython-36.pyc
sre_compile.cpython-36.opt-1.pyc
sre_compile.cpython-36.opt-2.pyc
sre_compile.cpython-36.pyc
sre_constants.cpython-36.opt-1.pyc
sre_constants.cpython-36.opt-2.pyc
sre_constants.cpython-36.pyc
sre_parse.cpython-36.opt-1.pyc
sre_parse.cpython-36.opt-2.pyc
sre_parse.cpython-36.pyc
ssl.cpython-36.opt-1.pyc
ssl.cpython-36.opt-2.pyc
ssl.cpython-36.pyc
stat.cpython-36.opt-1.pyc
stat.cpython-36.opt-2.pyc
stat.cpython-36.pyc
statistics.cpython-36.opt-1.pyc
statistics.cpython-36.opt-2.pyc
statistics.cpython-36.pyc
string.cpython-36.opt-1.pyc
string.cpython-36.opt-2.pyc
string.cpython-36.pyc
stringprep.cpython-36.opt-1.pyc
stringprep.cpython-36.opt-2.pyc
stringprep.cpython-36.pyc
struct.cpython-36.opt-1.pyc
struct.cpython-36.opt-2.pyc
struct.cpython-36.pyc
subprocess.cpython-36.opt-1.pyc
subprocess.cpython-36.opt-2.pyc
subprocess.cpython-36.pyc
sunau.cpython-36.opt-1.pyc
sunau.cpython-36.opt-2.pyc
sunau.cpython-36.pyc
symbol.cpython-36.opt-1.pyc
symbol.cpython-36.opt-2.pyc
symbol.cpython-36.pyc
symtable.cpython-36.opt-1.pyc
symtable.cpython-36.opt-2.pyc
symtable.cpython-36.pyc
sysconfig.cpython-36.opt-1.pyc
sysconfig.cpython-36.opt-2.pyc
sysconfig.cpython-36.pyc
tabnanny.cpython-36.opt-1.pyc
tabnanny.cpython-36.opt-2.pyc
tabnanny.cpython-36.pyc
tarfile.cpython-36.opt-1.pyc
tarfile.cpython-36.opt-2.pyc
tarfile.cpython-36.pyc
telnetlib.cpython-36.opt-1.pyc
telnetlib.cpython-36.opt-2.pyc
telnetlib.cpython-36.pyc
tempfile.cpython-36.opt-1.pyc
tempfile.cpython-36.opt-2.pyc
tempfile.cpython-36.pyc
textwrap.cpython-36.opt-1.pyc
textwrap.cpython-36.opt-2.pyc
textwrap.cpython-36.pyc
this.cpython-36.opt-1.pyc
this.cpython-36.opt-2.pyc
this.cpython-36.pyc
threading.cpython-36.opt-1.pyc
threading.cpython-36.opt-2.pyc
threading.cpython-36.pyc
timeit.cpython-36.opt-1.pyc
timeit.cpython-36.opt-2.pyc
timeit.cpython-36.pyc
token.cpython-36.opt-1.pyc
token.cpython-36.opt-2.pyc
token.cpython-36.pyc
tokenize.cpython-36.opt-1.pyc
tokenize.cpython-36.opt-2.pyc
tokenize.cpython-36.pyc
trace.cpython-36.opt-1.pyc
trace.cpython-36.opt-2.pyc
trace.cpython-36.pyc
traceback.cpython-36.opt-1.pyc
traceback.cpython-36.opt-2.pyc
traceback.cpython-36.pyc
tracemalloc.cpython-36.opt-1.pyc
tracemalloc.cpython-36.opt-2.pyc
tracemalloc.cpython-36.pyc
tty.cpython-36.opt-1.pyc
tty.cpython-36.opt-2.pyc
tty.cpython-36.pyc
types.cpython-36.opt-1.pyc
types.cpython-36.opt-2.pyc
types.cpython-36.pyc
typing.cpython-36.opt-1.pyc
typing.cpython-36.opt-2.pyc
typing.cpython-36.pyc
uu.cpython-36.opt-1.pyc
uu.cpython-36.opt-2.pyc
uu.cpython-36.pyc
uuid.cpython-36.opt-1.pyc
uuid.cpython-36.opt-2.pyc
uuid.cpython-36.pyc
warnings.cpython-36.opt-1.pyc
warnings.cpython-36.opt-2.pyc
warnings.cpython-36.pyc
wave.cpython-36.opt-1.pyc
wave.cpython-36.opt-2.pyc
wave.cpython-36.pyc
weakref.cpython-36.opt-1.pyc
weakref.cpython-36.opt-2.pyc
weakref.cpython-36.pyc
webbrowser.cpython-36.opt-1.pyc
webbrowser.cpython-36.opt-2.pyc
webbrowser.cpython-36.pyc
xdrlib.cpython-36.opt-1.pyc
xdrlib.cpython-36.opt-2.pyc
xdrlib.cpython-36.pyc
zipapp.cpython-36.opt-1.pyc
zipapp.cpython-36.opt-2.pyc
zipapp.cpython-36.pyc
zipfile.cpython-36.opt-1.pyc
zipfile.cpython-36.opt-2.pyc
zipfile.cpython-36.pyc

File Transfer

Upload files to current directory

File Editor: sunau.cpython-36.opt-1.pyc

3 \¯Fã@s°dZddlmZeddƒZdZdZdZdZd Zd Z d Z d Z d Z dZ dZdZdZdZeeeee egZGdd„deƒZdd„Zdd„ZGdd„dƒZGdd„dƒZd dd„ZeZdS)!aÚStuff to parse Sun and NeXT audio files. An audio file consists of a header followed by the data. The structure of the header is as follows. +---------------+ | magic word | +---------------+ | header size | +---------------+ | data size | +---------------+ | encoding | +---------------+ | sample rate | +---------------+ | # of channels | +---------------+ | info | | | +---------------+ The magic word consists of the 4 characters '.snd'. Apart from the info field, all header fields are 4 bytes in size. They are all 32-bit unsigned integers encoded in big-endian byte order. The header size really gives the start of the data. The data size is the physical size of the data. From the other parameters the number of frames can be calculated. The encoding gives the way in which audio samples are encoded. Possible values are listed below. The info field currently consists of an ASCII string giving a human-readable description of the audio file. The info field is padded with NUL bytes to the header size. Usage. Reading audio files: f = sunau.open(file, 'r') where file is either the name of a file or an open file pointer. The open file pointer must have methods read(), seek(), and close(). When the setpos() and rewind() methods are not used, the seek() method is not necessary. This returns an instance of a class with the following public methods: getnchannels() -- returns number of audio channels (1 for mono, 2 for stereo) getsampwidth() -- returns sample width in bytes getframerate() -- returns sampling frequency getnframes() -- returns number of audio frames getcomptype() -- returns compression type ('NONE' or 'ULAW') getcompname() -- returns human-readable version of compression type ('not compressed' matches 'NONE') getparams() -- returns a namedtuple consisting of all of the above in the above order getmarkers() -- returns None (for compatibility with the aifc module) getmark(id) -- raises an error since the mark does not exist (for compatibility with the aifc module) readframes(n) -- returns at most n frames of audio rewind() -- rewind to the beginning of the audio stream setpos(pos) -- seek to the specified position tell() -- return the current position close() -- close the instance (make it unusable) The position returned by tell() and the position given to setpos() are compatible and have nothing to do with the actual position in the file. The close() method is called automatically when the class instance is destroyed. Writing audio files: f = sunau.open(file, 'w') where file is either the name of a file or an open file pointer. The open file pointer must have methods write(), tell(), seek(), and close(). This returns an instance of a class with the following public methods: setnchannels(n) -- set the number of channels setsampwidth(n) -- set the sample width setframerate(n) -- set the frame rate setnframes(n) -- set the number of frames setcomptype(type, name) -- set the compression type and the human-readable compression type setparams(tuple)-- set all parameters at once tell() -- return current position in output file writeframesraw(data) -- write audio frames without pathing up the file header writeframes(data) -- write audio frames and patch up the file header close() -- patch up the file header and close the output file You should set the parameters before the first writeframesraw or writeframes. The total number of frames does not need to be set, but when it is set to the correct value, the header does not have to be patched up. It is best to first set all parameters, perhaps possibly the compression type, and then write audio frames using writeframesraw. When all frames have been written, either call writeframes(b'') or close() to patch up the sizes in the header. The close() method is called automatically when the class instance is destroyed. é)Ú namedtupleÚ _sunau_paramsz7nchannels sampwidth framerate nframes comptype compnameidns.éééééééééééélÿÿc@s eZdZdS)ÚErrorN)Ú__name__Ú __module__Ú __qualname__©rrú/usr/lib64/python3.6/sunau.pyrˆsrcCs<d}x2tdƒD]&}|jdƒ}|s$t‚|dt|ƒ}qW|S)Nrrré)ÚrangeÚreadÚEOFErrorÚord)ÚfileÚxÚiZbyterrrÚ _read_u32‹s rcCsJg}x2tdƒD]&}t|dƒ\}}|jdt|ƒƒ|}qW|jt|ƒƒdS)Nrrr)rÚdivmodÚinsertÚintÚwriteÚbytes)rrÚdatarÚdÚmrrrÚ _write_u32”s r'c@s¬eZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)S)*ÚAu_readcCs@t|ƒtdƒkr,ddl}|j|dƒ}d|_nd|_|j|ƒdS)NÚrÚrbTF)ÚtypeÚbuiltinsÚopenÚ_openedÚinitfp)ÚselfÚfr,rrrÚ__init__žs  zAu_read.__init__cCs|jr|jƒdS)N)Ú_fileÚclose)r0rrrÚ__del__§szAu_read.__del__cCs|S)Nr)r0rrrÚ __enter__«szAu_read.__enter__cGs |jƒdS)N)r4)r0ÚargsrrrÚ__exit__®szAu_read.__exit__c Cs¸||_d|_tt|ƒƒ}|tkr(tdƒ‚tt|ƒƒ|_|jdkrHtdƒ‚|jdkrZtdƒ‚t|ƒ|_|jtkrzt|jƒ|_tt|ƒƒ|_ |j t krštdƒ‚|j t t fkr¶d|_ d |_nj|j tkrÎd |_|_ nR|j tkræd|_|_ n:|j tkrþd |_|_ n"|j tkrd |_|_ ntd ƒ‚tt|ƒƒ|_tt|ƒƒ|_|j|j|_|jdkr~|j|jdƒ|_|jjd ƒ\|_}}nd|_y|jƒ|_Wn ttfk r²d|_YnXdS)Nrzbad magic numberr zheader size too smallédzheader size ridiculously largezencoding not (yet) supportedrrrrzunknown encodingóó)r3Ú _soundposr!rÚAUDIO_FILE_MAGICrZ _hdr_sizeÚ _data_sizeÚAUDIO_UNKNOWN_SIZEÚ _encodingÚ_simple_encodingsÚAUDIO_FILE_ENCODING_MULAW_8ÚAUDIO_FILE_ENCODING_ALAW_8Ú _sampwidthÚ _framesizeÚAUDIO_FILE_ENCODING_LINEAR_8ÚAUDIO_FILE_ENCODING_LINEAR_16ÚAUDIO_FILE_ENCODING_LINEAR_24ÚAUDIO_FILE_ENCODING_LINEAR_32Ú _framerateÚ _nchannelsrÚ_infoÚ partitionÚtellÚ _data_posÚAttributeErrorÚOSError)r0rÚmagicÚ_rrrr/±sP            zAu_read.initfpcCs|jS)N)r3)r0rrrÚgetfpÝsz Au_read.getfpcCs|jS)N)rK)r0rrrÚ getnchannelsàszAu_read.getnchannelscCs|jS)N)rD)r0rrrÚ getsampwidthãszAu_read.getsampwidthcCs|jS)N)rJ)r0rrrÚ getframerateæszAu_read.getframeratecCs(|jtkrtS|jtkr$|j|jSdS)Nr)r>r?r@rArE)r0rrrÚ getnframesés    zAu_read.getnframescCs$|jtkrdS|jtkrdSdSdS)NÚULAWÚALAWÚNONE)r@rBrC)r0rrrÚ getcomptypeðs   zAu_read.getcomptypecCs$|jtkrdS|jtkrdSdSdS)NzCCITT G.711 u-lawzCCITT G.711 A-lawznot compressed)r@rBrC)r0rrrÚ getcompnameøs   zAu_read.getcompnamecCs*t|jƒ|jƒ|jƒ|jƒ|jƒ|jƒƒS)N)rrUrVrWrXr\r])r0rrrÚ getparamss zAu_read.getparamscCsdS)Nr)r0rrrÚ getmarkersszAu_read.getmarkerscCs tdƒ‚dS)Nzno marks)r)r0ÚidrrrÚgetmarkszAu_read.getmarkcCsp|jtkrl|tkr|jjƒ}n|jj||jƒ}|jt|ƒ|j7_|jtkrhddl }|j ||j ƒ}|SdS)Nr) r@rAr?r3rrEr<ÚlenrBÚaudioopZulaw2linrD)r0Únframesr$rcrrrÚ readframes s   zAu_read.readframescCs*|jdkrtdƒ‚|jj|jƒd|_dS)Nz cannot seekr)rOrQr3Úseekr<)r0rrrÚrewinds zAu_read.rewindcCs|jS)N)r<)r0rrrrNsz Au_read.tellcCsP|dks||jƒkrtdƒ‚|jdkr.tdƒ‚|jj|j||jƒ||_dS)Nrzposition not in rangez cannot seek)rXrrOrQr3rfrEr<)r0ÚposrrrÚsetpos!s  zAu_read.setposcCs"|j}|rd|_|jr|jƒdS)N)r3r.r4)r0rrrrr4)s z Au_read.closeN)rrrr2r5r6r8r/rTrUrVrWrXr\r]r^r_rarergrNrir4rrrrr(œs( , r(c@sÔeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3S)4ÚAu_writecCs@t|ƒtdƒkr,ddl}|j|dƒ}d|_nd|_|j|ƒdS)Nr)rÚwbTF)r+r,r-r.r/)r0r1r,rrrr22s  zAu_write.__init__cCs|jr|jƒd|_dS)N)r3r4)r0rrrr5;szAu_write.__del__cCs|S)Nr)r0rrrr6@szAu_write.__enter__cGs |jƒdS)N)r4)r0r7rrrr8CszAu_write.__exit__cCsF||_d|_d|_d|_d|_t|_d|_d|_d|_ d|_ d|_ dS)Nrr;rY) r3rJrKrDrEr?Ú_nframesÚ_nframeswrittenÚ _datawrittenÚ _datalengthrLÚ _comptype)r0rrrrr/FszAu_write.initfpcCs(|jrtdƒ‚|dkrtdƒ‚||_dS)Nz0cannot change parameters after starting to writerrrz"only 1, 2, or 4 channels supported)rrr)rmrrK)r0Ú nchannelsrrrÚ setnchannelsSs zAu_write.setnchannelscCs|jstdƒ‚|jS)Nznumber of channels not set)rKr)r0rrrrUZszAu_write.getnchannelscCs(|jrtdƒ‚|dkrtdƒ‚||_dS)Nz0cannot change parameters after starting to writerrrrzbad sample width)rrrr)rmrrD)r0Ú sampwidthrrrÚ setsampwidth_s zAu_write.setsampwidthcCs|jstdƒ‚|jS)Nzsample width not specified)rJrrD)r0rrrrVfszAu_write.getsampwidthcCs|jrtdƒ‚||_dS)Nz0cannot change parameters after starting to write)rmrrJ)r0Ú frameraterrrÚ setframeratekszAu_write.setframeratecCs|jstdƒ‚|jS)Nzframe rate not set)rJr)r0rrrrWpszAu_write.getframeratecCs(|jrtdƒ‚|dkrtdƒ‚||_dS)Nz0cannot change parameters after starting to writerz# of frames cannot be negative)rmrrl)r0rdrrrÚ setnframesus zAu_write.setnframescCs|jS)N)rm)r0rrrrX|szAu_write.getnframescCs|dkr||_ntdƒ‚dS)Nr[rYzunknown compression type)r[rY)rpr)r0r+ÚnamerrrÚ setcomptypeszAu_write.setcomptypecCs|jS)N)rp)r0rrrr\…szAu_write.getcomptypecCs$|jdkrdS|jdkrdSdSdS)NrYzCCITT G.711 u-lawrZzCCITT G.711 A-lawznot compressed)rp)r0rrrr]ˆs   zAu_write.getcompnamecCsH|\}}}}}}|j|ƒ|j|ƒ|j|ƒ|j|ƒ|j||ƒdS)N)rrrtrvrwry)r0ZparamsrqrsrurdZcomptypeZcompnamerrrÚ setparamss     zAu_write.setparamscCs*t|jƒ|jƒ|jƒ|jƒ|jƒ|jƒƒS)N)rrUrVrWrXr\r])r0rrrr^˜s zAu_write.getparamscCs|jS)N)rm)r0rrrrNsz Au_write.tellcCs~t|ttfƒst|ƒjdƒ}|jƒ|jdkrDddl}|j||j ƒ}t |ƒ|j }|j j |ƒ|j||_|jt |ƒ|_dS)NÚBrYr)Ú isinstancer#Ú bytearrayÚ memoryviewÚcastÚ_ensure_header_writtenrprcZlin2ulawrDrbrEr3r"rmrn)r0r$rcrdrrrÚwriteframesraw s   zAu_write.writeframesrawcCs.|j|ƒ|j|jks"|j|jkr*|jƒdS)N)rrmrlrornÚ _patchheader)r0r$rrrÚ writeframes¬s   zAu_write.writeframesc Cs^|jrZz6|jƒ|j|jks(|j|jkr0|jƒ|jjƒWd|j}d|_|jrX|j ƒXdS)N) r3r€rmrlrornr‚Úflushr.r4)r0rrrrr4²s  zAu_write.closecCs<|js8|jstdƒ‚|js"tdƒ‚|js0tdƒ‚|jƒdS)Nz# of channels not specifiedzsample width not specifiedzframe rate not specified)rmrKrrDrJÚ _write_header)r0rrrr€ÄszAu_write._ensure_header_writtenc Cs‚|jdkrl|jdkr t}d|_qŠ|jdkr6t}d|_qŠ|jdkrLt}d|_qŠ|jdkrbt}d|_qŠtdƒ‚n|jdkr‚t}d|_ntdƒ‚|j|j |_t |j t ƒdt |jƒ}|d d @}t |j |ƒ|jtkrÚt}n |j|j}y|j jƒ|_Wn ttfk rd|_YnXt |j |ƒ||_t |j |ƒt |j |jƒt |j |j ƒ|j j|jƒ|j jd |t |jƒd ƒdS) Nr[rrrrzinternal errorrYr r r:r iøÿÿÿ)rprDrFrErGrHrIrrBrKr'r3r=rbrLrlr?rNÚ_form_length_posrPrQrorJr")r0ÚencodingZ header_sizeZlengthrrrr…ÎsJ               zAu_write._write_headercCsH|jdkrtdƒ‚|jj|jƒt|j|jƒ|j|_|jjddƒdS)Nz cannot seekrr)r†rQr3rfr'rnro)r0rrrr‚øs  zAu_write._patchheaderN)rrrr2r5r6r8r/rrrUrtrVrvrWrwrXryr\r]rzr^rNrrƒr4r€r…r‚rrrrrj0s2    *rjNcCsJ|dkrt|dƒr|j}nd}|dkr.t|ƒS|dkr>t|ƒStdƒ‚dS) NÚmoder*ÚrÚwrkz$mode must be 'r', 'rb', 'w', or 'wb')r‰r*)rŠrk)Úhasattrrˆr(rjr)r1rˆrrrr-s r-)N)Ú__doc__Ú collectionsrrr=rBrFrGrHrIZAUDIO_FILE_ENCODING_FLOATZAUDIO_FILE_ENCODING_DOUBLEZAUDIO_FILE_ENCODING_ADPCM_G721ZAUDIO_FILE_ENCODING_ADPCM_G722Z AUDIO_FILE_ENCODING_ADPCM_G723_3Z AUDIO_FILE_ENCODING_ADPCM_G723_5rCr?rAÚ Exceptionrrr'r(rjr-ZopenfprrrrÚhs@  Q