def gethdr(fp):
 if (fp.read(4) != MAGIC):
  raise error, 'gethdr: bad magic word'
 hdr_size = get_long_be(fp.read(4))
 data_size = get_long_be(fp.read(4))
 encoding = get_long_be(fp.read(4))
 sample_rate = get_long_be(fp.read(4))
 channels = get_long_be(fp.read(4))
 excess = (hdr_size - 24)
 if (excess < 0):
  raise error, 'gethdr: bad hdr_size'
 if (excess > 0):
  info = fp.read(excess)
 else:
  info = ''
 return (data_size, encoding, sample_rate, channels, info)

def gethdr ( fp ) : if ( fp . read ( 4 ) != MAGIC ) : raise error , 'gethdr: bad magic word' hdr_size = get_long_be ( fp . read ( 4 ) ) data_size = get_long_be ( fp . read ( 4 ) ) encoding = get_long_be ( fp . read ( 4 ) ) sample_rate = get_long_be ( fp . read ( 4 ) ) channels = get_long_be ( fp . read ( 4 ) ) excess = ( hdr_size - 24 ) if ( excess < 0 ) : raise error , 'gethdr: bad hdr_size' if ( excess > 0 ) : info = fp . read ( excess ) else : info = '' return ( data_size , encoding , sample_rate , channels , info )
read a sound header from an open file .