3D Sound

Previous topic - Next topic

Agny

The command 3DSound or SoundPan and SoundVolume in real time is necessary

Schranz0r

Move to GLBasic - en.
Thats not realy a beta :)

btw.: You can use Bassmod or Fmod with INLINE :)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Kitty Hello

OK, on my TODO.

Agny

Please, help me.
I do not know as to use command INLINE .

Kitty Hello

Code (glbasic) Select
INLINE
 // C++ code goes here
ENDINLINE
Just like this.

Agny

I know it. :)

But how to write? Prompt please .

Kitty Hello

3D sound!? LOL...

Agny

Thanks that has not given up!  :/

Agny

It is bad, when at a forum there are no good experts. To prompt there is nobody. :(

Quentin

*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 ;)

Moru

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?

Agny

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

Agny

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?

Quentin

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.

Agny

BlitzBasic and DarkBasic cannot create DLL .