Audio fixes: gain() DSP effect, sfxr phase wrap, SDL2 backend compat
- SoundBuffer.gain(factor): new DSP method for amplitude scaling before mixing (0.5 = half volume, 2.0 = double, clamped to int16 range) - Fix sfxr square/saw waveform artifacts: phase now wraps at period boundary instead of growing unbounded; noise buffer refreshes per period - Fix PySound construction from SoundBuffer on SDL2 backend: use loadFromSamples() directly instead of copy-assign (deleted on SDL2) - Add Image::create(w, h, pixels) overload to HeadlessTypes and SDL2Types for pixel data initialization - Waveform test suite (62 lines) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
80e14163f9
commit
732897426a
9 changed files with 125 additions and 1 deletions
|
|
@ -18,7 +18,10 @@ PySound::PySound(std::shared_ptr<SoundBufferData> bufData)
|
|||
: source("<SoundBuffer>"), loaded(false), bufferData(bufData)
|
||||
{
|
||||
if (bufData && !bufData->samples.empty()) {
|
||||
buffer = bufData->getSfBuffer();
|
||||
// Rebuild the sf::SoundBuffer from sample data directly
|
||||
// (avoids copy-assign which is deleted on SDL2 backend)
|
||||
buffer.loadFromSamples(bufData->samples.data(), bufData->samples.size(),
|
||||
bufData->channels, bufData->sampleRate);
|
||||
sound.setBuffer(buffer);
|
||||
loaded = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue