change the parameters on the command line and make the shape driver accept things given to it dynamically
This commit is contained in:
parent
79a422c2cf
commit
614c26da92
|
@ -145,13 +145,16 @@ static void DPOUpdate(void * id, struct NoteFinder*nf)
|
|||
static void DPOParams(void * id )
|
||||
{
|
||||
struct DPODriver * d = (struct DPODriver*)id;
|
||||
d->xn = GetParameterI( "lightx", 160 );
|
||||
d->yn = GetParameterI( "lighty", 90 );
|
||||
d->cutoff = GetParameterF( "cutoff", .01 );
|
||||
d->satamp = GetParameterF( "satamp", 5 );
|
||||
d->amppow = GetParameterF( "amppow", 2.51 );
|
||||
d->distpow = GetParameterF( "distpow", 1.5 );
|
||||
d->from_sides = GetParameterI( "fromsides", 1 ); //If 0, will make sources random locations.
|
||||
d->xn = 160; RegisterValue( "lightx", PINT, &d->xn, sizeof( d->xn ) ); printf( "XN: %d\n", d->xn );
|
||||
d->yn = 90; RegisterValue( "lighty", PINT, &d->yn, sizeof( d->yn ) );
|
||||
d->cutoff = .01; RegisterValue( "cutoff", PFLOAT, &d->cutoff, sizeof( d->cutoff ) );
|
||||
d->satamp = 5; RegisterValue( "satamp", PFLOAT, &d->satamp, sizeof( d->satamp ) );
|
||||
|
||||
d->amppow = 2.51; RegisterValue( "amppow", PFLOAT, &d->amppow, sizeof( d->amppow ) );
|
||||
d->distpow = 1.5; RegisterValue( "distpow", PFLOAT, &d->distpow, sizeof( d->distpow ) );
|
||||
|
||||
d->from_sides = 1.5;RegisterValue( "fromsides", PINT, &d->from_sides, sizeof( d->from_sides ) );
|
||||
|
||||
d->note_peaks = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ displayname = DisplayShapeDriver
|
|||
|
||||
#Display Shape Driver parameters
|
||||
fromsides = 1
|
||||
lightx = 160
|
||||
lighty = 90
|
||||
lightx = 80
|
||||
lighty = 45
|
||||
cutoff = 0.010
|
||||
satamp = 5.000
|
||||
amppow = 2.510
|
||||
|
|
20
main.c
20
main.c
|
@ -15,6 +15,8 @@
|
|||
#include "parameters.h"
|
||||
|
||||
short screenx, screeny;
|
||||
int gargc;
|
||||
char ** gargv;
|
||||
|
||||
int set_screenx = 640; REGISTER_PARAM( set_screenx, PINT );
|
||||
int set_screeny = 480; REGISTER_PARAM( set_screeny, PINT );
|
||||
|
@ -86,6 +88,7 @@ void LoadFile( const char * filename )
|
|||
{
|
||||
char * buffer;
|
||||
int r;
|
||||
int i;
|
||||
|
||||
FILE * f = fopen( filename, "rb" );
|
||||
if( !f )
|
||||
|
@ -111,6 +114,16 @@ void LoadFile( const char * filename )
|
|||
}
|
||||
free( buffer );
|
||||
}
|
||||
|
||||
|
||||
if( gargc > 2 )
|
||||
{
|
||||
for( i = 2; i < gargc; i++ )
|
||||
{
|
||||
printf( "AP: %s\n", gargv[i] );
|
||||
SetParametersFromString( gargv[i] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
|
@ -120,6 +133,9 @@ int main(int argc, char ** argv)
|
|||
int i;
|
||||
double LastFileTime;
|
||||
|
||||
gargc = argc;
|
||||
gargv = argv;
|
||||
|
||||
if( argc > 1 )
|
||||
{
|
||||
InitialFile = argv[1];
|
||||
|
@ -130,10 +146,6 @@ int main(int argc, char ** argv)
|
|||
LoadFile( InitialFile );
|
||||
}
|
||||
|
||||
if( argc > 2 )
|
||||
{
|
||||
SetParametersFromString( argv[1] );
|
||||
}
|
||||
|
||||
//Initialize Rawdraw
|
||||
int frames = 0;
|
||||
|
|
|
@ -97,6 +97,9 @@ static int SetParameter( struct Param * p, const char * str )
|
|||
((char*)p->ptr)[p->size-1]= '\0';
|
||||
break;
|
||||
case PSTRING:
|
||||
free( p->ptr );
|
||||
p->ptr = strdup( str );
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
@ -197,16 +200,17 @@ void SetParametersFromString( const char * string )
|
|||
{
|
||||
name[lastnamenowhite] = 0;
|
||||
value[lastvaluenowhite] = 0;
|
||||
// printf( "Break: %s %s %d\n", name, value, lastvaluenowhite );
|
||||
|
||||
struct Param * p = (struct Param*)HashGetEntry( parameters, name );
|
||||
if( p )
|
||||
{
|
||||
printf( "Set: %s %s\n", name, value );
|
||||
SetParameter( p, value );
|
||||
}
|
||||
else
|
||||
{
|
||||
//p is an orphan.
|
||||
printf( "Orp: %s %s\n", name, value );
|
||||
struct Param ** n = (struct Param **)HashTableInsert( parameters, name, 0 );
|
||||
*n = malloc( sizeof ( struct Param ) );
|
||||
(*n)->orphan = 1;
|
||||
|
|
|
@ -33,8 +33,13 @@ struct Param
|
|||
struct ParamCallback * callback;
|
||||
};
|
||||
|
||||
|
||||
//This is the preferred method for getting settings, that way changes will be propogated
|
||||
void RegisterValue( const char * name, enum ParamType, void * ptr, int size );
|
||||
|
||||
void DumpParameters();
|
||||
|
||||
//Use these only if you really can't register your value.
|
||||
float GetParameterF( const char * name, float defa );
|
||||
int GetParameterI( const char * name, int defa );
|
||||
const char * GetParameterS( const char * name, const char * defa );
|
||||
|
|
Loading…
Reference in a new issue