From the documentation using SDL2 Mixer to init the soundcard with 2 channels.

It will return 8 channels (7.1) and seems there is no way have just 2 channels.

here the snippet that i used simple as that:

    if (Mix_OpenAudio(44100, AUDIO_S16, 2, 1024) < 0) {
        cerr << Mix_GetError();
        return -1;

int freq;
uint16_t fmt;
int channels;
if (Mix_QuerySpec(&freq, &fmt, &channels) == 0) {
    cerr << "query return 0" << endl;
cout << "freq: " << freq << endl
    << "format: " << fmt << endl
    << "channels: " << channels << endl;

and channels are equal to 8. MY soundcard is a 7.1 so make sense, but shouldn't be init as stereo (2 ch) if required so?

Any help how to "force" to have just 2 channels? It seems like is my driver doesn't support normal stereo, that is quite weird to me. Any help would be appreciated

  • 1
    \$\begingroup\$ I believe that's not possible. SDL2_Mixer spec says there's no guarantee that the created device specs will match requested. \$\endgroup\$
    – Ocelot
    Nov 11 '20 at 12:16
  • \$\begingroup\$ Since the specification doesn't guarantee the # of channels returned will match the # requested, it would help to explain why you only want 2 channels. What is your end goal? How does getting more channels than expected interfere with the desired outcome? \$\endgroup\$
    – Pikalek
    Nov 11 '20 at 16:15
  • \$\begingroup\$ well first of all i have just L/R channels to manipulate sounds. 2nd is performances to avoid having 8 channels when just 2 are needed. 3rd is on generating sounds i have to loop through 8 channels instead of 2 or just 1 for example if i would like a mono one. \$\endgroup\$
    – Raffaello
    Nov 12 '20 at 13:32
  • \$\begingroup\$ I tried even with SDL2 audio rather than mixer and i have obtained the same results as mixer are just wrapper around those... so basically SDL2 is not able to provide a "downgrade" of audio system? \$\endgroup\$
    – Raffaello
    Nov 12 '20 at 13:34
  • \$\begingroup\$ Actually there's should be a way as Dosbox, ScummVM are using exactly 2 channels on my system and not 7.1 \$\endgroup\$
    – Raffaello
    Nov 15 '20 at 12:25

You must log in to answer this question.

Browse other questions tagged .