MCPcopy Create free account
hub / github.com/LabSound/LabSound / convertBuffer

Method convertBuffer

src/backends/RtAudio/RtAudio.cpp:11147–11691  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11145}
11146
11147void RtApi ::convertBuffer(char * outBuffer, char * inBuffer, ConvertInfo & info)
11148{
11149 // This function does format conversion, input/output channel compensation, and
11150 // data interleaving/deinterleaving. 24-bit integers are assumed to occupy
11151 // the lower three bytes of a 32-bit integer.
11152
11153 // Clear our device buffer when in/out duplex device channels are different
11154 if (outBuffer == stream_.deviceBuffer && stream_.mode == DUPLEX && (stream_.nDeviceChannels[0] < stream_.nDeviceChannels[1]))
11155 memset(outBuffer, 0, stream_.bufferSize * info.outJump * formatBytes(info.outFormat));
11156
11157 int j;
11158 if (info.outFormat == RTAUDIO_FLOAT64)
11159 {
11160 Float64 scale;
11161 Float64 * out = (Float64 *) outBuffer;
11162
11163 if (info.inFormat == RTAUDIO_SINT8)
11164 {
11165 signed char * in = (signed char *) inBuffer;
11166 scale = 1.0 / 127.5;
11167 for (unsigned int i = 0; i < stream_.bufferSize; i++)
11168 {
11169 for (j = 0; j < info.channels; j++)
11170 {
11171 out[info.outOffset[j]] = (Float64) in[info.inOffset[j]];
11172 out[info.outOffset[j]] += 0.5;
11173 out[info.outOffset[j]] *= scale;
11174 }
11175 in += info.inJump;
11176 out += info.outJump;
11177 }
11178 }
11179 else if (info.inFormat == RTAUDIO_SINT16)
11180 {
11181 Int16 * in = (Int16 *) inBuffer;
11182 scale = 1.0 / 32767.5;
11183 for (unsigned int i = 0; i < stream_.bufferSize; i++)
11184 {
11185 for (j = 0; j < info.channels; j++)
11186 {
11187 out[info.outOffset[j]] = (Float64) in[info.inOffset[j]];
11188 out[info.outOffset[j]] += 0.5;
11189 out[info.outOffset[j]] *= scale;
11190 }
11191 in += info.inJump;
11192 out += info.outJump;
11193 }
11194 }
11195 else if (info.inFormat == RTAUDIO_SINT24)
11196 {
11197 Int24 * in = (Int24 *) inBuffer;
11198 scale = 1.0 / 8388607.5;
11199 for (unsigned int i = 0; i < stream_.bufferSize; i++)
11200 {
11201 for (j = 0; j < info.channels; j++)
11202 {
11203 out[info.outOffset[j]] = (Float64)(in[info.inOffset[j]].asInt());
11204 out[info.outOffset[j]] += 0.5;

Callers

nothing calls this directly

Calls 1

asIntMethod · 0.80

Tested by

no test coverage detected