SFML community forums

Help => Audio => Topic started by: VUT on April 16, 2011, 09:59:41 pm

Title: SFML 2.0 SoundBuffer
Post by: VUT on April 16, 2011, 09:59:41 pm
hello ,


I compiled  SounBuffer's example  found on DOC sfml 2.0
unfortunately compiler return this message:

Code: [Select]

error: aggregate ‘sf::SoundBuffer buffer’ has incomplete type and cannot be defined


I found the same example on forum.
Can you help me ? thanks
Title: SFML 2.0 SoundBuffer
Post by: Laurent on April 16, 2011, 11:09:22 pm
Can you show the complete code?
Title: SFML 2.0 SoundBuffer
Post by: VUT on April 16, 2011, 11:31:47 pm
sure

Code: [Select]


#include <iostream>
#include <stdio.h>
#include <SFML/Graphics.hpp>
#include <SFML/Graphics/Text.hpp>
#include <SFML/Audio/Sound.hpp>


using namespace std;
using namespace sf;

int main()
{
    char w;
    //
    SoundBuffer buffer;
    buffer.LoadFromFile("Shot3.wav");
    Sound sound(buffer);

    cout << "Hello world!" << endl;

    sound.Play();

    do
    {
        w = getchar();

    }
    while (w!= 'e');

    sound.Stop();

    return 0;
}
Title: SFML 2.0 SoundBuffer
Post by: Laurent on April 17, 2011, 09:59:47 am
You forgot to include the SFML/Audio/SoundBuffer.hpp header (or simply SFML/Audio.hpp for the whole module).
Title: SFML 2.0 SoundBuffer
Post by: VUT on April 17, 2011, 01:35:24 pm
There is an example with audio.hpp and I have read again the whole doc

     SoundBuffer buffer;
     buffer.LoadFromFile("Shot3.wav");
     Sound sound;
     sound.SetBuffer(buffer);

     sound.Play();

 it is my fault   , thanks. :oops: