[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] [BUG] mixer.init() mixer.get_init() inconsistancies 1.8.0



Here's a simple test showing inconsistancies in pygame.mixer in 1.8.0

from pygame import mixer

sample_rates = [11025, 22050, 44100, 48000]
sample_widths = [-16, -8, 8] # 16 unsupported
channel_nums = [1, 2]
for sample_rate in sample_rates:
    for sample_width in sample_widths:
        for channel_num in channel_nums:
            conf = (sample_rate, sample_width, channel_num)
            mixer.init(*conf)
            mixer_conf = mixer.get_init()
            print "Tried %s, got %s" % (conf, mixer_conf)
            print "Sample rate equal? %s" % (conf[0] ==
mixer_conf[0],)
            print "Sample width equal? %s" % (conf[1] ==
mixer_conf[1],)
            print "Sample number of output channels equal? %s" %
(conf[2] == mixer_conf[2],)
            mixer.quit()

Number of output channels is never equal, as the number returned by
mixer.get_init() is 1 for stereo and 0 for everything else. This as an
internal inconsistancy wouldn't be so bad, however it is also
inconsistant with the documentation, which suggests mixer.get_init()
returns the same format as mixer.init(...) takes.

Sample widths of -8 are always output by mixer.get_init() as 8 and
despite suggestions from the documentation +16 (ie unsigned 16 bit
samples) are not supported.