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

Author Topic: Getting crazy with audio  (Read 4111 times)

0 Members and 1 Guest are viewing this topic.

TheEnigmist

  • Full Member
  • ***
  • Posts: 119
    • View Profile
Getting crazy with audio
« on: May 11, 2011, 03:58:56 pm »
I know that you are working on it, but yesterday my little stupid project runs well. Now when i lunch it will crash with this error:


I can't use any sound on my project now :/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Getting crazy with audio
« Reply #1 on: May 11, 2011, 04:09:17 pm »
Quote
I can't use any sound on my project now

Doesn't the crash happen at exit?
Laurent Gomila - SFML developer

TheEnigmist

  • Full Member
  • ***
  • Posts: 119
    • View Profile
Getting crazy with audio
« Reply #2 on: May 11, 2011, 07:33:27 pm »
Yesterday was like it. Project ran well, and only at the end VS2010 showed that error.
Now at start ofp roject it crash and show this error!
I will try to ue sf::Music, maybe i will run it...

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Getting crazy with audio
« Reply #3 on: May 11, 2011, 07:40:37 pm »
Are you sure there is no mistake in your code? Have you already tried to isolate the place where the error occurs, and to come up with a minimal reproducing example?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

TheEnigmist

  • Full Member
  • ***
  • Posts: 119
    • View Profile
Getting crazy with audio
« Reply #4 on: May 11, 2011, 08:09:25 pm »
Changed to sf:Music... different error, but i'm able to run project:


This is the code:
Code: [Select]

#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Audio.hpp>
#include <iostream>

using namespace std;

int main()
{


//Creazione Finestra Applicazione
sf::RenderWindow Game(sf::VideoMode(800,600,32),"Game",sf::Style::Titlebar);
//inputs:
const sf::Input& Input = Game.GetInput();


//Game.SetFramerateLimit(60);

//Creazione Rettangolo
sf::Shape box(sf::Shape::Rectangle(0, 0, 50, 50, sf::Color(127, 0, 0)));

//Posizionamento di 'box'
box.SetPosition(100, 100);



/*sf::SoundBuffer Buffer;
if (Buffer.LoadFromFile("guitar_1.ogg"))
{
//Buffer.~SoundBuffer();
return EXIT_FAILURE;
}
//Create a sound instance and play it
sf::Sound Sound(Buffer, true, 1.0F, 100.0F);
Sound.Play();
*/

//Buffer Immagine
sf::Image Image;
if (!Image.LoadFromFile("image.png"))
{
return EXIT_FAILURE;
}

sf::Music music;
if (!music.OpenFromFile("guitar_1.ogg"))
{
return EXIT_FAILURE;
}

music.Play();


//Set Image Mask
Image.CreateMaskFromColor(sf::Color(0, 255, 0, 255));

//Creazione Sprite
sf::Sprite Sprite;

//Set Sprite Image
Sprite.SetImage(Image);

//Set Sprite Position
Sprite.SetPosition(400,400);

//MOVIMENTI
const float Speed = 1.f;
float Left = 0.f;
float Top  = 0.f;
float testx = 0;
float testy = 0;


//Game Loop
while (Game.IsOpened())
{
//Pulizia finestra
Game.Clear(sf::Color(1,158,241));

//Creazione Eventi
sf::Event Event;

//Eventi
while (Game.PollEvent(Event))
{
bool Sinistra = Input.IsKeyDown(sf::Key::Left);
bool Destra = Input.IsKeyDown(sf::Key::Right);
bool Giu = Input.IsKeyDown(sf::Key::Down);
bool Su = Input.IsKeyDown(sf::Key::Up);
bool LetA = Input.IsKeyDown(sf::Key::A);
bool LetS = Input.IsKeyDown(sf::Key::S);
bool LetD = Input.IsKeyDown(sf::Key::D);
bool LetW = Input.IsKeyDown(sf::Key::W);
bool ESC = Input.IsKeyDown(sf::Key::Escape);

if (ESC)
{
//music.~Music();
Game.Close();
}
if (Su)
{
Sprite.Move(0,-2);
}
if (Giu)
{
Sprite.Move(0,2);
}

if (Destra)
{
Sprite.Move(2,0);
}

if (Sinistra)
{
Sprite.Move(-2,0);
}

if (LetA)
{
box.Move(-2,0);
}
if (LetD)
{
box.Move(2,0);
}

if (LetS)
{
box.Move(0,-2);
}

if (LetW)
{
box.Move(0,2);
}

if (ESC)
{
Game.Close();
}


}

//Movimenti
box.Move(0.1,0);

cout <<"\rX:" << fixed << box.GetPosition().x << "\tY:"<< box.GetPosition().y;

//Inserimento 'box'
Game.Draw(box);

//Inserimento 'sprite'
Game.Draw(Sprite);

//Mostrare la finestra
Game.Display();
}
music.Stop();
return EXIT_SUCCESS;
}

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Getting crazy with audio
« Reply #5 on: May 11, 2011, 09:21:33 pm »
Code: [Select]
Buffer.~SoundBuffer();
music.~Music();
Don't do this. Calling destructors explicitly results in undefined behaviour in the very most cases.

Please reduce your code to a minimal example which only contains the relevant parts (no game logic or advanced input handling) and which still reproduces the error. Do the SFML audio examples work?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

TheEnigmist

  • Full Member
  • ***
  • Posts: 119
    • View Profile
Getting crazy with audio
« Reply #6 on: May 11, 2011, 09:45:16 pm »
Oh yeah, sorry :P
I made this simple code:
Code: [Select]

#include <SFML/Audio.hpp>
int main()
{
       sf::SoundBuffer Buffer;
if (!Buffer.LoadFromFile("1.ogg"))
return EXIT_FAILURE;

sf::Sound Sound(Buffer);
Sound.Play();

return EXIT_SUCCESS;
}

I got the same error i've posted before!
And i get the same with sf::Music.
Code: [Select]
#include <SFML/Audio.hpp>

int main()
{
sf::Music musica;
musica.OpenFromFile("1.ogg");

musica.Play();


return EXIT_SUCCESS;
}

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Getting crazy with audio
« Reply #7 on: May 11, 2011, 11:21:21 pm »
Do you link and load (DLLs) everything correctly? Do you use the dynamic libsndfile and OpenAL libraries supplied with SFML? Are you sure there are no older versions in Windows/System32 that are accidentally used instead?

In case of doubt, I would try to get rid of everything that has to do with SFML and reinstall it completely. Inconsistent compilation or link options may also lead to such errors.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

TheEnigmist

  • Full Member
  • ***
  • Posts: 119
    • View Profile
Getting crazy with audio
« Reply #8 on: May 11, 2011, 11:44:06 pm »
I've used ALL libs (ext too). I've put alll DLLs of SFML into dir of .exe.
For the older version, uhm how can i check it?
I've compiled yesterday all libs and dlls with cmake!

 

anything