Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / About set sound volume and set sound pan functions (Errors or Bugs)

Author
Message
Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 21st Mar 2011 01:25
Hi ,

I am working with my game , everything so far is good.

Now I try to create some 3D sound , but not as real 3D but like
pseudo 3D.

For example when you hear one door opening in front of you
you hear the sound of the door near to you.


But when you go far away from the door , you hear the sound lower.

I am using one technique which calculates how many squares are you far from one door.

Generic how far you are from one object which makes some sound.

So I am using 2 commands:

Set sound pan
Set sound volume

But there is one problem with these 2 functions

The set sound pan takes 2 arguments which one is the sound number and the second is the value from -10000 to 10000 when the second argument is minus value , you hear the sound at the left speaker and when the value is plus value , you hear the sound at the right speaker.

The problem is either value is -1 or -1000 or -5000 or -10000 you hear the sound at the left speaker , but you hear the sound complete at the left speaker , it doesn't have sensitivity to hear little from the left and most of the right and when the value becomes more minus you hear more at the left and fewer at the right.

You just hear the sound completely left or right.

This about set sound pan function.


And there is a problem with sound volume function.

Set Sound volume function take 2 arguments , one is for sound number and the other takes value from 0 to 100 and is percentage value.

So when you go far away from the noisy object , I give in the set sound volume some value for example 100 when I am near to the noicy object and then I give 70 if I am far but not very far and 40 if I am very far and when I am very very far almost you can't here the sound , I give value 10.

But in all cases the sound volume remains 100.

Might there are bugs in Set sound pan and Set sound volume functions
There are not work well.

Is there any way to fix this?

Or is there any other sound dll or plugin?

Thank you
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 21st Mar 2011 01:57
Hope this helps.
I just loaded up a sound and did some tests on the statements you said you were having problems with.

Ill start with sound pan.
Set sound pan does alter the sound left to right, i managed to just about get this working but its very tricky to get the sound you want from this, i had to mess around with multiple values just to get it to not appear like it was all out of one or both. Its just a case of finding the right value, for the sound i had and the volume i was playing it, anything from -2000 appeared to come soley from the left speaker, 800 seemed to come from mainly the left but a little through the right, and anything from 0 to -400 seemed to be both speakers at once. Its probably the sound and your volume settings that will determine just what effect you get. It was a little tricky but i was able to get the sound i wanted eventually with some playing.

In regards to sound volume, this also worked for me but was much the same issue as above. Tricky to get the desired effect. With the volume i have my speakers at anything below 50 was not able to be heard (even though at full volume i could hear it more than clear so 50 - i.e 50% - would or should be half) there is no way that 50% is half when using that function, but again if you play around you might be able to get the desired effect.

Something to try might be a for loop which cyles through the sound pan and prints the value as it slowly pans from left to right. Pressing a key could stop the sound when you get the desired effect and make a note of the value displayed. This may help and you could also do this for volume.

Hope this helps.
Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 21st Mar 2011 02:27
So the functions according to manual are wrong.

It doesn't work from -10000 to +10000 to have correct effect.

And I test sound volume from my main source code worked.

when I run it through function doesn't work.

I will try to change me code a little , but so far I don't have my
desired effect.
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 21st Mar 2011 02:35
Yes i have to admit it is very difficult to get your sound the way you want it, but although there is barely any audiable difference between -9999 and -10000 (it almost seems pointless) the difference is technically there.

I wrote a very quick and dirty program that demonstrates it. Feel free to pop you own sound in and mess with the wait values and step command on sound pan to achive the desired result.

Sound file is attached on the download bit but its a horrible sound in the program because the way it works.

Attachments

Login to view attachments
Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 22nd Mar 2011 00:05 Edited at: 22nd Mar 2011 00:07
In your sound pan test , I start hear sound move from left to right when the value is from -3000 to 2000

And in volume test sound started after 50%

Your program was run , but the functions have bugs.

Why in the manual they say choose values from -10000 to 10000 and they don't say choose numbers from -3000 to 2000 for sound pan

And why in volume don't they say you will hear sound after 50%

Both functions are broken need to be fixed in next version of darkbasic...

Thank you for your program , I will try to make changes in my code and if I manage to do something I will inform...
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 22nd Mar 2011 00:58
I do think the functions dont work quite as intended but i also think it depends on what the sound is (as sounds are recorded differently and at different sound levels) and also what your settings are. As horrible as that sound is if i have my volume up very very high i can hear it come in from about 5%, its just the way my volume is set up with the sound.
I agree that 50% should be half the volume, and if i play that sound in winamp at 50% it sounds much louder than 50% in DB at the same physical volume on my computer speakers. So why they say 50% i dont know but its probably because its too difficult to get an exact match for each sound and its recorded volume plus it has to take in your volume aswell and windows setting etc.
However with a program like what i did you could set up the sound you want, set the desired average listening volume on your setup and then play the program till roughly the desired sound is heard then make a note of the volume and at least that will give you some rough ideas of how to work around it.

