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

Author Topic: No audio comes out of my program  (Read 5375 times)

0 Members and 1 Guest are viewing this topic.

jeffkilledjohn

  • Newbie
  • *
  • Posts: 2
    • View Profile
No audio comes out of my program
« on: November 05, 2018, 12:54:39 am »
Hi at all! I'm trying to add sounds into my game, but I am getting into troubles.
I am currently using Irrlicht, and I know I can't mix these two engines without problems, but I want only to play audio (and maybe networking, later)!!!

I followed this guide (I am using Visual Studio 2017):
https://www.sfml-dev.org/tutorials/2.5/start-vc.php

I linked against these SFML libraries (Debug config):
sfml-system-d.lib
sfml-audio-d.lib
openal32.lib
flac.lib
vorbisenc.lib
vorbisfile.lib
vorbis.lib
ogg.lib

But no sounds comes out of my game when I copy-paste this code:
sf::SoundBuffer buffer;
if (!buffer.loadFromFile("sounds/select.ogg"))
    return;
sf::Sound sound;
sound.setBuffer(buffer);
sound.setLoop(true);
sound.play();


No errors appear in console. Where is the problem?

Thanks in advance!!

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: No audio comes out of my program
« Reply #1 on: November 05, 2018, 09:05:16 am »
Is your volume up? Also check it's not muted on an application level.

What's your complete code?
SoundBuffer and Sound objects need to stay alive as long as sound is playing.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

jeffkilledjohn

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: No audio comes out of my program
« Reply #2 on: November 05, 2018, 05:54:17 pm »
Aaaaah thanks!!! I thought only sf::Sound must be alive, because you are passing the SoundBuffer to sf::Sound, so it would be implicit. Anyway, thanks!!

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: No audio comes out of my program
« Reply #3 on: November 07, 2018, 11:00:27 pm »
Just to clarify, the sf::Sound doesn't store the sf::SoundBuffer (or a copy) but does store a pointer to the one you passed. This makes the sf::Sound a rather lightweight object that can be passed around and created quite quickly. Also, multiple sounds can point to the same sound buffer; this reduces the amount of storage used.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*