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

Author Topic: Music not working  (Read 5644 times)

0 Members and 4 Guests are viewing this topic.

epilepticPi

  • Newbie
  • *
  • Posts: 15
    • View Profile
    • Email
Music not working
« on: July 15, 2016, 10:13:11 pm »
I just wrote this:
#include <SFML\Audio\Music.hpp>
        sf::Music music;
        if(!music.openFromFile("music_background.wav"))
        {
                std::cout << "ERROR" << std::endl;
        }
        music.setLoop(true);
        music.play();
 
But i got an error message in cmd:
Failed to open sound file "music_background.wav" (format not supported)
Failed to play audio stream: sound parameters have not been initialized (call initialize() first)

How can i fix that?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Music not working
« Reply #1 on: July 15, 2016, 11:16:34 pm »
What format is your music in?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

epilepticPi

  • Newbie
  • *
  • Posts: 15
    • View Profile
    • Email
Re: Music not working
« Reply #2 on: July 16, 2016, 12:46:06 pm »
.wav

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Music not working
« Reply #3 on: July 16, 2016, 01:39:11 pm »
That's not a format but merely a container.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

epilepticPi

  • Newbie
  • *
  • Posts: 15
    • View Profile
    • Email
Re: Music not working
« Reply #4 on: July 16, 2016, 02:37:08 pm »
"Waveform Audio File Format (WAVE, or more commonly known as WAV due to its filename extension)(rarely, Audio for Windows) is a Microsoft and IBM audio file format standard for storing an audio bitstream on PCs" -Wikipedia

victorlevasseur

  • Full Member
  • ***
  • Posts: 206
    • View Profile
Re: Music not working
« Reply #5 on: July 17, 2016, 08:36:40 pm »
Look at the "WAV file audio coding formats compared" section in the wikipedia article. You'll see that audio can be encoded in many different ways in a WAV file. You can even put MP3 encoded audio inside a WAV file.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Music not working
« Reply #6 on: July 17, 2016, 08:57:46 pm »
I guess we could rephrase the question:
which codec was used when saving the file?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

epilepticPi

  • Newbie
  • *
  • Posts: 15
    • View Profile
    • Email
Re: Music not working
« Reply #7 on: July 18, 2016, 01:25:36 pm »
vlc says its codec is MPEG Audio Layer 1/2(mpga)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Music not working
« Reply #8 on: July 18, 2016, 01:40:01 pm »
SFML only support PCM wav files.
Laurent Gomila - SFML developer