mirror of https://github.com/godotengine/godot
Add 8-channel audio support
This commit is contained in:
parent
ca8664b4b6
commit
5fbd83ed43
|
|
@ -52,7 +52,7 @@ class VideoStreamPlaybackTheora : public VideoStreamPlayback {
|
|||
Point2i size;
|
||||
Rect2i region;
|
||||
|
||||
const static int AUXBUF_LEN = 4096;
|
||||
const static int AUXBUF_LEN = 8192;
|
||||
float audio_buffer[AUXBUF_LEN];
|
||||
int audio_ptr_start;
|
||||
int audio_ptr_end;
|
||||
|
|
|
|||
|
|
@ -78,9 +78,9 @@ uint32_t AudioRBResampler::_resample(AudioFrame *p_dest, int p_todo, int32_t p_i
|
|||
// This will probably never be used, but added anyway
|
||||
if constexpr (C == 4) {
|
||||
float v0 = rb[(pos << 2) + 0];
|
||||
float v1 = rb[(pos << 2) + 1];
|
||||
float v1 = rb[(pos << 2) + 2];
|
||||
float v0n = rb[(pos_next << 2) + 0];
|
||||
float v1n = rb[(pos_next << 2) + 1];
|
||||
float v1n = rb[(pos_next << 2) + 2];
|
||||
v0 += (v0n - v0) * frac;
|
||||
v1 += (v1n - v1) * frac;
|
||||
p_dest[i] = AudioFrame(v0, v1);
|
||||
|
|
@ -88,14 +88,24 @@ uint32_t AudioRBResampler::_resample(AudioFrame *p_dest, int p_todo, int32_t p_i
|
|||
|
||||
if constexpr (C == 6) {
|
||||
float v0 = rb[(pos * 6) + 0];
|
||||
float v1 = rb[(pos * 6) + 1];
|
||||
float v1 = rb[(pos * 6) + 2];
|
||||
float v0n = rb[(pos_next * 6) + 0];
|
||||
float v1n = rb[(pos_next * 6) + 1];
|
||||
float v1n = rb[(pos_next * 6) + 2];
|
||||
|
||||
v0 += (v0n - v0) * frac;
|
||||
v1 += (v1n - v1) * frac;
|
||||
p_dest[i] = AudioFrame(v0, v1);
|
||||
}
|
||||
|
||||
if constexpr (C == 8) {
|
||||
float v0 = rb[(pos << 3) + 0];
|
||||
float v1 = rb[(pos << 3) + 2];
|
||||
float v0n = rb[(pos_next << 3) + 0];
|
||||
float v1n = rb[(pos_next << 3) + 2];
|
||||
v0 += (v0n - v0) * frac;
|
||||
v1 += (v1n - v1) * frac;
|
||||
p_dest[i] = AudioFrame(v0, v1);
|
||||
}
|
||||
}
|
||||
|
||||
return read >> MIX_FRAC_BITS; //rb_read_pos = offset >> MIX_FRAC_BITS;
|
||||
|
|
@ -125,6 +135,9 @@ bool AudioRBResampler::mix(AudioFrame *p_dest, int p_frames) {
|
|||
case 6:
|
||||
src_read = _resample<6>(p_dest, target_todo, increment);
|
||||
break;
|
||||
case 8:
|
||||
src_read = _resample<8>(p_dest, target_todo, increment);
|
||||
break;
|
||||
}
|
||||
|
||||
if (src_read > read_space) {
|
||||
|
|
@ -159,7 +172,7 @@ int AudioRBResampler::get_num_of_ready_frames() {
|
|||
}
|
||||
|
||||
Error AudioRBResampler::setup(int p_channels, int p_src_mix_rate, int p_target_mix_rate, int p_buffer_msec, int p_minbuff_needed) {
|
||||
ERR_FAIL_COND_V(p_channels != 1 && p_channels != 2 && p_channels != 4 && p_channels != 6, ERR_INVALID_PARAMETER);
|
||||
ERR_FAIL_COND_V(p_channels != 1 && p_channels != 2 && p_channels != 4 && p_channels != 6 && p_channels != 8, ERR_INVALID_PARAMETER);
|
||||
|
||||
int desired_rb_bits = nearest_shift(MAX((p_buffer_msec / 1000.0) * p_src_mix_rate, p_minbuff_needed));
|
||||
|
||||
|
|
|
|||
|
|
@ -153,6 +153,19 @@ public:
|
|||
wp = (wp + 1) & rb_mask;
|
||||
}
|
||||
} break;
|
||||
case 8: {
|
||||
for (uint32_t i = 0; i < p_frames; i++) {
|
||||
rb[(wp << 3) + 0] = read_buf[(i << 3) + 0];
|
||||
rb[(wp << 3) + 1] = read_buf[(i << 3) + 1];
|
||||
rb[(wp << 3) + 2] = read_buf[(i << 3) + 2];
|
||||
rb[(wp << 3) + 3] = read_buf[(i << 3) + 3];
|
||||
rb[(wp << 3) + 4] = read_buf[(i << 3) + 4];
|
||||
rb[(wp << 3) + 5] = read_buf[(i << 3) + 5];
|
||||
rb[(wp << 3) + 6] = read_buf[(i << 3) + 6];
|
||||
rb[(wp << 3) + 7] = read_buf[(i << 3) + 7];
|
||||
wp = (wp + 1) & rb_mask;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
rb_write_pos.set(wp);
|
||||
|
|
|
|||
Loading…
Reference in New Issue