Controlling music volume with script?

What exactly do you need it for?

If you're having problems hearing sfx/speech over music than the files might need to be optimized.
 
Checked the documentation project, there's nothing, until I got into the source code and found this:

//setmusicvolume(left, right)

Apparently, you can give the number value of the left and right channels. You could use this for various stuff, but for fading music, there's the fade music command.
 
CRxTRDude said:
Checked the documentation project, there's nothing, until I got into the source code and found this:

//setmusicvolume(left, right)

Apparently, you can give the number value of the left and right channels. You could use this for various stuff, but for fading music, there's the fade music command.

Would that work if the music volume is low and then when you go to another area in the same level, the music volume gets normal or high? Where will setmusicvolume be set in? A stage.txt (not levels.txt)?

setmusicvolume(10, 5); //Left volume higher than the right volume.

EDIT: I am lost in where to setmusicvolume. I tried to make the volume on the left stay higher than the right which I make it no sound, but I can't get it to work.

Code:
#bglayer        {path} {xratio} {zratio} {xposition} {zposition} {xspacing} {zspacing} {xrepeat} {zrepeat} {transparency} {alpha} {watermode} {amplitude} {wavelenghth} {wavespeed} {bgspeedratio}
#bglayer	path                     xratio zratio xoffset zoffset xspacing zspacing xrepeat zrepeat trans alpha w-mode ampl wlen wmode begsize endsize
bglayer		data/bgs/ryu/ryubg.png   1      0.5    0       0       0        0        -1      1       1     0     0      0    0    0
bglayer		data/bgs/ryu/ryubg1.png  0      0.5    0       0       0        0        -1      1       1     0     0      0    0    0
panel data/bgs/ryu/ryu1.png
order		a
direction both
settime         0
notime 1
cameratype 0
#music           data/music/ryu.ogg 1992614.4  #1:30.368 = 90.523 => 22050 * 90.368 = 1992614.4
#music            data/music/ken.ogg 4124628.9 #93.529 #Ken's theme 1.33.480 = 93.480 => 44100 * 93.480 4122468
#music		data/music/balrog.ogg 4186809.9 #Balrog's theme 44100 * 94.861 =
#music           data/music/bison.ogg 3991491 #Bison's theme 44100 * 90.510
#music            data/music/akuma.ogg 4110120 #Akuma's theme
#music             data/music/gou-ryu.ogg 3503789.1 #Gouken vs Ryu
#music              data/music/joe2.ogg
music              data/music/cody.ogg 4525321.5 
#music             data/music/cody1.ogg 3074828.4 

setmusicvolume 100 0
 
Thanks O! I got it tested and it works. But there's something strange/wrong about the right side of volume. I was increasing the volume for the right higher than the left and it's not louder as it seems. Left volume works good though. I think left is the main factor for adjusting volumes to work, and it must be because it's stereo? I dunno. It cannot be adjusted like mono style?

Also, another strange thing is that when exiting/quitting the game (whether you close OpenBOR.exe or quit game) the volume returns to normal default (non-scripted volume). For example, when you set your setmusicvolume lower in in-game and you quit game, the volume will return from lower setmusicvolume adjustment to normal (while closing).

Anways... this is for volume:
Code:
@script
    if(frame==1){
      playmusic("data/music/ken.ogg", 1);
      setmusicvolume(35,100);
    }
    if(frame==2){
      void self = getlocalvar("self");
      int r = rand()%30;

      if( r > 10 ){
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW1"));
      } else if( r < -10 ){
        changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW2"));
      } else if( r > -10 ){
	changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW3"));
      }
    }
	@end_script

EDIT: Now I'm wondering if it could be possible to use for entering from outside of the dance club to inside there where volume is very loud when people dance in the club. :D I'd like to use that for it, plus I'm curious for trying out the tempo script which kbandressen made but I dunno what type of script he used. (Too bad I didn't bother knowing it.)
 
I was increasing the volume for the right higher than the left and it's not louder as it seems. Left volume works good though. I think left is the main factor for adjusting volumes to work, and it must be because it's stereo? I dunno. It cannot be adjusted like mono style?

Yes, left is always the reference when working with audio. For example, when you have only one plug connected into a system, it should be the left one.

About the volume at OpenBOR, I dunno if it works like in Mugen, where the engine changes the stereo ballance based on the entity position.

Also, another strange thing is that when exiting/quitting the game (whether you close OpenBOR.exe or quit game) the volume returns to normal default (non-scripted volume). For example, when you set your setmusicvolume lower in in-game and you quit game, the volume will return from lower setmusicvolume adjustment to normal (while closing).

I think its the way it should work. I am taking a wild guess here, but the volume at options has a higher priority over volume by script and once you stop the script, the engine will revert the value to the default.

Now I'm wondering if it could be possible to use for entering from outside of the dance club to inside there where volume is very loud when people dance in the club.

If you can change the volume by script, you can do this :) Just spawn an empty entity which controls (raises) the volume when you are inside the club.
 
O Ilusionista said:
About the volume at OpenBOR, I dunno if it works like in Mugen, where the engine changes the stereo ballance based on the entity position.

No, it doesn't, but you can do this with script. Pay close attention to the sound in my demo videos for Golden Axe or Fatal Fury. You will notice the sound effects move left/right depending on their screen position.

DC
 
Back
Top Bottom