fbsound 1.1 (dynamic) Windows/Linux 32 and 64-bit (wav mp3 ogg mod it xm s3m)

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
leopardpm
Posts: 1795
Joined: Feb 28, 2009 20:58

Re: fbsound 1.1 (dynamic) Windows/Linux 32 and 64-bit (wav mp3 ogg mod it xm s3m)

Post by leopardpm »

badidea wrote:Creating a WAV-file (from data in memory) does not seem too hard: http://soundfile.sapp.org/doc/WaveFormat/
since its just a onetime thing...using an online converter works fine for me.

plus, that page describes the WAV format...would also need the OGG format and then a way to translate from ogg->wav.... too much work for simple tsk me thinks
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: fbsound 1.1 (dynamic) Windows/Linux 32 and 64-bit (wav mp3 ogg mod it xm s3m)

Post by badidea »

For creating a WAVE file, see: viewtopic.php?f=7&t=27330
With fbsound, you can probably convert (open) OGG to memory.
Dr_D
Posts: 2451
Joined: May 27, 2005 4:59
Contact:

Re: fbsound 1.1 (dynamic) Windows/Linux 32 and 64-bit (wav mp3 ogg mod it xm s3m)

Post by Dr_D »

DJ, sorry if this question has already been covered... I missed it, if it was. I've been out of the loop for a while.
Anyway, I'm wondering what is the best approach to use when enabling/disabling an infinitely looping sound? It's a retro game I've been playing with, and the sound is used for a space-ship thruster. When the thrust key is pressed, the volume will be set using distance, when it isn't pressed, the volume is set to 0. I'm getting a popping sound whenever I do this, and I wonder if there is a better approach? At first, I tried to play/stop the sound, but it had the popping artifact, so I tried switching to this method, and the popping persists. It might just be that my PC has a weird driver/hardware. Thanks for any tips or advice. This is the first time I've tried to use FBSound for a complete game.

Code: Select all


		if .thrust>0 then

			dim as vec2f vec = .dirVec*-1
			vec.normalize()
			.prt->spawn_thrust( .model(0).tLines(2).p1+.p, .model(0).tLines(1).p1+.p, .model(0).tLines(3).p1+.p, vec*50, PARTICLE_ENUM.THRUST, fTime + .5 )
			fbs_Set_SoundPan (sound(2), -((cam.p.x-player.p.x)+320)/320)
			fbs_Set_SoundVolume( sound(2), 100-(player.p.dist(cam.transP)/SOUND_FALLOFF_FACTOR) )
			
		else
		
			fbs_Set_SoundVolume( sound(2), 0 )
			
		end if

Dr_D
Posts: 2451
Joined: May 27, 2005 4:59
Contact:

Re: fbsound 1.1 (dynamic) Windows/Linux 32 and 64-bit (wav mp3 ogg mod it xm s3m)

Post by Dr_D »

Sorry to be a pest, but I have another question. Is there an utility to determine if a sound is currently playing?
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: fbsound 1.1 (dynamic) Windows/Linux 32 and 64-bit (wav mp3 ogg mod it xm s3m)

Post by badidea »

Dr_D wrote:Sorry to be a pest, but I have another question. Is there an utility to determine if a sound is currently playing?
I made this routine (after some advice somewhere in this topic):

Code: Select all

function my_fbs_Sound_playing(hSound as integer) as boolean
	dim as integer nLoops
	fbs_Get_SoundLoops(hSound, @nLoops)
	if nLoops = 0 then return false
	return true
end function
I cannot answer the question on looping sound (at the moment).
Dr_D
Posts: 2451
Joined: May 27, 2005 4:59
Contact:

Re: fbsound 1.1 (dynamic) Windows/Linux 32 and 64-bit (wav mp3 ogg mod it xm s3m)

Post by Dr_D »

Ahh, hmm.... I hadn't noticed it worked with a specific pointer like that. Thanks!
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: fbsound 1.1 (dynamic) Windows/Linux 32 and 64-bit (wav mp3 ogg mod it xm s3m)

Post by badidea »

Some thoughts on the sound looping question...
If the last sample value of the sound does not line up with the first sample value of the sound, I would expect some 'pop'.
I was playing a bit with this in the ALSA topic: https://freebasic.net/forum/viewtopic.p ... sa#p248912
There was another issue with the sound buffer not being filled fast enough in the beginning.
I think fbound also uses ALSA (at least on linux).

