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

Author Topic: SFML 2.0 SoundBuffer  (Read 3481 times)

0 Members and 2 Guests are viewing this topic.

VUT

  • Newbie
  • *
  • Posts: 4
    • View Profile
SFML 2.0 SoundBuffer
« 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

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2.0 SoundBuffer
« Reply #1 on: April 16, 2011, 11:09:22 pm »
Can you show the complete code?
Laurent Gomila - SFML developer

VUT

  • Newbie
  • *
  • Posts: 4
    • View Profile
SFML 2.0 SoundBuffer
« Reply #2 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;
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 2.0 SoundBuffer
« Reply #3 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).
Laurent Gomila - SFML developer

VUT

  • Newbie
  • *
  • Posts: 4
    • View Profile
SFML 2.0 SoundBuffer
« Reply #4 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: