GLBasic forum

Main forum => GLBasic - en => Topic started by: Agny on 2008-Apr-22

Title: 3D Sound
Post by: Agny on 2008-Apr-22
The command 3DSound or SoundPan and SoundVolume in real time is necessary
Title: 3D Sound
Post by: Schranz0r on 2008-Apr-22
Move to GLBasic - en.
Thats not realy a beta :)

btw.: You can use Bassmod or Fmod with INLINE :)
Title: 3D Sound
Post by: Kitty Hello on 2008-Apr-22
OK, on my TODO.
Title: 3D Sound
Post by: Agny on 2008-Apr-23
Please, help me.
I do not know as to use command INLINE .
Title: 3D Sound
Post by: Kitty Hello on 2008-Apr-23
Code (glbasic) Select
INLINE
 // C++ code goes here
ENDINLINE
Just like this.
Title: 3D Sound
Post by: Agny on 2008-Apr-23
I know it. :)

But how to write? Prompt please .
Title: 3D Sound
Post by: Kitty Hello on 2008-Apr-23
3D sound!? LOL...
Title: 3D Sound
Post by: Agny on 2008-Apr-23
Thanks that has not given up!  :/
Title: 3D Sound
Post by: Agny on 2008-Apr-24
It is bad, when at a forum there are no good experts. To prompt there is nobody. :(
Title: 3D Sound
Post by: Quentin on 2008-Apr-24
*rofl*
you're joking aren't you?

perhaps its a good idea if you explain a little bit more detailed what you want to do.
Just to ask "how to use inline" is "nearly the same as to ask "I want to rule the word. How should I start?"

Usage of INLINE is explained in the help files. Did you read them? Do you know programming in C++?

don't hesitate to ask if something is not clear for you, but even don't expect us to read your thoughts ;)
Title: 3D Sound
Post by: Moru on 2008-Apr-24
INLINE is not just for making 3D sound, INLINE is a specialized command for doing things that GL-Basic can't do on it's own yet. That means you need to do it all by yourself. And correct me if I'm wrong but I don't think INLINE works in the free version of GL-Basic, you need to buy the full version?
Title: 3D Sound
Post by: Agny on 2008-Apr-24
I wanted to make analogue of the program on Blitz3D:

Code (glbasic) Select
; Load3DSound Example
; -------------------

Graphics3D 640,480
SetBuffer BackBuffer()

camera=CreateCamera()
PositionEntity camera,0,1,-10

light=CreateLight()
RotateEntity light,90,0,0

plane=CreatePlane()
ground_tex=LoadTexture("media/Chorme-2.bmp")
EntityTexture plane,ground_tex

cube=CreateCube()
cube_tex=LoadTexture("media/b3dlogo.jpg")
EntityTexture cube,cube_tex
PositionEntity cube,0,1,0

microphone=CreateListener(camera) ; Create listener, make it child of camera
sound=Load3DSound("media/ufo.wav") ; Load 3D sound

While Not KeyDown(1)

If KeyDown(205)=True Then TurnEntity camera,0,-1,0
If KeyDown(203)=True Then TurnEntity camera,0,1,0
If KeyDown(208)=True Then MoveEntity camera,0,0,-0.05
If KeyDown(200)=True Then MoveEntity camera,0,0,0.05

; If left mouse button hit then emit sound from cube
If MouseHit(1) = True Then EmitSound(sound,cube)

RenderWorld

Text 0,0,"Use cursor keys to move about"
Text 0,20,"Press left mouse button to make a sound be emitted from the cube"

Flip

Wend

End
Or on DarkBasic:


Code (glbasic) Select
rem ==============================================
rem DARK BASIC EXAMPLE PROGRAM 8
rem ==============================================
rem This program demonstrates a simple 3D sound
rem ----------------------------------------------

rem SOUND COMMAND : Load a 3d sound
load 3dsound "sound.wav",1
loop sound 1
pause sound 1

