clamp output samples before integerizing... but wow that's a neat effect

portability/boost
zetaPRIME 2019-01-14 18:15:56 -05:00
parent 96c22eac1d
commit 4b8688bdec
2 changed files with 4 additions and 2 deletions

2
notes
View File

@ -92,6 +92,8 @@ TODO {
- note transpose
volume meter
"wrap clipper" (gain up, then wrap around +-1.0, then gain down)
Polyplexer (splits a single command input into several monophonic outputs and keeps track of individual notes between them)
probably three sorts of sampler (quick drum sequencer, quick single-sample "wavetable", then the full-on tracker sampler later on)

View File

@ -261,8 +261,8 @@ qint64 AudioEngine::readData(char *data, qint64 maxlen) {
// convert non-interleaved floating point into interleaved int16
int16_t* l = reinterpret_cast<int16_t*>(data);
int16_t* r = reinterpret_cast<int16_t*>(data+smp);
*l = static_cast<int16_t>(buffer[0][bufPos] * 32767);
*r = static_cast<int16_t>(buffer[1][bufPos] * 32767);
*l = static_cast<int16_t>(std::clamp(buffer[0][bufPos], -1.0f, 1.0f) * 32767);
*r = static_cast<int16_t>(std::clamp(buffer[1][bufPos], -1.0f, 1.0f) * 32767);
bufPos++;
data += stride;