Editing Scripts

Write here what nice effects or shows you have done with MADRIX or ask other users.

Moderator: MADRIX Team

Locked
trj222
Posts: 11
Joined: Wed Dec 04, 2013 11:58 pm

Editing Scripts

Post 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();
}
User avatar
Wissmann
Developer
Developer
Posts: 774
Joined: Fri Feb 23, 2007 3:36 pm
Location: Germany
Contact:

Re: Editing Scripts

Post 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.
LEDs are nothing without control ;-)
trj222
Posts: 11
Joined: Wed Dec 04, 2013 11:58 pm

Re: Editing Scripts

Post by trj222 »

Thank you. I made the changes and it says:
Macro has no Function 'PostRenderEffect'
Fritzsche
Support
Support
Posts: 735
Joined: Mon Oct 05, 2009 5:26 pm
Contact:

Re: Editing Scripts

Post 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();
}
trj222
Posts: 11
Joined: Wed Dec 04, 2013 11:58 pm

Re: Editing Scripts

Post 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.
User avatar
Wissmann
Developer
Developer
Posts: 774
Joined: Fri Feb 23, 2007 3:36 pm
Location: Germany
Contact:

Re: Editing Scripts

Post by Wissmann »

You are welcome !
LEDs are nothing without control ;-)
trj222
Posts: 11
Joined: Wed Dec 04, 2013 11:58 pm

Re: Editing Scripts

Post 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();
}
User avatar
Wissmann
Developer
Developer
Posts: 774
Joined: Fri Feb 23, 2007 3:36 pm
Location: Germany
Contact:

Re: Editing Scripts

Post 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();
}
LEDs are nothing without control ;-)
trj222
Posts: 11
Joined: Wed Dec 04, 2013 11:58 pm

Re: Editing Scripts

Post 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.
User avatar
Wissmann
Developer
Developer
Posts: 774
Joined: Fri Feb 23, 2007 3:36 pm
Location: Germany
Contact:

Re: Editing Scripts

Post by Wissmann »

;-)
LEDs are nothing without control ;-)
Locked