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

Author Topic: Sound "plays", but I can't hear anything  (Read 4108 times)

0 Members and 1 Guest are viewing this topic.

Kivattt

  • Guest
Sound "plays", but I can't hear anything
« on: August 24, 2018, 09:44:24 pm »
I tried posting this before, I got the msg that it was already posted, but I didn't see any posts by me. I hope I'm not reposting anything
Hello, I'm trying to play a wav file using sf::Sound. The buffer I'm using loads the file, and the sound's status is sf::Sound::Playing. I can't hear anything though. Any idea why? I've had problems with jack before. See https://ibb.co/m0mYTU for code, and https://ibb.co/dJa5a9 for output.
« Last Edit: August 24, 2018, 10:41:26 pm by Kivattt »

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Sound "plays", but I can't hear anything
« Reply #1 on: August 24, 2018, 11:19:40 pm »
Have you tried adding sleep or getline to not let your main quit instantly?
Back to C++ gamedev with SFML in May 2023

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Sound "plays", but I can't hear anything
« Reply #2 on: August 25, 2018, 12:49:37 am »
Meaning if you don't actually wait for the sound to finish playing and just quite the main function, your sound objects will be destroyed and you application will be terminated.

You can have a while loop that checks the status and to prevent the loop from eating up the full process time, you can add a sleep for a few milliseconds every loop iteration.

Also it's better to post short code snippets directly here as text with the [code=cpp][/code] tags rather than externally hosted or even worse posted as image. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Kivattt

  • Guest
Re: Sound "plays", but I can't hear anything
« Reply #3 on: August 25, 2018, 10:07:26 am »
Have you tried adding sleep or getline to not let your main quit instantly?

Silly me, that made it work

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Sound "plays", but I can't hear anything
« Reply #4 on: August 25, 2018, 05:37:36 pm »
At least it's not an actual bug and if you ever need to ask something else you already have the forum account. ;D

And it gave me a good giggle during a busy week. :P
Back to C++ gamedev with SFML in May 2023