Edit, see also:
https://freebasic.net/forum/viewtopic.p ... op#p187445
https://freebasic.net/forum/viewtopic.p ... op#p105603
Last edited by badidea on May 23, 2019 22:16, edited 1 time in total.
Dr_D
Posts: 2451
Joined: May 27, 2005 4:59
Contact:

Re: fbsound 1.1 (dynamic) Windows/Linux 32 and 64-bit (wav mp3 ogg mod it xm s3m)

Post by Dr_D »

Well, what I did was create the thrust sound, double the length, copy the first half and paste it in reverse at the midpoint. It loops seamlessly, but maybe the trick is to stop it at an endpoint?
Dr_D
Posts: 2451
Joined: May 27, 2005 4:59
Contact:

Re: fbsound 1.1 (dynamic) Windows/Linux 32 and 64-bit (wav mp3 ogg mod it xm s3m)

Post by Dr_D »

I can post the sound, if you would like to experiment with it. I'll post the whole program eventually, but it isn't really a game yet... It isn't that impressive right now, and you can't even die yet. :p
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: fbsound 1.1 (dynamic) Windows/Linux 32 and 64-bit (wav mp3 ogg mod it xm s3m)

Post by badidea »

Dr_D wrote:I can post the sound, if you would like to experiment with it. I'll post the whole program eventually, but it isn't really a game yet... It isn't that impressive right now, and you can't even die yet. :p
I can try something, but not in the next 16 hours (sleep and work first).
I once started some code to simulate a 'revving' car to experiment with fbsound. But I got distracted by some other stuff and never continued.
Dr_D
Posts: 2451
Joined: May 27, 2005 4:59
Contact:

Re: fbsound 1.1 (dynamic) Windows/Linux 32 and 64-bit (wav mp3 ogg mod it xm s3m)

Post by Dr_D »

Ok. Thanks again. Get some sleep. You've already opened doors for me. :)
Dr_D
Posts: 2451
Joined: May 27, 2005 4:59
Contact:

Re: fbsound 1.1 (dynamic) Windows/Linux 32 and 64-bit (wav mp3 ogg mod it xm s3m)

Post by Dr_D »

Heya... I did some tests and discovered that the popping artifact has nothing to do with FBSound. As far as I can tell, there is an issue with my audio hardware. Even with professional audio recording/editing software, the buffers eventually get corrupted. Sorry for the nonsense. lol
mrToad
Posts: 430
Joined: Jun 07, 2005 23:03
Location: USA
Contact:

Re: fbsound 1.1 (dynamic) Windows/Linux 32 and 64-bit (wav mp3 ogg mod it xm s3m)

Post by mrToad »

I was late to see this and I wanted to say thank you Joshy! I compiled several of your tests in GAS 32/64 as well as GCC 32/64 (EDIT: fbc 1.05) and all of them work perfectly. (Win 7 64bit) This is a wonderful contribution to the community and I hope things like this continue to happen because I love FB! Thank you again for your good work, fbSound is awesome. I especially love the speed of playback and panning controls for sound effects.

May I ask about the license? Now that it's matured so well, is it possible to be used in a commercial project?
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: fbsound 1.1 (dynamic) Windows/Linux 32 and 64-bit (wav mp3 ogg mod it xm s3m)

Post by D.J.Peters »

mrToad wrote:.. fbSound is awesome ...
good to know I will give it a try :-)

All my software and source code in the public domain can be modified, distributed, or sold even without any attribution by anyone !

For libMad (MP3), libDump (tracker modules) and libVorbis (OGG) take a look at the doc folder.

Joshy
mrToad
Posts: 430
Joined: Jun 07, 2005 23:03
Location: USA
Contact:

Re: fbsound 1.1 (dynamic) Windows/Linux 32 and 64-bit (wav mp3 ogg mod it xm s3m)

Post by mrToad »

Yes I saw those licenses. Pretty easy-going.
D.J.Peters wrote:good to know I will give it a try :-)
Like you don't know already. :)
D.J.Peters wrote:even without any attribution by anyone !
But I would be happy to give credit for this gift.

EDIT:
Also tested GCC/GAS 32/64 on latest 1.07 fbc, and all work great!
Post Reply