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

Author Topic: Buffer reading?  (Read 3030 times)

0 Members and 1 Guest are viewing this topic.

Lupinius

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Buffer reading?
« on: September 01, 2010, 04:30:42 pm »
I'm trying to analyze a sound in SFML2. I'm accessing the SoundBuffer data like this:
Code: [Select]
#include <SFML/Audio.hpp>
#include <iostream>

int main() {

    sf::SoundBuffer buffer;
    buffer.LoadFromFile("no quiet.ogg");
    sf::Sound sound;
    sound.SetBuffer(buffer);

    sound.Play();

    while (sound.GetStatus() == sf::Sound::Playing) {

        std::cout << buffer.GetSamples()[int(sound.GetPlayingOffset()*buffer.GetSampleRate())] << std::endl;
        sf::Sleep(0.01);

    }

}

Is this a good way to access the buffer? And how does SFML handle stereo sounds?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Buffer reading?
« Reply #1 on: September 01, 2010, 05:07:46 pm »
Quote
Is this a good way to access the buffer?

This is one way. Whether it is a "good" one or not depends on what you want to do.

Quote
And how does SFML handle stereo sounds?

Channel data is interleaved in the buffer (left[0], right[0], left[1], right[1], ...).
Laurent Gomila - SFML developer