Skip to content

SDL Mixer multi-channel MixEffect Callback not working when copying data to the Side Channels in 7.1 (8 channels) #663

Open
@superhac

Description

@superhac

Hi everyone!

I've been using the mixer for project where I need to manually control what speakers certain mixChunk's go to. My output device settings per the AudioSpec is "Output Device Settings: Freq: 48000 Format (SDL_AudioFormat): 32784(SDL_AUDIO_S16LE) channels: 8". I'm on on Ubuntu using Pulse Audio directly, e.g. no Pipewire. By default if your playing audio file with less channels then your output channels Pulse with automatically remix those channels onto the ones you have. This is covered with these two options (specify in your daemon config file):

enable-remixing
remixing-use-all-sink-channels

Since I want to control all the channels when in 8 channel mode I need to specify remixing-use-all-sink-channels = no or else I get anything on the front channels bleeding back at lower volume on the side channels. Not the rear though....

For simplicity sake lets say I have one MixChunk that I only want to play on the Side and Rear channels. Its a wav file and its either stereo or a mono the sample that only has data on FL, FR channels. I need to copy those to the side and rear channels, and when that's done I wipe the FL,FR. To accomplish this I have the following in a MixEffect Callback:

   for (int frame = 0; frame < frames; ++frame) {
      int index = frame * channels;

      // copy the sound sample from Front to Back and Side channels.
      samples[index + 4] = static_cast<int16_t>(samples[index]);   // COPY FL to BL
      samples[index + 5] = static_cast<int16_t>(samples[index+1]); // Copy FR to BR
      samples[index + 6] = static_cast<int16_t>(samples[index]);   // Copy FL to SL 
      samples[index + 7] = static_cast<int16_t>(samples[index+1]); // Copy FR to SR
 
      // wipe front channels
      samples[index]   = static_cast<int16_t>(0);
      samples[index+1] = static_cast<int16_t>(0);

      //PLOGI << "FL: " << samples[index]  << " FR: " << samples[index+1] << " FC: " << samples[index+2] << " LFE: " << samples[index+3] << " BL: " << samples[index+4]
         //<< " BR: " << samples[index+5] << " SR: " << samples[index+6] << " SR: " << samples[index+7] ;
      
   }

But this doesn't work. While I see the data after its all done on the right channels, the side channels have no audio. The rear has audio and the front is silent as it should be. But nothing on the side channels.

I did as much as could to try to figure this out and didn't come up with answer. If I had to take a guess I think its something in mixer when it mixes all the chunks together its dropping or not including the side channels in the final output. Not sure if this related at all to any of positional stuff that only supports up to 5.1. But I'm on 7.1, 8 channels.

And just for coverage to see if it was just the side channels I changed it copy to the center and lfe channel and it worked. So its something with the side channel.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions