make a number of tweaks to the way parameters are loaded and dealt with.
This commit is contained in:
parent
13d0f17b11
commit
465ca076b4
2
Makefile
2
Makefile
|
@ -5,7 +5,7 @@ SOUND:=sound.o sound_alsa.o sound_pulse.o sound_null.o
|
|||
OUTS:=LEDOUTDriver.o DisplayOUTDriver.o DisplayShapeDriver.o parameters.o chash.o
|
||||
RAWDRAWLIBS:=-lX11 -lm -lpthread -lXinerama -lXext
|
||||
LDLIBS:=-lpthread -lasound -lm -lpulse-simple -lpulse
|
||||
CFLAGS:=-g -Os -flto -Wall
|
||||
CFLAGS:=-g -Os -flto -Wall -ffast-math
|
||||
EXTRALIBS:=-lusb-1.0
|
||||
|
||||
colorchord : os_generic.o main.o dft.o decompose.o filter.o color.o sort.o notefinder.o util.o outdrivers.o $(RAWDRAW) $(SOUND) $(OUTS)
|
||||
|
|
89
default.conf
89
default.conf
|
@ -1,19 +1,78 @@
|
|||
play=0
|
||||
record=1
|
||||
samplerate=44100
|
||||
buffer=128
|
||||
sound_source=PULSE
|
||||
sourcename=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
|
||||
#default
|
||||
# This is the configuration file for colorchord.
|
||||
# Most values are already defaulted in the software.
|
||||
# This file is constantly checked for new versions.
|
||||
# \r, and ; are used as terminators, so you can put
|
||||
# multiple entries on the same line.
|
||||
|
||||
#Whether to limit the control loop to ~60ish FPS.
|
||||
cpu_autolimit = 1
|
||||
|
||||
#What display output driver should be used?
|
||||
displayname = DisplayShapeDriver
|
||||
|
||||
|
||||
#Display Shape Driver parameters
|
||||
fromsides = 1
|
||||
lightx = 160
|
||||
lighty = 90
|
||||
cutoff = 0.010
|
||||
satamp = 5.000
|
||||
amppow = 2.510
|
||||
distpow = 1.500
|
||||
|
||||
#General GUI properties.
|
||||
title = PA Test
|
||||
set_screenx = 640
|
||||
set_screeny = 480
|
||||
|
||||
#Sound properties.
|
||||
buffer = 128
|
||||
play = 0
|
||||
rec = 1
|
||||
channels = 2
|
||||
samplerate = 44100
|
||||
sound_source = PULSE
|
||||
sourcename = alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
|
||||
|
||||
##################################
|
||||
# General ColorChord properties. #
|
||||
##################################
|
||||
|
||||
# How much to amplify the incoming signal.
|
||||
amplify = 2.0
|
||||
|
||||
# What is the base note? I.e. the lowest note.
|
||||
# Note that it won't have very much impact until an octave up though!
|
||||
base_hz = 55.0000
|
||||
|
||||
# This is only used when dealing with the slow decompose (now defunct)
|
||||
# decompose_iterations = 1000
|
||||
# default_sigma = 1.4000
|
||||
|
||||
# DFT properties for the DFT up top.
|
||||
dft_iir = 0.7000
|
||||
dft_q = 10.0000
|
||||
dft_speedup = 300.0000
|
||||
octaves = 5
|
||||
|
||||
filter_iter = 1
|
||||
filter_strength = 0.5000
|
||||
|
||||
# How many bins per octave to use?
|
||||
freqbins = 24
|
||||
|
||||
# For the final note information... How much to slack everything?
|
||||
note_attach_amp_iir = 0.3000
|
||||
note_attach_amp_iir2 = 0.2000
|
||||
note_attach_freq_iir = 0.4000
|
||||
|
||||
#How many bins a note can jump from frame to frame to be considered a slide.
|
||||
#this is used to prevent notes from popping in and out a lot.
|
||||
note_combine_distance = 0.5000
|
||||
note_jumpability = 2.5000
|
||||
note_minimum_new_distribution_value = 0.0200
|
||||
note_out_chop = 0.1000
|
||||
|
||||
|
||||
amplify=2
|
||||
dft_iir=0.7
|
||||
dft_q=10
|
||||
note_attach_amp_iir=.3
|
||||
note_attach_freq_iir=.4
|
||||
note_attach_amp_iir2=.2
|
||||
|
||||
displayname=DisplayShapeDriver
|
||||
fromsides=1
|
||||
|
||||
|
|
103
main.c
103
main.c
|
@ -19,8 +19,7 @@ short screenx, screeny;
|
|||
int set_screenx = 640; REGISTER_PARAM( set_screenx, PINT );
|
||||
int set_screeny = 480; REGISTER_PARAM( set_screeny, PINT );
|
||||
char sound_source[16]; REGISTER_PARAM( sound_source, PBUFFER );
|
||||
|
||||
#define SMARTCPU
|
||||
int cpu_autolimit = 1; REGISTER_PARAM( cpu_autolimit, PINT );
|
||||
|
||||
struct NoteFinder * nf;
|
||||
|
||||
|
@ -44,6 +43,7 @@ void HandleKey( int keycode, int bDown )
|
|||
if( c == '-' && bDown ) { gKey++; nf->base_hz = 55 * pow( 2, gKey / 12.0 ); ChangeNFParameters( nf ); }
|
||||
if( c == '0' && bDown ) { gKey = 0; nf->base_hz = 55 * pow( 2, gKey / 12.0 ); ChangeNFParameters( nf ); }
|
||||
if( c == 'E' && bDown ) show_debug_basic = !show_debug_basic;
|
||||
if( c == 'K' && bDown ) DumpParameters();
|
||||
if( keycode == 65307 ) exit( 0 );
|
||||
printf( "Key: %d -> %d\n", keycode, bDown );
|
||||
}
|
||||
|
@ -57,8 +57,6 @@ void HandleMotion( int x, int y, int mask )
|
|||
{
|
||||
}
|
||||
|
||||
//#define HARDWAVE
|
||||
|
||||
void SoundCB( float * out, float * in, int samplesr, int * samplesp, struct SoundDriver * sd )
|
||||
{
|
||||
int channelin = sd->channelsRec;
|
||||
|
@ -69,11 +67,6 @@ void SoundCB( float * out, float * in, int samplesr, int * samplesp, struct Soun
|
|||
|
||||
int process_channels = (MAX_CHANNELS < channelin)?MAX_CHANNELS:channelin;
|
||||
|
||||
#ifdef HARDWAVE
|
||||
static double sttf=0;
|
||||
if( sttf > 200 ) return;
|
||||
#endif
|
||||
|
||||
int i;
|
||||
int j;
|
||||
for( i = 0; i < samplesr; i++ )
|
||||
|
@ -82,55 +75,59 @@ void SoundCB( float * out, float * in, int samplesr, int * samplesp, struct Soun
|
|||
{
|
||||
float f = in[i*channelin+j];
|
||||
if( f < -1 || f > 1 ) continue;
|
||||
sound[j][soundhead] =
|
||||
#ifdef HARDWAVE
|
||||
sin(sttf+=0.01);
|
||||
#else
|
||||
in[i*channelin+j];
|
||||
#endif
|
||||
sound[j][soundhead] = in[i*channelin+j];
|
||||
}
|
||||
soundhead = (soundhead+1)%SOUNDCBSIZE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LoadFile( const char * filename )
|
||||
{
|
||||
char * buffer;
|
||||
int r;
|
||||
|
||||
FILE * f = fopen( filename, "rb" );
|
||||
if( !f )
|
||||
{
|
||||
fprintf( stderr, "Warning: cannot open %s.\n", filename );
|
||||
}
|
||||
else
|
||||
{
|
||||
fseek( f, 0, SEEK_END );
|
||||
int size = ftell( f );
|
||||
fseek( f, 0, SEEK_SET );
|
||||
buffer = malloc( size + 1 );
|
||||
r = fread( buffer, size, 1, f );
|
||||
fclose( f );
|
||||
buffer[size] = 0;
|
||||
if( r != 1 )
|
||||
{
|
||||
fprintf( stderr, "Warning: %d bytes read. Expected: %d from file %s\n", r, size, filename );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetParametersFromString( buffer );
|
||||
}
|
||||
free( buffer );
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
// const char * OutDriver = "name=LEDOutDriver;leds=512;light_siding=1.9";
|
||||
const char * InitialFile = "default.conf";
|
||||
int i;
|
||||
double LastFileTime;
|
||||
|
||||
if( argc > 1 )
|
||||
{
|
||||
InitialFile = "default.conf";
|
||||
InitialFile = argv[1];
|
||||
}
|
||||
|
||||
{
|
||||
char * buffer;
|
||||
int r;
|
||||
FILE * f = fopen( InitialFile, "rb" );
|
||||
if( !f )
|
||||
{
|
||||
fprintf( stderr, "Warning: cannot open %s.\n", InitialFile );
|
||||
}
|
||||
else
|
||||
{
|
||||
fseek( f, 0, SEEK_END );
|
||||
int size = ftell( f );
|
||||
fseek( f, 0, SEEK_SET );
|
||||
buffer = malloc( size + 1 );
|
||||
r = fread( buffer, size, 1, f );
|
||||
fclose( f );
|
||||
buffer[size] = 0;
|
||||
if( r != 1 )
|
||||
{
|
||||
fprintf( stderr, "Warning: %d bytes read. Expected: %d from file %s\n", r, size, InitialFile );
|
||||
}
|
||||
else
|
||||
{
|
||||
SetParametersFromString( buffer );
|
||||
}
|
||||
free( buffer );
|
||||
}
|
||||
LastFileTime = OGGetFileTime( InitialFile );
|
||||
LoadFile( InitialFile );
|
||||
}
|
||||
|
||||
if( argc > 2 )
|
||||
|
@ -297,12 +294,22 @@ int main(int argc, char ** argv)
|
|||
frames = 0;
|
||||
LastFPSTime+=1;
|
||||
}
|
||||
#ifdef SMARTCPU
|
||||
SecToWait = .016 - ( ThisTime - LastFrameTime );
|
||||
LastFrameTime += .016;
|
||||
if( SecToWait > 0 )
|
||||
OGUSleep( (int)( SecToWait * 1000000 ) );
|
||||
#endif
|
||||
|
||||
if( cpu_autolimit )
|
||||
{
|
||||
SecToWait = .016 - ( ThisTime - LastFrameTime );
|
||||
LastFrameTime += .016;
|
||||
if( SecToWait < -.1 ) LastFrameTime = ThisTime - .1;
|
||||
if( SecToWait > 0 )
|
||||
OGUSleep( (int)( SecToWait * 1000000 ) );
|
||||
}
|
||||
|
||||
if( OGGetFileTime( InitialFile ) != LastFileTime )
|
||||
{
|
||||
LastFileTime = OGGetFileTime( InitialFile );
|
||||
LoadFile( InitialFile );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
21
parameters.c
21
parameters.c
|
@ -33,6 +33,7 @@ float GetParameterF( const char * name, float defa )
|
|||
default: break;
|
||||
}
|
||||
}
|
||||
printf( "U: %s = %f\n", name, defa );
|
||||
|
||||
return defa;
|
||||
}
|
||||
|
@ -53,6 +54,8 @@ int GetParameterI( const char * name, int defa )
|
|||
}
|
||||
}
|
||||
|
||||
printf( "U: %s = %d\n", name, defa );
|
||||
|
||||
return defa;
|
||||
}
|
||||
|
||||
|
@ -72,6 +75,8 @@ const char * GetParameterS( const char * name, const char * defa )
|
|||
}
|
||||
}
|
||||
|
||||
printf( "U: %s = %s\n", name, defa );
|
||||
|
||||
return defa;
|
||||
}
|
||||
|
||||
|
@ -288,3 +293,19 @@ void AddCallback( const char * name, ParamCallbackT t, void * v )
|
|||
}
|
||||
|
||||
|
||||
void DumpParameters()
|
||||
{
|
||||
int i;
|
||||
struct chashlist * l = HashProduceSortedTable( parameters );
|
||||
|
||||
for( i = 0; i < l->length; i++ )
|
||||
{
|
||||
struct chashentry * e = &l->items[i];
|
||||
printf( "%s = %s\n", e->key, GetParameterS( e->key, "" ) );
|
||||
}
|
||||
printf( "\n" );
|
||||
|
||||
free( l );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ struct Param
|
|||
};
|
||||
|
||||
void RegisterValue( const char * name, enum ParamType, void * ptr, int size );
|
||||
|
||||
void DumpParameters();
|
||||
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