Move colorchord2 into its own folder, since colorchord embedded is its own thing.

This commit is contained in:
cnlohr 2015-07-27 03:39:16 -04:00
parent 24b606988f
commit ed15ea49b9
56 changed files with 1 additions and 12 deletions

58
colorchord2/util.c Normal file
View file

@ -0,0 +1,58 @@
#include "util.h"
#include <math.h>
#include <stdlib.h>
//Take the absolute distance between two points on a torus.
float fabsloop( float a, float b, float modl )
{
float fa = fabsf( a - b );
fa = fmodf( fa, modl );
if( fa > modl/2.0 )
{
fa = modl - fa;
}
return fa;
}
//Get the weighted - average of two points on a torus.
float avgloop( float pta, float ampa, float ptb, float ampb, float modl )
{
float amptot = ampa + ampb;
//Determine if it should go linearly, or around the edge.
if( fabsf( pta - ptb ) > modl/2.0 )
{
//Loop around the outside.
if( pta < ptb )
{
pta += modl;
}
else
{
ptb += modl;
}
}
float modmid = (pta * ampa + ptb * ampb)/amptot;
return fmodf( modmid, modl );
}
int atoi_del( char * data )
{
int ret = atoi( data );
free( data );
return ret;
}
float atof_del( char * data )
{
float ret = atof( data );
free( data );
return ret;
}