Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::sound.setBuffer(...) - how to switch buffer without tiny sound lag?  (Read 2534 times)

0 Members and 1 Guest are viewing this topic.

kevincentius

  • Newbie
  • *
  • Posts: 1
    • View Profile
Let's say I have two SoundBuffer objects Buffer1 and Buffer2.

I have a Sound object, which is currently playing from Buffer 1 with looping on.
At certain times, the Sound object must switch between playing from Buffer 1 and playing from Buffer 2.

But when switching buffers, the sound gets briefly interrupted.
Imagine both buffers simply contain a sine wave: I want to switch buffers, but still hears a continuous, uninterrupted sine wave, as it would have been if I did not switch buffers.

My code goes something like this:

    sf::Time offset = sound.getPlayingOffset();
    sound.setBuffer(Buffer2);
    sound.setPlayingOffset(offset);

So, how can I achieve uninterrupted sound when switching buffers? Thanks!!
« Last Edit: December 13, 2014, 10:05:31 am by kevincentius »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
AW: sf::sound.setBuffer(...) - how to switch buffer without tiny sound lag?
« Reply #1 on: December 13, 2014, 10:09:12 am »
Use two sound objects. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything