def get_format_from_width(width, unsigned=True):
 if (width == 1):
  if unsigned:
   return paUInt8
  else:
   return paInt8
 elif (width == 2):
  return paInt16
 elif (width == 3):
  return paInt24
 elif (width == 4):
  return paFloat32
 else:
  raise ValueError(('Invalid width: %d' % width))

def get_format_from_width ( width , unsigned = True ) : if ( width == 1 ) : if unsigned : return paUInt8 else : return paInt8 elif ( width == 2 ) : return paInt16 elif ( width == 3 ) : return paInt24 elif ( width == 4 ) : return paFloat32 else : raise ValueError ( ( 'Invalid width: %d' % width ) )
returns a portaudio format constant for the specified *width* .