MADRIX Forum • Editing Scripts
Page 1 of 1

Editing Scripts

Posted: Thu Dec 05, 2013 11:42 pm
by trj222
I've seen a few posts of people asking to share scripts etc but I didn't see where anyone actually shared theirs. I read through the help file and let me start by stating I am not a programmer but thought I would give it a try. I'm starting off by simply trying to edit one of the examples and making it apply to a different effect. I am getting errors though. Can someone show me what I am doing wrong? I'm trying to figure out how to change height and width to the music. One of the examples was for Wave/Radial. I tried making it work for a SCE Graph effect. Not sure if its actually possible. But if it is not, then I want to try and adjust to where my midi controller changes the height or width when I press a key and when I release it goes back to original value. I'm determined to figure this out but I need a starting point. Here is the code with errors:
@scriptname="";
@author="";
@version="";
@description="";


void InitEffect()
{

}

void PreRenderEffect()
{
float s = GetSoundLevel(0);
float s1 = s * 500;
float s2 = s * 300;

if (s>=0.10)
{
SetHeight(s1);
SetWidth(s2);
}
else
{
SetHeight(100);
SetWidth(500);
}
}

void PostRenderEffect()
{

}

void MatrixSizeChanged()
{
InitEffect();
}

Re: Editing Scripts

Posted: Fri Dec 06, 2013 8:37 am
by Wissmann
try this

Code: Select all

void PreRenderEffect()
{
float s = GetSoundLevel(0);
float s1 = s * 50.0;
float s2 = s * 30.0;

if (s>=0.10)
{
SetHeight(s1);
SetWidth(s2,0);
}
else
{
SetHeight(10.0);
SetWidth(50.0,0);
}
}
you forgot the second parameter at SetWidth(s2,0) which could be used for each register.

Re: Editing Scripts

Posted: Fri Dec 06, 2013 11:16 pm
by trj222
Thank you. I made the changes and it says:
Macro has no Function 'PostRenderEffect'

Re: Editing Scripts

Posted: Mon Dec 09, 2013 10:59 am
by Fritzsche
Hi,

Please make sure to replace the old code with the snippet provided by Wissmann. You need to use the complete script, such as

@scriptname="";
@author="";
@version="";
@description="";


void InitEffect()
{

}

void PreRenderEffect()
{
float s = GetSoundLevel(0);
float s1 = s * 50.0;
float s2 = s * 30.0;

if (s>=0.10)
{
SetHeight(s1);
SetWidth(s2,0);
}
else
{
SetHeight(10.0);
SetWidth(50.0,0);
}
}

void PostRenderEffect()
{

}

void MatrixSizeChanged()
{
InitEffect();
}

Re: Editing Scripts

Posted: Tue Dec 10, 2013 11:10 pm
by trj222
I must have mistyped something. Thank you so much for the help. I have been able to create a couple more scripts now and wouldnt have been able to do it without help on this one. Much appreciated.

Re: Editing Scripts

Posted: Wed Dec 11, 2013 10:12 am
by Wissmann
You are welcome !

Re: Editing Scripts

Posted: Wed Dec 11, 2013 9:39 pm
by trj222
Last question: I have a script lowering the submaster and raising it to the music. It works, but i do have some errors. Also, is there anyway to get it to lower and raise not so sporadically? In other words, does anyone know a way to make it lower and raise at a slower rate like you are using a fader knob instead of flashing to level 220 and back to level 30? Here is what i have so far... Like i said it works but it flashes back and forth and it does have errors. Any help is greatly appreciated:

@scriptname="";
@author="";
@version="";
@description="";


void InitEffect()
{

}

void PreRenderEffect()
{
float s = GetSoundLevel(0);
float s1 = 220.0;

if (s>=0.10)
{
SetSubMaster(s1);
}
else
{
SetSubMaster(30.0);
}
}

void PostRenderEffect()
{

}

void MatrixSizeChanged()
{
InitEffect();
}

Re: Editing Scripts

Posted: Wed Dec 11, 2013 10:59 pm
by Wissmann
OK, check this out

Code: Select all

@scriptname="";
@author="";
@version="";
@description="";

int MAX = 220;
int MIN = 30;
int VALUE_UP = 30;
int VALUE_DOWN = 30;

int iSMValue = MAX;

void InitEffect()
{

}

void PreRenderEffect()
{
if (GetSoundLevel(0) >= 0.1)
	iSMValue = min(MAX,iSMValue + VALUE_UP);
else
	iSMValue = max(MIN,iSMValue - VALUE_DOWN);

SetSubMaster(iSMValue);
}

void PostRenderEffect()
{

}

void MatrixSizeChanged()
{
InitEffect();
}

Re: Editing Scripts

Posted: Thu Dec 12, 2013 12:06 am
by trj222
Wissmann, you are a badass. Thank you so much. I think it would have taken me a week to figure that one out.

Re: Editing Scripts

Posted: Thu Dec 12, 2013 5:35 pm
by Wissmann
;-)