Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
D12

How can I make a low pass filter effect?

Recommended Posts

I wanna make a low pass filter effect on my Map, whenever I'm closer to an area the music gets louder and more closer.

And vice versa if I move away from it. Is there a script that can make this work? Thx for your time and reply. 

 

Edit: My Game Data is UDMF and my wad is ran with GzDoom. 

Edited by D12

Share this post


Link to post
33 minutes ago, Mordeth said:

Assuming you use GZDoom, you may want to look at this dynamic music project.

 

Yes I uze Gzdoom, Gzdoombuilder as well. Thx for your help. 

 

Edit: But does it work for low pass filter effects?

Share this post


Link to post

If you are using GZDoom and your map is in UDMF map format you can actually use an ACS script to obtain the effect that you desire

 

First of all you need to place a MapSpot (you can find it in the ZDoom folder of the thing panel) in the center of the area that will control your music volume.

Then assign a TID to that MapSpot. In this example we will assume that the TID is 1.

After that you have to open your script editor and write the following code:

Spoiler

#include "zcommon.acs"

 

Script 1 ENTER

{

        SetMusicVolume (0.0);

        while (TRUE)

        {

                Int xa = GetActorX (0);

                Int ya = GetActorY (0);

                Int xb = GetActorX (1);

                Int yb = GetActorY (1);

                Int x = xa*xa + xb*xb -2*xa*xb;

                Int y = ya*ya + yb*yb - 2*ya*yb;

                Int distance = sqrt (x + y);       

                If (distance <= 1000)

                    SetMusicVolume (1.1 - (distance/1000));

                delay (1);

        }

}

 

NOTES:

The first 7 rows inside the while at here only to calculate the distance between you and the MapSpot. I'm quite sure that there is a better way to calculate it, so if if you know it just replace them with it. 

 

The variables xb, yb refer to the MapSpot, that probably is a stationary point. I've used the proper command only to create the most general script possible. You can easily replace them with the actual coordinates of your MapSpot to make every other calculation easier.

So for example:

int xb = 10;

int yb = 24;

This script assumes that there is no music at the start of the level, and the music will start to become louder only if you get at least 1000 map units from the MapSpot. You can change this last number in the "if" and in the last SetMusicVolume.

 

The code in this spoiler has not been tested and I have the strong suspect that it will not work properly. But at least it is an idea.

 

 

 

Edited by Simomarchi

Share this post


Link to post
11 minutes ago, Simomarchi said:

If you are using GZDoom and your map is in UDMF map format you can actually use an ACS script to obtain the effect that you desire

 

First of all you need to place a MapSpot (you can find it in the ZDoom folder of the thing panel) in the center of the area that will control your music volume.

Then assign a TID to that MapSpot. In this example we will assume that the TID is 1.

After that you have to open your script editor and write the following code:

  Hide contents

#include "zcommon.acs"

 

Script 1 ENTER

{

        SetMusicVolume (0.0);

        while (TRUE)

        {

                Int xa = GetActorX (0);

                Int ya = GetActorY (0);

                Int xb = GetActorX (1);

                Int yb = GetActorY (1);

                Int x = xa*xa + xb*xb -2*xa*xb;

                Int y = ya*ya + yb*yb - 2*ya*yb;

                Int distance = sqrt (x + y);       

                If (distance <= 1000)

                    SetMusicVolume (1.1 - (distance/1000));

                delay (1);

        }

}

 

NOTES:

The first 7 rows inside the while at here only to calculate the distance between you and the MapSpot. I'm quite sure that there is a better way to calculate it, so if if you know it just replace them with it. 

 

The variables xb, yb refer to the MapSpot, that probably is a stationary point. I've used the proper command only to create the most general script possible. You can easily replace them with the actual coordinates of your MapSpot to make every other calculation easier.

So for example:

int xb = 10;

int yb = 24;

This script assumes that there is no music at the start of the level, and the music will start to become louder only if you get at least 1000 map units from the MapSpot. You can change this last number in the "if" and in the last SetMusicVolume.

 

The code in this spoiler has not been tested and I have the strong suspect that it will not work properly. But at least it is an idea.

 

 

I really appreciatte your time for this, thank you. I will try this out later! since I have no rush :)

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×