Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
Au_write Class Reference

Public Member Functions

def __init__
 
def __del__
 
def initfp
 
def setnchannels
 
def getnchannels
 
def setsampwidth
 
def getsampwidth
 
def setframerate
 
def getframerate
 
def setnframes
 
def getnframes
 
def setcomptype
 
def getcomptype
 
def getcompname
 
def setparams
 
def getparams
 
def tell
 
def writeframesraw
 
def writeframes
 
def close
 

Detailed Description

Definition at line 281 of file sunau.py.

Constructor & Destructor Documentation

def __init__ (   self,
  f 
)

Definition at line 283 of file sunau.py.

284  def __init__(self, f):
285  if type(f) == type(''):
286  import __builtin__
287  f = __builtin__.open(f, 'wb')
288  self.initfp(f)
def __del__ (   self)

Definition at line 289 of file sunau.py.

290  def __del__(self):
291  if self._file:
292  self.close()

Member Function Documentation

def close (   self)

Definition at line 398 of file sunau.py.

399  def close(self):
401  if self._nframeswritten != self._nframes or \
402  self._datalength != self._datawritten:
403  self._patchheader()
404  self._file.flush()
405  self._file = None
def getcompname (   self)

Definition at line 359 of file sunau.py.

360  def getcompname(self):
361  if self._comptype == 'ULAW':
362  return 'CCITT G.711 u-law'
363  elif self._comptype == 'ALAW':
364  return 'CCITT G.711 A-law'
365  else:
366  return 'not compressed'
def getcomptype (   self)

Definition at line 356 of file sunau.py.

357  def getcomptype(self):
358  return self._comptype
def getframerate (   self)

Definition at line 335 of file sunau.py.

336  def getframerate(self):
337  if not self._framerate:
338  raise Error, 'frame rate not set'
339  return self._framerate
def getnchannels (   self)

Definition at line 313 of file sunau.py.

314  def getnchannels(self):
315  if not self._nchannels:
316  raise Error, 'number of channels not set'
317  return self._nchannels
def getnframes (   self)

Definition at line 347 of file sunau.py.

348  def getnframes(self):
349  return self._nframeswritten
def getparams (   self)

Definition at line 374 of file sunau.py.

375  def getparams(self):
376  return self.getnchannels(), self.getsampwidth(), \
377  self.getframerate(), self.getnframes(), \
378  self.getcomptype(), self.getcompname()
def getsampwidth (   self)

Definition at line 325 of file sunau.py.

326  def getsampwidth(self):
327  if not self._framerate:
328  raise Error, 'sample width not specified'
329  return self._sampwidth
def initfp (   self,
  file 
)

Definition at line 293 of file sunau.py.

294  def initfp(self, file):
295  self._file = file
296  self._framerate = 0
297  self._nchannels = 0
298  self._sampwidth = 0
299  self._framesize = 0
300  self._nframes = AUDIO_UNKNOWN_SIZE
301  self._nframeswritten = 0
302  self._datawritten = 0
303  self._datalength = 0
304  self._info = ''
305  self._comptype = 'ULAW' # default is U-law
def setcomptype (   self,
  type,
  name 
)

Definition at line 350 of file sunau.py.

351  def setcomptype(self, type, name):
352  if type in ('NONE', 'ULAW'):
353  self._comptype = type
354  else:
355  raise Error, 'unknown compression type'
def setframerate (   self,
  framerate 
)

Definition at line 330 of file sunau.py.

331  def setframerate(self, framerate):
332  if self._nframeswritten:
333  raise Error, 'cannot change parameters after starting to write'
334  self._framerate = framerate
def setnchannels (   self,
  nchannels 
)

Definition at line 306 of file sunau.py.

307  def setnchannels(self, nchannels):
308  if self._nframeswritten:
309  raise Error, 'cannot change parameters after starting to write'
310  if nchannels not in (1, 2, 4):
311  raise Error, 'only 1, 2, or 4 channels supported'
312  self._nchannels = nchannels
def setnframes (   self,
  nframes 
)

Definition at line 340 of file sunau.py.

341  def setnframes(self, nframes):
342  if self._nframeswritten:
343  raise Error, 'cannot change parameters after starting to write'
344  if nframes < 0:
345  raise Error, '# of frames cannot be negative'
346  self._nframes = nframes
def setparams (   self,
  nchannels,
  sampwidth,
  framerate,
  nframes,
  comptype,
  compname 
)

Definition at line 367 of file sunau.py.

368  def setparams(self, (nchannels, sampwidth, framerate, nframes, comptype, compname)):
369  self.setnchannels(nchannels)
370  self.setsampwidth(sampwidth)
371  self.setframerate(framerate)
372  self.setnframes(nframes)
373  self.setcomptype(comptype, compname)
def setsampwidth (   self,
  sampwidth 
)

Definition at line 318 of file sunau.py.

319  def setsampwidth(self, sampwidth):
320  if self._nframeswritten:
321  raise Error, 'cannot change parameters after starting to write'
322  if sampwidth not in (1, 2, 4):
323  raise Error, 'bad sample width'
324  self._sampwidth = sampwidth
def tell (   self)

Definition at line 379 of file sunau.py.

380  def tell(self):
381  return self._nframeswritten
def writeframes (   self,
  data 
)

Definition at line 392 of file sunau.py.

393  def writeframes(self, data):
394  self.writeframesraw(data)
395  if self._nframeswritten != self._nframes or \
396  self._datalength != self._datawritten:
397  self._patchheader()
def writeframesraw (   self,
  data 
)

Definition at line 382 of file sunau.py.

383  def writeframesraw(self, data):
385  nframes = len(data) / self._framesize
386  if self._comptype == 'ULAW':
387  import audioop
388  data = audioop.lin2ulaw(data, self._sampwidth)
389  self._file.write(data)
390  self._nframeswritten = self._nframeswritten + nframes
391  self._datawritten = self._datawritten + len(data)

The documentation for this class was generated from the following file: