// TODO maybe send num-1 frames from here already
}
+typedef int channelmapping_t[8];
+channelmapping_t mapping[8] =
+{
+ { 0, -1, -1, -1, -1, -1, -1, -1 }, // mono
+ { 0, 1, -1, -1, -1, -1, -1, -1 }, // stereo
+ { 0, 1, 2, -1, -1, -1, -1, -1 }, // L C R
+ { 0, 1, 2, 3, -1, -1, -1, -1 }, // surround40
+ { 0, 4, 1, 2, 3, -1, -1, -1 }, // FL FC FR RL RR
+ { 0, 4, 1, 2, 3, 5, -1, -1 }, // surround51
+ { 0, 4, 1, 2, 3, 5, 6, -1 }, // (not defined by vorbis spec)
+ { 0, 4, 1, 2, 3, 5, 6, 7 } // surround71 (not defined by vorbis spec)
+};
+
static void SCR_CaptureVideo_Ogg_SoundFrame(const portable_sampleframe_t *paintbuffer, size_t length)
{
LOAD_FORMATSPECIFIC_OGG();
size_t i;
int j;
ogg_packet pt;
+ int *map = mapping[bound(1, cls.capturevideo.soundchannels, 8) - 1];
vorbis_buffer = qvorbis_analysis_buffer(&format->vd, length);
- for(i = 0; i < length; ++i)
+ for(j = 0; j < cls.capturevideo.soundchannels; ++j)
{
- for(j = 0; j < cls.capturevideo.soundchannels; ++j)
- vorbis_buffer[j][i] = paintbuffer[i].sample[j] / 32768.0f;
+ float *b = vorbis_buffer[map[j]];
+ for(i = 0; i < length; ++i)
+ b[i] = paintbuffer[i].sample[j] / 32768.0f;
}
qvorbis_analysis_wrote(&format->vd, length);
#define SND_MAX_WIDTH 2
#define SND_MIN_CHANNELS 1
#define SND_MAX_CHANNELS 8
-
#if SND_LISTENERS != 8
# error this data only supports up to 8 channel, update it!
#endif
-typedef struct listener_s
-{
- float yawangle;
- float dotscale;
- float dotbias;
- float ambientvolume;
-}
-listener_t;
-typedef struct speakerlayout_s
-{
- const char *name;
- unsigned int channels;
- listener_t listeners[SND_LISTENERS];
-}
-speakerlayout_t;
-static speakerlayout_t snd_speakerlayout;
+speakerlayout_t snd_speakerlayout;
// Our speaker layouts are based on ALSA. They differ from those
// Win32 and Mac OS X APIs use when there's more than 4 channels.
{
"surround71", 8,
{
- {45, 0.2, 0.2, 0.5}, // front left
- {315, 0.2, 0.2, 0.5}, // front right
- {135, 0.2, 0.2, 0.5}, // rear left
- {225, 0.2, 0.2, 0.5}, // rear right
- {0, 0.2, 0.2, 0.5}, // front center
- {0, 0, 0, 0}, // lfe (we don't have any good lfe sound sources and it would take some filtering work to generate them (and they'd probably still be wrong), so... no lfe)
- {90, 0.2, 0.2, 0.5}, // side left
- {180, 0.2, 0.2, 0.5}, // side right
+ {0, 45, 0.2, 0.2, 0.5}, // front left
+ {1, 315, 0.2, 0.2, 0.5}, // front right
+ {2, 135, 0.2, 0.2, 0.5}, // rear left
+ {3, 225, 0.2, 0.2, 0.5}, // rear right
+ {4, 0, 0.2, 0.2, 0.5}, // front center
+ {5, 0, 0, 0, 0}, // lfe (we don't have any good lfe sound sources and it would take some filtering work to generate them (and they'd probably still be wrong), so... no lfe)
+ {6, 90, 0.2, 0.2, 0.5}, // side left
+ {7, 180, 0.2, 0.2, 0.5}, // side right
}
},
{
"surround51", 6,
{
- {45, 0.2, 0.2, 0.5}, // front left
- {315, 0.2, 0.2, 0.5}, // front right
- {135, 0.2, 0.2, 0.5}, // rear left
- {225, 0.2, 0.2, 0.5}, // rear right
- {0, 0.2, 0.2, 0.5}, // front center
- {0, 0, 0, 0}, // lfe (we don't have any good lfe sound sources and it would take some filtering work to generate them (and they'd probably still be wrong), so... no lfe)
- {0, 0, 0, 0},
- {0, 0, 0, 0},
+ {0, 45, 0.2, 0.2, 0.5}, // front left
+ {1, 315, 0.2, 0.2, 0.5}, // front right
+ {2, 135, 0.2, 0.2, 0.5}, // rear left
+ {3, 225, 0.2, 0.2, 0.5}, // rear right
+ {4, 0, 0.2, 0.2, 0.5}, // front center
+ {5, 0, 0, 0, 0}, // lfe (we don't have any good lfe sound sources and it would take some filtering work to generate them (and they'd probably still be wrong), so... no lfe)
+ {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0},
}
},
{
// channel of its own
"surround40", 4,
{
- {45, 0.3, 0.3, 0.8}, // front left
- {315, 0.3, 0.3, 0.8}, // front right
- {135, 0.3, 0.3, 0.8}, // rear left
- {225, 0.3, 0.3, 0.8}, // rear right
- {0, 0, 0, 0},
- {0, 0, 0, 0},
- {0, 0, 0, 0},
- {0, 0, 0, 0},
+ {0, 45, 0.3, 0.3, 0.8}, // front left
+ {1, 315, 0.3, 0.3, 0.8}, // front right
+ {2, 135, 0.3, 0.3, 0.8}, // rear left
+ {3, 225, 0.3, 0.3, 0.8}, // rear right
+ {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0},
}
},
{
// channel of its own
"stereo", 2,
{
- {90, 0.5, 0.5, 1}, // side left
- {270, 0.5, 0.5, 1}, // side right
- {0, 0, 0, 0},
- {0, 0, 0, 0},
- {0, 0, 0, 0},
- {0, 0, 0, 0},
- {0, 0, 0, 0},
- {0, 0, 0, 0},
+ {0, 90, 0.5, 0.5, 1}, // side left
+ {1, 270, 0.5, 0.5, 1}, // side right
+ {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0},
}
},
{
"mono", 1,
{
- {0, 0, 1, 1}, // center
- {0, 0, 0, 0},
- {0, 0, 0, 0},
- {0, 0, 0, 0},
- {0, 0, 0, 0},
- {0, 0, 0, 0},
- {0, 0, 0, 0},
- {0, 0, 0, 0},
+ {0, 0, 0, 1, 1}, // center
+ {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0},
}
}
};