As for sound pan, i also agree, -10000 to 10000 seems a little much as there is barely any audiable difference between -10000 and -9999 but it only appears to "kick in" around -3000 because of the sound and various other settings, they will probably just be far too subtle for us to pick up. Again though using the program i hope you will get a desired "range" to play around with.

Good luck in your project.
Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 22nd Mar 2011 01:54 Edited at: 22nd Mar 2011 01:57
Your info helped me a lot.
But I discover , you need to run the command fast.

What I mean?

You need to run the set volume command and immediately call play sound command to have better effect , if you run the command after your own function then the effect is not working.

This is strange...
Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 25th Mar 2011 01:05 Edited at: 25th Mar 2011 02:07
I manage with your program to have good effect with set sound pan and set sound volume.

I have one problem.


As I told , I have one noisy object and when I go around to this object , I want to hear the sound left or right or slower when I get far away from my noisy object.


In my game for example I have one door for example as a noisy object.

When I am opening my door , I hear the creak sound of the door , in fact my door is a slide door and when it opens you hear some wooden sound.

Well , I have the data of my door in one type.

For example the code describe my data type to keep my data of my door.





The code above is exactly the code I use to store my data of my door.

In fact my array doors keeps all data of my door mechanism.

(levels,number_of_doors) this means in my 10 levels of my game , each level have 100 doors.

And there is another one data type which I store the data of my players as (party)



The above code is exactly the data type code to keep my party position , direction and level of my party.

So , now I am comparing the party position with my door position to see if I am near or far from my doors or if there is door at the left or at the right accourding to my direction.

I use this kind of code:




The above code scans all of my doors in my currect level I am , from my party.level variable.

So we assume , I have 100 unique doors in my map.
If I want to initialize one of my doors I write this code:



The above code tells my game , I have one door , in level 1 and the door is number 1 from whole 100 doors I have.
The position of specific door is 5,4 squares on the map.

The graphic variable is the graphic of the door (wooden , metal , glass etc)
The frame variable is the frame sprite animation of my door.
The mech variable is the mechanism of the door , you will get confused but you don't care about this
and the State variable means , what is the state of the specific door , is locked , is unlocked , is closed , is opened , is opening (in middle of opening animation) or is closing (in middle of closing animation).

From all of these we care only about x and y variables because I use these variables only to compare my party position , with my door position.

If my party.x+1 square there is one door.

Pseudo code


I don't want to confuse you very much , but the problem is.

When I am in front of my door , I mean the party.x=door(1,1).x
but I am far the y variable of my party if bigger or smaller , I hear my door far (set sound valume slower)
When I am at the left of my door or the right of my door I hear the sound from my left or my right.

How to describe my problem.

When I am horizontal or vertical from my door , I hear my sound well
but when I am diagonal from my door , the all variables get confused.

For example , doors().x=5 and doors.y=5 but the party.x=4 and party.y=6

I have one picture to illustrate the idea.

When I am in front of my door , or the door is behind me or at the left or right , I hear the sound and pan effect well.

But when I am diagonal , or my door is behind me , but not opposite behind me but behind and at left or behind and right or in front left or in front and right , or far front and far right then the sound confusing , in fact I hear the sound pan correct but not the sound volume correct. (Now you got confused very much)

I thing I described the problem well.

If you didn't understand , I will post my game to see...

If few words , even I am horizontal , vertical or diagonal , 1 or more squares far , to hear my door far or at the left or right correct.

Like I am in some sound range from my door...

Did you get the point?

Attachments

Login to view attachments
Takis76
19
Years of Service
User Offline
Joined: 9th Apr 2005
Location: Greece
Posted: 26th Mar 2011 00:26 Edited at: 26th Mar 2011 00:28
I thing I MADE IT.....

I calculate the difference of distance between my party.x position minus the doors(xx,xx).x position.

And I made one test and the sound volume was correct.

If my distance is 1 or -1 I have sound volume 90%
If my distance is 2 or -2 I have sound volume 80%
If my distance is 3 or -3 I have sound volume 70%
If my distance is 4 or -4 I have sound volume 60%
when I have distance larger than -4 or 4 I have sound volume 0
that means the door is very far and you hear nothing.


I thing this fixed and my diagonal position of my doors...

I will test it and with sound pan and now I will have complete 3D surround system in my game , I will able to hear monsters behind walls , or other kind of horror ambience sounds around.

Wow , my game will become bery scary...


I would like to ask something else.

Is it possible to convert all negative values to positive without need to check and minus values.

I mean any distance which is minus value , could be converted as positive value.

Thank you very much...

Login to post a reply

Server time is: 2024-11-22 23:13:28
Your offset time is: 2024-11-22 23:13:28