Author Topic: Sounds  (Read 3294 times)

0 Members and 1 Guest are viewing this topic.

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Sounds
« on: October 07, 2020, 11:10:08 pm »
What ways are there to play sounds with QB64? Ones I know of are:
1) SOUND
2) PLAY
3) WAV player someone posted here
4) MessageBeep library

With methods 1 and 3 there's an annoying "click" as the sound begins
and when it ends. Pleasant sounds don't seem possible with 1 or 2.
4 sounds nicest and there's no "click", but has a very limited selection.

I get all sorts of NICE short sounds when browsing with Chrome, with
no annoying "click".  How is it done?
It works better if you plug it in.

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Sounds
« Reply #1 on: October 08, 2020, 10:55:34 am »
The built-in sound playing capabilities of QB64 are pretty good, with which you can play mp3/ogg/wav sounds easily.  Here's the wiki page of _SNDOPEN that shows how to play sounds:  https://www.qb64.org/wiki/SNDOPEN.

- Dav
« Last Edit: October 08, 2020, 11:29:33 am by Dav »

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: Sounds
« Reply #2 on: October 08, 2020, 02:49:55 pm »
Yep, that's the way.  Variety with no clicking.

Thanks!
It works better if you plug it in.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Sounds
« Reply #3 on: October 08, 2020, 02:58:51 pm »
Just a side note, if your doing loop-able sounds like Back Ground Music(BGM) you'll want to probably use OGG, as for some reason a lot of MP3 encoders add silence to the file, this also makes it better to use OGG for repeating Sound Effects (SFX) again because of the silence addition. of course if you have a MP3 encoder that doesn't add that I think you can get smaller file sizes with better quality in MP3 but thats just some things I have noted here recently when adding sounds to games.
Granted after becoming radioactive I only have a half-life!

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: Sounds
« Reply #4 on: October 09, 2020, 12:19:56 am »
I finally remembered that the WAV player I tried used _SNDPLAY. 
Something about how it was implemented, or how I modified it,
led to a click at the beginning and end of sound.  I get no
such click now. 

Re using sound files in a program, is it better to load them
all during initialization and keep them open, or load/use/close?
Although there are 10 files involved, they're all small (20K)
except one (1M).  It's for my chess program, so some of them
are used rather often.  Even if the total was 2 megs, that's
peanuts for modern computers, right?
It works better if you plug it in.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Sounds
« Reply #5 on: October 09, 2020, 09:54:27 pm »
I would say load everything at startup. Less to worry about later.
Granted after becoming radioactive I only have a half-life!

FellippeHeitor

  • Guest
Re: Sounds
« Reply #6 on: October 10, 2020, 05:21:39 pm »
I usually load everything at startup too.