Added some debug output for unimplemented functionality. Cleaned up a bit,
but should probably rewritten - I think it's already too complex now to solve that whole task. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3402 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -21,55 +21,50 @@ AudioMixer::FillMixBuffer(void *outbuffer, size_t ioSize)
|
|||||||
{
|
{
|
||||||
case media_raw_audio_format::B_AUDIO_FLOAT:
|
case media_raw_audio_format::B_AUDIO_FLOAT:
|
||||||
{
|
{
|
||||||
|
|
||||||
float *outdata = (float*)outbuffer;
|
float *outdata = (float*)outbuffer;
|
||||||
|
|
||||||
memset(outdata, 0, ioSize); // CHANGE_THIS
|
memset(outdata, 0, ioSize); // CHANGE_THIS
|
||||||
|
|
||||||
int sampleCount = int(fOutput.format.u.raw_audio.buffer_size / sizeof(float));
|
int sampleCount = int(fOutput.format.u.raw_audio.buffer_size / sizeof(float));
|
||||||
|
|
||||||
for (int s = 0; s < sampleCount; s++)
|
for (int s = 0; s < sampleCount; s++)
|
||||||
{
|
{
|
||||||
outdata[s] = 0.0; // CHANGE_THIS
|
outdata[s] = 0.0; // CHANGE_THIS
|
||||||
}
|
}
|
||||||
|
|
||||||
int mixerInputCount = fMixerInputs.CountItems();
|
int mixerInputCount = fMixerInputs.CountItems();
|
||||||
|
|
||||||
for (int c = 0; c < mixerInputCount; c++)
|
for (int c = 0; c < mixerInputCount; c++)
|
||||||
{
|
{
|
||||||
mixer_input *channel = (mixer_input *)fMixerInputs.ItemAt(c);
|
mixer_input *channel = (mixer_input *)fMixerInputs.ItemAt(c);
|
||||||
|
|
||||||
if (channel->enabled == true) // still broken... FIX_THIS
|
if (channel->enabled == true) // still broken... FIX_THIS
|
||||||
{
|
{
|
||||||
int32 inChannels = channel->fInput.format.u.raw_audio.channel_count;
|
int32 inChannels = channel->fInput.format.u.raw_audio.channel_count;
|
||||||
bool split = outChannels > inChannels;
|
bool split = outChannels > inChannels;
|
||||||
bool mix = outChannels < inChannels;
|
bool mix = outChannels < inChannels;
|
||||||
|
|
||||||
if (fOutput.format.u.raw_audio.frame_rate == channel->fInput.format.u.raw_audio.frame_rate)
|
if (fOutput.format.u.raw_audio.frame_rate == channel->fInput.format.u.raw_audio.frame_rate)
|
||||||
{
|
{
|
||||||
switch(channel->fInput.format.u.raw_audio.format)
|
switch (channel->fInput.format.u.raw_audio.format)
|
||||||
{
|
{
|
||||||
case media_raw_audio_format::B_AUDIO_FLOAT:
|
case media_raw_audio_format::B_AUDIO_FLOAT:
|
||||||
{
|
{
|
||||||
|
|
||||||
float *indata = (float *)channel->fData;
|
float *indata = (float *)channel->fData;
|
||||||
|
|
||||||
if (split)
|
if (split) {
|
||||||
{ } // ADD_THIS
|
printf("#### FillMixBuffer(): 1.Should split from B_AUDIO_FLOAT!\n");
|
||||||
else if (mix)
|
} else if (mix) {
|
||||||
{ } // ADD_THIS
|
printf("#### FillMixBuffer(): 1.Should mix from B_AUDIO_FLOAT!\n");
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
int baseOffset = channel->fEventOffset / 4;
|
int baseOffset = channel->fEventOffset / 4;
|
||||||
int maxOffset = int(channel->fDataSize / 4);
|
int maxOffset = int(channel->fDataSize / 4);
|
||||||
|
|
||||||
int offsetWrap = maxOffset - baseOffset;
|
int offsetWrap = maxOffset - baseOffset;
|
||||||
|
|
||||||
int inputSample = baseOffset;
|
int inputSample = baseOffset;
|
||||||
|
|
||||||
for (int s = 0; s < sampleCount; s++)
|
for (int s = 0; s < sampleCount; s++)
|
||||||
{
|
{
|
||||||
|
|
||||||
outdata[s] = indata[inputSample];
|
outdata[s] = indata[inputSample];
|
||||||
indata[inputSample] = 0;
|
indata[inputSample] = 0;
|
||||||
|
|
||||||
@@ -77,29 +72,23 @@ AudioMixer::FillMixBuffer(void *outbuffer, size_t ioSize)
|
|||||||
inputSample = 0;
|
inputSample = 0;
|
||||||
else
|
else
|
||||||
inputSample ++;
|
inputSample ++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
channel->fEventOffset = (channel->fEventOffset + fOutput.format.u.raw_audio.buffer_size) %
|
channel->fEventOffset = (channel->fEventOffset + fOutput.format.u.raw_audio.buffer_size) %
|
||||||
channel->fDataSize;
|
channel->fDataSize;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case media_raw_audio_format::B_AUDIO_SHORT:
|
case media_raw_audio_format::B_AUDIO_SHORT:
|
||||||
{
|
{
|
||||||
|
|
||||||
int16 *indata = (int16 *)channel->fData;
|
int16 *indata = (int16 *)channel->fData;
|
||||||
|
|
||||||
if (split)
|
if (split) {
|
||||||
{ }
|
printf("#### FillMixBuffer(): 2.Should split from B_AUDIO_SHORT!\n");
|
||||||
else if (mix)
|
} else if (mix) {
|
||||||
{ }
|
printf("#### FillMixBuffer(): 2.Should mix from B_AUDIO_SHORT!\n");
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
|
|
||||||
int baseOffset = channel->fEventOffset / 2;
|
int baseOffset = channel->fEventOffset / 2;
|
||||||
int maxOffset = int(channel->fDataSize / 2);
|
int maxOffset = int(channel->fDataSize / 2);
|
||||||
|
|
||||||
@@ -108,33 +97,27 @@ AudioMixer::FillMixBuffer(void *outbuffer, size_t ioSize)
|
|||||||
int inputSample = baseOffset;
|
int inputSample = baseOffset;
|
||||||
|
|
||||||
for (int s = 0; s < sampleCount; s++)
|
for (int s = 0; s < sampleCount; s++)
|
||||||
{
|
{
|
||||||
|
outdata[s] = outdata[s] + (indata[inputSample] / 32768.0);
|
||||||
outdata[s] = outdata[s] + (indata[inputSample] / 32768.0); // CHANGE_THIS indata[inputSample] = 0;
|
// CHANGE_THIS indata[inputSample] = 0;
|
||||||
|
|
||||||
if (s == offsetWrap)
|
if (s == offsetWrap)
|
||||||
inputSample = 0;
|
inputSample = 0;
|
||||||
else
|
else
|
||||||
inputSample ++;
|
inputSample ++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
channel->fEventOffset = (channel->fEventOffset + fOutput.format.u.raw_audio.buffer_size / 2) %
|
channel->fEventOffset = (channel->fEventOffset + fOutput.format.u.raw_audio.buffer_size / 2) %
|
||||||
channel->fDataSize;
|
channel->fDataSize;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // input format
|
} // input format
|
||||||
|
} else
|
||||||
} // samplerate
|
printf("#### sample rate does not match - don't do anything\n");
|
||||||
|
|
||||||
} // data available
|
} // data available
|
||||||
|
|
||||||
} // channel loop
|
} // channel loop
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// The buffer is done - we still need to scale for the MainVolume...
|
// The buffer is done - we still need to scale for the MainVolume...
|
||||||
// then check to see if anything is clipping, adjust if needed
|
// then check to see if anything is clipping, adjust if needed
|
||||||
@@ -151,23 +134,20 @@ AudioMixer::FillMixBuffer(void *outbuffer, size_t ioSize)
|
|||||||
// outdata[sample] = 1.0;
|
// outdata[sample] = 1.0;
|
||||||
// else if (outdata[sample] < -1.0)
|
// else if (outdata[sample] < -1.0)
|
||||||
// outdata[sample] = -1.0;
|
// outdata[sample] = -1.0;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
} // cur-case
|
} // cur-case
|
||||||
|
|
||||||
case media_raw_audio_format::B_AUDIO_SHORT:
|
case media_raw_audio_format::B_AUDIO_SHORT:
|
||||||
{
|
{
|
||||||
|
|
||||||
int16 *outdata = (int16*)outbuffer;
|
int16 *outdata = (int16*)outbuffer;
|
||||||
int sampleCount = int(fOutput.format.u.raw_audio.buffer_size / sizeof(int16));
|
int sampleCount = int(fOutput.format.u.raw_audio.buffer_size / sizeof(int16));
|
||||||
|
|
||||||
int *clipoffset = new int[sampleCount]; // keep a running tally of +/- clipping so we don't get rollaround distortion
|
int *clipoffset = new int[sampleCount];
|
||||||
// we only need this for int/char audio types - not float
|
// keep a running tally of +/- clipping so we don't get rollaround distortion
|
||||||
|
// we only need this for int/char audio types - not float
|
||||||
|
|
||||||
memset(outdata, 0, ioSize);
|
memset(outdata, 0, ioSize);
|
||||||
memset(clipoffset, 0, sizeof(int) * sampleCount);
|
memset(clipoffset, 0, sizeof(int) * sampleCount);
|
||||||
|
|
||||||
@@ -175,16 +155,16 @@ AudioMixer::FillMixBuffer(void *outbuffer, size_t ioSize)
|
|||||||
// {
|
// {
|
||||||
// clipoffset[s] = 0;
|
// clipoffset[s] = 0;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
int mixerInputs = fMixerInputs.CountItems();
|
int mixerInputs = fMixerInputs.CountItems();
|
||||||
|
if (mixerInputs == 0)
|
||||||
|
printf("#### mixer null\n");
|
||||||
for (int c = 0; c < mixerInputs; c++)
|
for (int c = 0; c < mixerInputs; c++)
|
||||||
{
|
{
|
||||||
mixer_input *channel = (mixer_input *)fMixerInputs.ItemAt(c);
|
mixer_input *channel = (mixer_input *)fMixerInputs.ItemAt(c);
|
||||||
|
|
||||||
if (channel->enabled == true) // only use if there are buffers waiting (seems to be broken atm...)
|
if (channel->enabled == true) // only use if there are buffers waiting (seems to be broken atm...)
|
||||||
{
|
{
|
||||||
|
|
||||||
// if (channel->fProducerDataStatus == B_DATA_AVAILABLE)
|
// if (channel->fProducerDataStatus == B_DATA_AVAILABLE)
|
||||||
// printf("B_DATA_AVAILABLE\n");
|
// printf("B_DATA_AVAILABLE\n");
|
||||||
// else if (channel->fProducerDataStatus == B_DATA_NOT_AVAILABLE)
|
// else if (channel->fProducerDataStatus == B_DATA_NOT_AVAILABLE)
|
||||||
@@ -195,30 +175,25 @@ AudioMixer::FillMixBuffer(void *outbuffer, size_t ioSize)
|
|||||||
int32 inChannels = channel->fInput.format.u.raw_audio.channel_count;
|
int32 inChannels = channel->fInput.format.u.raw_audio.channel_count;
|
||||||
bool split = outChannels > inChannels;
|
bool split = outChannels > inChannels;
|
||||||
bool mix = outChannels < inChannels;
|
bool mix = outChannels < inChannels;
|
||||||
|
|
||||||
if (fOutput.format.u.raw_audio.frame_rate == channel->fInput.format.u.raw_audio.frame_rate)
|
if (fOutput.format.u.raw_audio.frame_rate == channel->fInput.format.u.raw_audio.frame_rate)
|
||||||
{
|
{
|
||||||
switch(channel->fInput.format.u.raw_audio.format)
|
switch (channel->fInput.format.u.raw_audio.format)
|
||||||
{
|
{
|
||||||
|
|
||||||
case media_raw_audio_format::B_AUDIO_FLOAT:
|
case media_raw_audio_format::B_AUDIO_FLOAT:
|
||||||
{
|
{
|
||||||
|
|
||||||
float *indata = (float *)channel->fData;
|
float *indata = (float *)channel->fData;
|
||||||
|
|
||||||
if (split)
|
if (split) {
|
||||||
{
|
|
||||||
|
|
||||||
int baseOffset = channel->fEventOffset / 4;
|
int baseOffset = channel->fEventOffset / 4;
|
||||||
int maxOffset = int(channel->fDataSize / 4);
|
int maxOffset = int(channel->fDataSize / 4);
|
||||||
|
|
||||||
int offsetWrap = maxOffset - baseOffset;
|
int offsetWrap = maxOffset - baseOffset;
|
||||||
|
|
||||||
int inputSample = baseOffset;
|
int inputSample = baseOffset;
|
||||||
|
|
||||||
for (int s = 0; s < sampleCount; s += 2)
|
for (int s = 0; s < sampleCount; s += 2)
|
||||||
{
|
{
|
||||||
|
|
||||||
if ((outdata[s] + int16(32767 * indata[inputSample])) > 32767)
|
if ((outdata[s] + int16(32767 * indata[inputSample])) > 32767)
|
||||||
clipoffset[s] = clipoffset[s] + 1;
|
clipoffset[s] = clipoffset[s] + 1;
|
||||||
else if ((outdata[s] + int16(32767 * indata[inputSample])) < -32768)
|
else if ((outdata[s] + int16(32767 * indata[inputSample])) < -32768)
|
||||||
@@ -239,15 +214,12 @@ AudioMixer::FillMixBuffer(void *outbuffer, size_t ioSize)
|
|||||||
else
|
else
|
||||||
inputSample ++;
|
inputSample ++;
|
||||||
}
|
}
|
||||||
|
} else if (mix) {
|
||||||
}
|
printf("#### FillMixBuffer(): 3.Should mix from B_AUDIO_FLOAT!\n");
|
||||||
else if (mix)
|
} else {
|
||||||
{}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int baseOffset = channel->fEventOffset / 4;
|
int baseOffset = channel->fEventOffset / 4;
|
||||||
int maxOffset = int(channel->fDataSize / 4);
|
int maxOffset = int(channel->fDataSize / 4);
|
||||||
|
|
||||||
int offsetWrap = maxOffset - baseOffset;
|
int offsetWrap = maxOffset - baseOffset;
|
||||||
|
|
||||||
int inputSample = baseOffset;
|
int inputSample = baseOffset;
|
||||||
@@ -257,54 +229,48 @@ AudioMixer::FillMixBuffer(void *outbuffer, size_t ioSize)
|
|||||||
for (int chan = 0; chan < outChannels; chan ++)
|
for (int chan = 0; chan < outChannels; chan ++)
|
||||||
{
|
{
|
||||||
int sample = frameStart + chan;
|
int sample = frameStart + chan;
|
||||||
|
|
||||||
int inputValue = int((32767 * indata[inputSample] * channel->fGainScale[chan]) + outdata[sample]);
|
int inputValue = int((32767 * indata[inputSample] * channel->fGainScale[chan]) + outdata[sample]);
|
||||||
|
|
||||||
if (inputValue > 32767)
|
if (inputValue > 32767)
|
||||||
clipoffset[sample] = clipoffset[sample] + 1;
|
clipoffset[sample] = clipoffset[sample] + 1;
|
||||||
else if (inputValue < -32768)
|
else if (inputValue < -32768)
|
||||||
clipoffset[sample] = clipoffset[sample] - 1;
|
clipoffset[sample] = clipoffset[sample] - 1;
|
||||||
|
|
||||||
outdata[sample] = inputValue; // CHANGE_THIS
|
outdata[sample] = inputValue; // CHANGE_THIS
|
||||||
indata[inputSample] = 0;
|
indata[inputSample] = 0;
|
||||||
|
|
||||||
if (sample == offsetWrap)
|
if (sample == offsetWrap)
|
||||||
inputSample = 0;
|
inputSample = 0;
|
||||||
else
|
else
|
||||||
inputSample ++;
|
inputSample ++;
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
channel->fEventOffset += (fOutput.format.u.raw_audio.buffer_size * 2);
|
channel->fEventOffset += (fOutput.format.u.raw_audio.buffer_size * 2);
|
||||||
if (channel->fEventOffset >= channel->fDataSize)
|
if (channel->fEventOffset >= channel->fDataSize)
|
||||||
channel->fEventOffset -= channel->fDataSize;
|
channel->fEventOffset -= channel->fDataSize;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case media_raw_audio_format::B_AUDIO_SHORT:
|
case media_raw_audio_format::B_AUDIO_SHORT:
|
||||||
{
|
{
|
||||||
|
|
||||||
int16 *indata = (int16 *)channel->fData;
|
int16 *indata = (int16 *)channel->fData;
|
||||||
|
|
||||||
if (split)
|
if (split) {
|
||||||
{ }
|
printf("#### FillMixBuffer(): 4.Should split from B_AUDIO_SHORT!\n");
|
||||||
else if (mix)
|
} else if (mix) {
|
||||||
{ }
|
printf("#### FillMixBuffer(): 4.Should mix from B_AUDIO_SHORT!\n");
|
||||||
else
|
} else {
|
||||||
{
|
printf("#### FillMixBuffer(): 4.Should copy from B_AUDIO_SHORT!\n");
|
||||||
int baseOffset = channel->fEventOffset / 2;
|
int baseOffset = channel->fEventOffset / 2;
|
||||||
int maxOffset = int(channel->fDataSize / 2);
|
int maxOffset = int(channel->fDataSize / 2);
|
||||||
|
|
||||||
int offsetWrap = maxOffset - baseOffset;
|
int offsetWrap = maxOffset - baseOffset;
|
||||||
|
|
||||||
int inputSample = baseOffset;
|
int inputSample = baseOffset;
|
||||||
|
|
||||||
for (int frameStart = 0; frameStart < sampleCount; frameStart += outChannels)
|
for (int frameStart = 0; frameStart < sampleCount; frameStart += outChannels)
|
||||||
{
|
{
|
||||||
for (int chan = 0; chan < outChannels; chan ++)
|
for (int chan = 0; chan < outChannels; chan ++)
|
||||||
@@ -328,102 +294,85 @@ AudioMixer::FillMixBuffer(void *outbuffer, size_t ioSize)
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
channel->fEventOffset = (channel->fEventOffset + fOutput.format.u.raw_audio.buffer_size);
|
channel->fEventOffset = (channel->fEventOffset + fOutput.format.u.raw_audio.buffer_size);
|
||||||
if (channel->fEventOffset >= channel->fDataSize)
|
if (channel->fEventOffset >= channel->fDataSize)
|
||||||
channel->fEventOffset -= channel->fDataSize;
|
channel->fEventOffset -= channel->fDataSize;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case media_raw_audio_format::B_AUDIO_INT:
|
}
|
||||||
{
|
|
||||||
|
case media_raw_audio_format::B_AUDIO_INT:
|
||||||
int32 *indata = (int32 *)channel->fData;
|
{
|
||||||
|
int32 *indata = (int32 *)channel->fData;
|
||||||
if (split)
|
|
||||||
{
|
if (split) {
|
||||||
|
int baseOffset = channel->fEventOffset / 4;
|
||||||
int baseOffset = channel->fEventOffset / 4;
|
int maxOffset = int(channel->fDataSize / 4);
|
||||||
int maxOffset = int(channel->fDataSize / 4);
|
|
||||||
|
int offsetWrap = maxOffset - baseOffset;
|
||||||
|
|
||||||
|
int inputSample = baseOffset;
|
||||||
|
|
||||||
|
for (int s = 0; s < sampleCount; s += 2) {
|
||||||
|
if ((outdata[s] + (indata[inputSample] / 65536)) > 32767)
|
||||||
|
clipoffset[s] = clipoffset[s] + 1;
|
||||||
|
else if ((outdata[s] + (indata[inputSample] / 65536)) < -32768)
|
||||||
|
clipoffset[s] = clipoffset[s] - 1;
|
||||||
|
|
||||||
|
if ((outdata[s + 1] + (indata[inputSample] / 65536)) > 32767)
|
||||||
|
clipoffset[s + 1] = clipoffset[s + 1] + 1;
|
||||||
|
else if ((outdata[s + 1] + (indata[inputSample] / 65536)) < -32768)
|
||||||
|
clipoffset[s + 1] = clipoffset[s + 1] - 1;
|
||||||
|
|
||||||
|
outdata[s] = int16(outdata[s] + (indata[inputSample] / 65535)); // CHANGE_THIS mixing
|
||||||
|
outdata[s + 1] = outdata[s];
|
||||||
|
|
||||||
|
indata[inputSample] = 0;
|
||||||
|
|
||||||
|
if (s == offsetWrap)
|
||||||
|
inputSample = 0;
|
||||||
|
else
|
||||||
|
inputSample ++;
|
||||||
|
}
|
||||||
|
} else if (mix) {
|
||||||
|
printf("#### FillMixBuffer(): 5.Should mix from B_AUDIO_INT!\n");
|
||||||
|
} else {
|
||||||
|
int baseOffset = channel->fEventOffset / 4;
|
||||||
|
int maxOffset = int(channel->fDataSize / 4);
|
||||||
|
|
||||||
|
int offsetWrap = maxOffset - baseOffset;
|
||||||
|
|
||||||
|
int inputSample = baseOffset;
|
||||||
|
|
||||||
|
for (int s = 0; s < sampleCount; s++) {
|
||||||
|
if ((outdata[s] + (indata[inputSample] / 65536)) > 32767)
|
||||||
|
clipoffset[s] = clipoffset[s] + 1;
|
||||||
|
else if ((outdata[s] + (indata[inputSample] / 65536)) < -32768)
|
||||||
|
clipoffset[s] = clipoffset[s] - 1;
|
||||||
|
|
||||||
int offsetWrap = maxOffset - baseOffset;
|
outdata[s] = int16(outdata[s] + (indata[inputSample] / 65536)); // CHANGE_THIS mixing
|
||||||
|
|
||||||
int inputSample = baseOffset;
|
|
||||||
|
|
||||||
for (int s = 0; s < sampleCount; s += 2)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ((outdata[s] + (indata[inputSample] / 65536)) > 32767)
|
|
||||||
clipoffset[s] = clipoffset[s] + 1;
|
|
||||||
else if ((outdata[s] + (indata[inputSample] / 65536)) < -32768)
|
|
||||||
clipoffset[s] = clipoffset[s] - 1;
|
|
||||||
|
|
||||||
if ((outdata[s + 1] + (indata[inputSample] / 65536)) > 32767)
|
|
||||||
clipoffset[s + 1] = clipoffset[s + 1] + 1;
|
|
||||||
else if ((outdata[s + 1] + (indata[inputSample] / 65536)) < -32768)
|
|
||||||
clipoffset[s + 1] = clipoffset[s + 1] - 1;
|
|
||||||
|
|
||||||
outdata[s] = int16(outdata[s] + (indata[inputSample] / 65535)); // CHANGE_THIS mixing
|
|
||||||
outdata[s + 1] = outdata[s];
|
|
||||||
|
|
||||||
indata[inputSample] = 0;
|
indata[inputSample] = 0;
|
||||||
|
|
||||||
if (s == offsetWrap)
|
if (s == offsetWrap)
|
||||||
inputSample = 0;
|
inputSample = 0;
|
||||||
else
|
else
|
||||||
inputSample ++;
|
inputSample ++;
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (mix)
|
|
||||||
{ }
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
int baseOffset = channel->fEventOffset / 4;
|
|
||||||
int maxOffset = int(channel->fDataSize / 4);
|
|
||||||
|
|
||||||
int offsetWrap = maxOffset - baseOffset;
|
|
||||||
|
|
||||||
int inputSample = baseOffset;
|
|
||||||
|
|
||||||
for (int s = 0; s < sampleCount; s++)
|
|
||||||
{
|
|
||||||
|
|
||||||
if ((outdata[s] + (indata[inputSample] / 65536)) > 32767)
|
|
||||||
clipoffset[s] = clipoffset[s] + 1;
|
|
||||||
else if ((outdata[s] + (indata[inputSample] / 65536)) < -32768)
|
|
||||||
clipoffset[s] = clipoffset[s] - 1;
|
|
||||||
|
|
||||||
outdata[s] = int16(outdata[s] + (indata[inputSample] / 65536)); // CHANGE_THIS mixing
|
|
||||||
indata[inputSample] = 0;
|
|
||||||
|
|
||||||
if (s == offsetWrap)
|
|
||||||
inputSample = 0;
|
|
||||||
else
|
|
||||||
inputSample ++;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
channel->fEventOffset = (channel->fEventOffset + (fOutput.format.u.raw_audio.buffer_size * 2)) %
|
|
||||||
channel->fDataSize;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
channel->fEventOffset = (channel->fEventOffset + (fOutput.format.u.raw_audio.buffer_size * 2))
|
||||||
|
% channel->fDataSize;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
}
|
printf("#### sample rate does not match - don't do anything\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// use our clipoffset to determine correct limits
|
|
||||||
|
// use our clipoffset to determine correct limits
|
||||||
|
|
||||||
for (int frameStart = 0; frameStart < sampleCount; frameStart += outChannels)
|
for (int frameStart = 0; frameStart < sampleCount; frameStart += outChannels)
|
||||||
{
|
{
|
||||||
for (int channel = 0; channel < outChannels; channel ++)
|
for (int channel = 0; channel < outChannels; channel ++)
|
||||||
@@ -442,9 +391,11 @@ AudioMixer::FillMixBuffer(void *outbuffer, size_t ioSize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete clipoffset;
|
delete clipoffset;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
printf("##### oh no, unknown conversion %ld #####\n", fOutput.format.u.raw_audio.format);
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user