SFML community forums

Help => Audio => Topic started by: Lupinius on September 01, 2010, 04:30:42 pm

Title: Buffer reading?
Post by: Lupinius 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?
Title: Buffer reading?
Post by: Laurent 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], ...).