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

[pygame] How to check sound format of mixer?



I can't seem to find out how you check the sound format that mixer is
using. For example, when I request 8 bit signed format, I get 8 bit
unsigned, and all my samples sound terrible (they are raw samples so I
have to load them into a sndarray.) But to find this out, I had to
write a test in C using SDL_OpenAudio because even SDL_mixer cannot
seem to tell you this. Checking the struct output by SDL_OpenAudio
seems to be the only way to know, so if you don't call it yourself,
you can't know, and Mix_OpenAudio hides the output from
SDL_OpenAudio...

Also it would be nice to have a pygame.mixer.Sound.from_buffer()
function similar to the Surface.from_buffer() in that it does not
require Numeric. I don't have anything against sndarray and surfarray
but if you only need to convert your samples/images once it seems
unnecessary to add a further dependency on Numeric. In my case I'm
loading 1 bit bitmaps and converting them to 8 bit, and
imageop.mono2grey is fine for this. Unfortunately it would be much
less useful for sound without the ability to check mixer format, so if
anyone can solve that problem, I'll try to code from_buffer for
sounds.

-- 
Alistair Buxton
a.j.buxton@xxxxxxxxx