rem Make a simple scene for the camera to look at
make matrix 1,10000.0,10000.0,25,25
load bitmap "rock1.bmp",1
get image 1,0,0,256,256
delete bitmap 1
prepare matrix texture 1,1,1,1
randomize matrix 1,20.0

rem Create characters to see
make object sphere 1,100.0
make object cylinder 2,100.0

rem Set variables for character position
x#=5000
z#=5000

rem Resume sound
resume sound 1

rem Activate manual sync
sync on

rem Begin loop
do

rem Control camera with arrow keys
if upkey()=1 then x#=newxvalue(x#,a#,10) : z#=newzvalue(z#,a#,10)
if downkey()=1 then x#=newxvalue(x#,a#,-10) : z#=newzvalue(z#,a#,-10)
if leftkey()=1 then a#=wrapvalue(a#-10.0)
if rightkey()=1 then a#=wrapvalue(a#+10.0)

rem Update character
y#=get ground height(1,x#,z#)+50.0
position object 1,x#,y#,z#
yrotate object 1,a#

rem Position camera to the back of the character
ca#=wrapvalue(curveangle(a#,ca#,12.0))
cx#=newxvalue(x#,wrapvalue(ca#+180),300)
cz#=newzvalue(z#,wrapvalue(ca#+180),300)
cy#=get ground height(1,cx#,cz#)+100.0
position camera cx#,cy#,cz#
yrotate camera wrapvalue(ca#)

rem Make object 2 look like a generator
rr#=wrapvalue(rr#+3.0)
position object 2,4000,25+(cos(rr#)*20),4000

rem SOUND COMMANDS
rem Position sound at object 2
position sound 1,object position x(2),0,object position z(2)

rem Position our listener at camera
position listener cx#,cy#,cz#
rotate listener 0,wrapvalue(360.0-ca#),0

rem Syncronise
sync

rem End loop
loop
It is an example on DarkBasicClassic.

I have Download and Setup " Header Files for INLINE "
Yes I do not know programming on C ++, but I tried under the book, entered ready examples after line INLINE, but they do not work
Title: 3D Sound
Post by: Agny on 2008-Apr-25
Command PLAYSOUND in GlBasic does not work in real time.
If the sound will be long, and the source of a sound will move quickly there will be a unpleasant effect.

Where to take a Full help files on commands INLINE?
Title: 3D Sound
Post by: Quentin on 2008-Apr-25
there the help for INLINE command delivered with GLBasic. And there are a couple of examples using INLINE in this board. Just use the search function.

so you want to use the sound functions of BlitzBasic? you can store them in a DLL (for windows) and include this functions into GLBasic with INLINE. Also for this there are some examples on the board.


for example:

http://www.glbasic.com/forum/viewtopic.php?id=848

http://www.glbasic.com/forum/viewtopic.php?id=567


Also please notice that you can buffer the same sound up to 4 times when loading it with LOADSOUND. Perhaps this is the reason for the unnice effets you wrote about. Anyway it would be easier to help you if you post your GLBasic source.
Title: 3D Sound
Post by: Agny on 2008-Apr-25
BlitzBasic and DarkBasic cannot create DLL .
Title: 3D Sound
Post by: Quentin on 2008-Apr-25
too bad ;(
BlitzMax can create DLL's but not Blitz3D I guess

but just to understand your problem with the sounds. You want to play the same sound several times. Right? or more exactly at every mousehit

you can buffer the sound up to 4 times with LOADSOUND "sound.wav", 0, 4

with function SOUNDPLAYING you can check wether a sound is still playing or not
Title: 3D Sound
Post by: Kitty Hello on 2008-Apr-25
No, he want's to be able to pan the sound *while* it is playing.
I'm implementing it. Please be patient.
Just write your game and wait for an update, OK.
Title: 3D Sound
Post by: Schranz0r on 2008-Apr-26
YEAH Nice :)
Title: Re: 3D Sound
Post by: djtoon on 2011-Jan-19
is there someting new on this request?