Change pan\pitch\volume of currently playing audio?

KotoYama

Veteran
Veteran
Joined
Apr 20, 2019
Messages
146
Reaction score
12
First Language
Spanish
Primarily Uses
RMMV
I'm making my own dynamic audio based on the character's direction(for a 3D game). Is there any way to change the pan\pitch of currently playing audio via ScriptCalls?
 

Featherbrain

Veteran
Veteran
Joined
Jan 12, 2020
Messages
59
Reaction score
55
First Language
English
Primarily Uses
RMMV
You can use the "Play BGM" command, select the currently playing music, and adjust the pan/pitch/volume accordingly. It will seamlessly adjust the changed settings without resetting or interrupting the song. For the script call version of that, you can use AudioManager.playBgm( name: filename, volume: n, pitch: n, pan: n );

I assume the other audio types (ME, SE, or BGS) work similarly. Not sure though.
 

KotoYama

Veteran
Veteran
Joined
Apr 20, 2019
Messages
146
Reaction score
12
First Language
Spanish
Primarily Uses
RMMV
@Featherbrain

The default PLAY command isn't flexible enough for me, since I want to change pan\pitch\volume independently. I've tried Script Calls already and they simply didn't work for me.
1603442314241.png

Am I missing something here?
 

Featherbrain

Veteran
Veteran
Joined
Jan 12, 2020
Messages
59
Reaction score
55
First Language
English
Primarily Uses
RMMV
Hmm... I'm not 100% sure and I'm not at my machine to double check, but I believe the syntax on your script call is wrong. I'm pretty sure "Sound Object" is not actually part of the command but rather an example of the parameters the "AudioManager.playBgs" function takes. Try this instead:

* Script : AudioManager.playBgs( a__drone-loop__fission9__1, 100, 100, 0);
* Wait: 180
* Script : AudioManager.playBgs( a__drone-loop__fission9__1, 50, 100, 0);

The sound should play uninterrupted at full volume for 3 seconds and then drop to half volume.

Note this script call is simply trying to achieve the same effect as the following ordinary event commands:

* Reproducir BGS : a__drone-loop__fission9__1 (100, 100, 0);
* Wait: 180
* Reproducir BGS : a__drone-loop__fission9__1 (50, 100, 0);

So I would probably try it the event command way first; I offered script calls only because you asked for them specifically. I'm not sure what you mean when you say the Play commands aren't enough because you want to change the values independently. As long as you change only one of the parameters, as in this example, then you are effectively changing that parameter independently; it should continue the same audio and simply adjust that one parameter. Give it a try. I know it works that way (at least for BGM) because I've used the same trick in my game to make BGM slightly quieter during dialogue.
 

KotoYama

Veteran
Veteran
Joined
Apr 20, 2019
Messages
146
Reaction score
12
First Language
Spanish
Primarily Uses
RMMV
@Featherbrain None of these worked for me, unfortunately. I've copy-pasted your example, also tried some bgm's.

I'll explain what I mean. As I've mentioned before I'm making a "dynamic audio" system where volume would depend on your closeness to an event and pan check your direction and whether it's(the event) on your right, left, etc. So, pan and volume won't have anything to do with each other, BUT both the event command and, apparently, script call set all the values at once.
I could make something like this using basic tools, but it would be a huge waste of my time if I can adjust them independently
 

KotoYama

Veteran
Veteran
Joined
Apr 20, 2019
Messages
146
Reaction score
12
First Language
Spanish
Primarily Uses
RMMV
I believe the answer might be here (1, 2) but I can't figure out the exact scripts I need.
 

Featherbrain

Veteran
Veteran
Joined
Jan 12, 2020
Messages
59
Reaction score
55
First Language
English
Primarily Uses
RMMV
Have you looked for a plugin that does what you want to do? I'm fairly certain I've seen plugins devoted to "spatial" or "positional" audio that might save you a lot of trouble trying to build a system like this yourself with events or script calls.

Beyond that, I'm baffled that the Play command isn't working for this. When you say it doesn't work to use the Play command, what exactly does happen? For instance, when you do the example of two Play commands separated by a wait, the first Play command at 100 percent volume and the second at 50 percent, what happens?

I understand what you're trying to do, but I don't really understand why you think you need a specific command that only adjusts one parameter of the audio at a time, because the Play command effectively already works like that--you have to "set all the values at once," but if you only change one of the parameters since the last time the command was called, then only that parameter will change. If I use the exact same Play command but the second time I set it to 50% volume, the only effect of the second Play command is to reduce the volume to 50%.

If you're saying the Play command simply doesn't function this way, you may have a plugin incompatibility or something, and again I'm curious what actually DOES happen for you?

I'm assuming the way you intend to implement this would be with a parallel process, that checks the player's distance and position in relation to the event, then updates the sound accordingly:

If Player distance < 10, then Play command with 50% volume
If Player distance < 5, then Exact Same Play command except with 100% volume
If Player is to the Left side of event, then Exact Same Play command except with left pan
Etc, etc.

Or are you trying to approach this some other way?
 

KotoYama

Veteran
Veteran
Joined
Apr 20, 2019
Messages
146
Reaction score
12
First Language
Spanish
Primarily Uses
RMMV
@Featherbrain "dynamic audio based on the character's direction(for a 3D game) "
None of these plugins consider the player's direction and cameras yaw(rotation) cause none of them was made for a 3D first-person game.
When you say it doesn't work to use the Play command, what exactly does happen?
Nothing happens. I don't get any sounds at all, but since they are not any different from basic Event commands, it doesn't really matter anymore.
I understand what you're trying to do, but I don't really understand why you think you need a specific command that only adjusts one parameter of the audio at a time
Pan and volume should change independently cause I don't want to program every possible combination (10 for volume and let's say 5 for pan = 50 variations)
 

Featherbrain

Veteran
Veteran
Joined
Jan 12, 2020
Messages
59
Reaction score
55
First Language
English
Primarily Uses
RMMV
If nothing happens when you use the Play command, you're definitely having a more fundamental issue with your audio. You probably want to get that figured out before worrying about more complicated audio functionality. As far as the 3D aspect, very few plugins will consider that, as RPG Maker has no innate 3D functionality whatsoever. You would have to graft those aspects together somehow from multiple plugins or code it yourself. All of that's definitely beyond me to figure out though. Sorry I wasn't able to help you. Good luck!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Posts

Latest Profile Posts

currently listening to Driftwood Gaming streaming some RPG Maker dev time and it's delightful! had no idea they were this entertaining, love it
In quarantine, will be tested soon. This year is really something... special.
I was at another orientation yesterday and I realized I'll be working with an old friend! We met at the local water park a few years back and it was so nice to see her again! We had a chat, and next week when I officially start, I'll see if maybe we can trade our Zoom IDs so we can talk!
I made some sideview closets for MV!
You can find them in my MV resource thread.

Forum statistics

Threads
105,509
Messages
1,014,317
Members
137,193
Latest member
OfTheManyColours
Top