update aspects for having a overall equalizer/compressor

This commit is contained in:
Charles Lohr 2016-05-28 14:54:15 -04:00
parent cb048b7866
commit 9f032be96d
7 changed files with 70 additions and 15 deletions

View file

@ -3,7 +3,7 @@ all : colorchord
RAWDRAW:=DrawFunctions.o XDriver.o RAWDRAW:=DrawFunctions.o XDriver.o
SOUND:=sound.o sound_alsa.o sound_pulse.o sound_null.o SOUND:=sound.o sound_alsa.o sound_pulse.o sound_null.o
OUTS := OutputVoronoi.o DisplayArray.o OutputLinear.o DisplayPie.o DisplayNetwork.o DisplayUSB2812.o DisplayDMX.o OutputProminent.o RecorderPlugin.o OUTS := OutputVoronoi.o DisplayArray.o OutputLinear.o DisplayPie.o DisplayNetwork.o DisplayUSB2812.o DisplayDMX.o OutputProminent.o RecorderPlugin.o OutputCells.o
WINGCC:=i586-mingw32msvc-gcc WINGCC:=i586-mingw32msvc-gcc
WINGCCFLAGS:= -O2 -Wl,--relax -Wl,--gc-sections -ffunction-sections -fdata-sections -s -DICACHE_FLASH_ATTR= -I../embeddedcommon -I. WINGCCFLAGS:= -O2 -Wl,--relax -Wl,--gc-sections -ffunction-sections -fdata-sections -s -DICACHE_FLASH_ATTR= -I../embeddedcommon -I.
@ -13,13 +13,13 @@ RAWDRAWLIBS:=-lX11 -lm -lpthread -lXinerama -lXext
LDLIBS:=-lpthread -lasound -lm -lpulse-simple -lpulse LDLIBS:=-lpthread -lasound -lm -lpulse-simple -lpulse
CFLAGS:=-g -Os -flto -Wall -ffast-math -I../embeddedcommon -I. -DICACHE_FLASH_ATTR= CFLAGS:=-g -O0 -flto -Wall -ffast-math -I../embeddedcommon -I. -DICACHE_FLASH_ATTR=
EXTRALIBS:=-lusb-1.0 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) parameters.o chash.o hook.o ../embeddedcommon/DFT32.o 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) parameters.o chash.o hook.o ../embeddedcommon/DFT32.o
gcc -o $@ $^ $(CFLAGS) $(LDLIBS) $(EXTRALIBS) $(RAWDRAWLIBS) gcc -o $@ $^ $(CFLAGS) $(LDLIBS) $(EXTRALIBS) $(RAWDRAWLIBS)
colorchord.exe : os_generic.c main.c dft.c decompose.c filter.c color.c sort.c notefinder.c util.c outdrivers.c DrawFunctions.c parameters.c chash.c WinDriver.c sound.c sound_null.c sound_win.c OutputVoronoi.c DisplayArray.c OutputLinear.c DisplayPie.c DisplayNetwork.c hook.c RecorderPlugin.c ../embeddedcommon/DFT32.c colorchord.exe : os_generic.c main.c dft.c decompose.c filter.c color.c sort.c notefinder.c util.c outdrivers.c DrawFunctions.c parameters.c chash.c WinDriver.c sound.c sound_null.c sound_win.c OutputVoronoi.c DisplayArray.c OutputLinear.c DisplayPie.c DisplayNetwork.c hook.c RecorderPlugin.c ../embeddedcommon/DFT32.c OutputCells.c
$(WINGCC) $(WINGCCFLAGS) -o $@ $^ $(WINLDFLAGS) $(WINGCC) $(WINGCCFLAGS) -o $@ $^ $(WINLDFLAGS)

View file

@ -24,9 +24,13 @@ wininput = 0
#sound_source = PULSE #sound_source = PULSE
#-1 indicates left and right, 0 left, 1 right. #-1 indicates left and right, 0 left, 1 right.
sample_channel = 1 sample_channel = -1
sourcename = default sourcename = default
alsa_output.pci-0000_00_1b.0.analog-stereo.monitor #alsa_output.pci-0000_00_1f.3.analog-stereo.monitor
#default
# alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
#alsa_output.pci-0000_00_1f.3.analog-stereo.monitor << New laptop
#use pactl list | grep pci-
################################## ##################################
# General ColorChord properties. # # General ColorChord properties. #
@ -55,7 +59,8 @@ octaves = 5
# 2 = DFT Progressive Integer # 2 = DFT Progressive Integer
# 3 = DFT Progressive Integer Skippy # 3 = DFT Progressive Integer Skippy
# 4 = Integer, 32-Bit, Progressive, Skippy. # 4 = Integer, 32-Bit, Progressive, Skippy.
do_progressive_dft = 4 do_progressive_dft = 4fa
filter_iter = 2 filter_iter = 2
filter_strength = .5 filter_strength = .5
@ -64,8 +69,8 @@ filter_strength = .5
freqbins = 24 freqbins = 24
# For the final note information... How much to slack everything? # For the final note information... How much to slack everything?
note_attach_amp_iir = 0.2000 note_attach_amp_iir = 0.3500
note_attach_amp_iir2 = 0.150 note_attach_amp_iir2 = 0.250
note_attach_freq_iir = 0.3000 note_attach_freq_iir = 0.3000
#How many bins a note can jump from frame to frame to be considered a slide. #How many bins a note can jump from frame to frame to be considered a slide.
@ -75,6 +80,9 @@ note_jumpability = 1.8000
note_minimum_new_distribution_value = 0.0200 note_minimum_new_distribution_value = 0.0200
note_out_chop = 0.05000 note_out_chop = 0.05000
#compress_coefficient = 4.0
#compress_exponent = .5
#======================================================================= #=======================================================================
#Outputs #Outputs

View file

@ -2,7 +2,7 @@
outdrivers = DisplayPie,DisplayNetwork,OutputLinear outdrivers = DisplayPie,DisplayNetwork,OutputLinear
leds = 48 leds = 48
light_siding = 1.0 #Turn this to ~1.9 for more uniformity, ~1.0 for less. light_siding = 1.9 #Turn this to ~1.9 for more uniformity, ~1.0 for less.
satamp = 1.600 satamp = 1.600
is_loop=1 is_loop=1
led_floor = .1 #Turn to .25 for more uniformity, .1 for less. led_floor = .1 #Turn to .25 for more uniformity, .1 for less.

View file

@ -30,6 +30,9 @@ void WindowsTerm()
#endif #endif
float DeltaFrameTime = 0;
double Now = 0;
int lastfps; int lastfps;
short screenx, screeny; short screenx, screeny;
int gargc; int gargc;
@ -183,7 +186,7 @@ const char * InitialFile[NRDEFFILES];
double FileTimes[NRDEFFILES]; double FileTimes[NRDEFFILES];
int InitialFileCount = 1; int InitialFileCount = 1;
void SetEnvValues() void SetEnvValues( int force )
{ {
int i; int i;
int hits = 0; int hits = 0;
@ -197,7 +200,7 @@ void SetEnvValues()
} }
} }
if( !hits ) return; if( !hits && !force ) return;
//Otherwise, something changed. //Otherwise, something changed.
@ -233,13 +236,19 @@ void ProcessArgs()
} }
} }
SetEnvValues(); SetEnvValues( 1 );
} }
int main(int argc, char ** argv) int main(int argc, char ** argv)
{ {
int i; int i;
printf( "Output Drivers:\n" );
for( i = 0; i < MAX_OUT_DRIVERS; i++ )
{
if( ODList[i].Name ) printf( "\t%s\n", ODList[i].Name );
}
#ifdef WIN32 #ifdef WIN32
WSADATA wsaData; WSADATA wsaData;
@ -324,11 +333,19 @@ int main(int argc, char ** argv)
nf = CreateNoteFinder( sd->spsRec ); nf = CreateNoteFinder( sd->spsRec );
//Once everything was reinitialized, re-read the ini files.
SetEnvValues( 1 );
Now = OGGetAbsoluteTime();
double Last = Now;
while(1) while(1)
{ {
char stt[1024]; char stt[1024];
//Handle Rawdraw frame swappign //Handle Rawdraw frame swappign
Now = OGGetAbsoluteTime();
DeltaFrameTime = Now - Last;
if( !headless ) if( !headless )
{ {
CNFGHandleInput(); CNFGHandleInput();
@ -369,12 +386,16 @@ int main(int argc, char ** argv)
//Do a bunch of debugging. //Do a bunch of debugging.
if( show_debug_basic ) if( show_debug_basic )
{ {
//char sttdebug[1024];
//char * sttend = sttdebug;
for( i = 0; i < nf->dists; i++ ) for( i = 0; i < nf->dists; i++ )
{ {
CNFGPenX = (nf->dist_means[i] + 0.5) / freqbins * screenx; //Move over 0.5 for visual purposes. The means is correct. CNFGPenX = (nf->dist_means[i] + 0.5) / freqbins * screenx; //Move over 0.5 for visual purposes. The means is correct.
CNFGPenY = 400-nf->dist_amps[i] * 150.0 / nf->dist_sigmas[i]; CNFGPenY = 400-nf->dist_amps[i] * 150.0 / nf->dist_sigmas[i];
//printf( "%f %f\n", dist_means[i], dist_amps[i] ); //printf( "%f %f\n", dist_means[i], dist_amps[i] );
sprintf( stt, "%f\n%f\n", nf->dist_means[i], nf->dist_amps[i] ); sprintf( stt, "%f\n%f\n", nf->dist_means[i], nf->dist_amps[i] );
// sttend += sprintf( sttend, "%f/%f ",nf->dist_means[i], nf->dist_amps[i] );
CNFGDrawText( stt, 2 ); CNFGDrawText( stt, 2 );
} }
CNFGColor( 0xffffff ); CNFGColor( 0xffffff );
@ -399,6 +420,7 @@ int main(int argc, char ** argv)
CNFGPenX = ((float)(i+.4) / note_peaks) * screenx; CNFGPenX = ((float)(i+.4) / note_peaks) * screenx;
CNFGPenY = screeny - 30; CNFGPenY = screeny - 30;
sprintf( stt, "%d\n%0.0f", nf->enduring_note_id[i], nf->note_amplitudes2[i]*1000.0 ); sprintf( stt, "%d\n%0.0f", nf->enduring_note_id[i], nf->note_amplitudes2[i]*1000.0 );
//sttend += sprintf( sttend, "%5d/%5.0f ", nf->enduring_note_id[i], nf->note_amplitudes2[i]*1000.0 );
CNFGDrawText( stt, 2 ); CNFGDrawText( stt, 2 );
} }
@ -415,6 +437,7 @@ int main(int argc, char ** argv)
lasty = thisy; lasty = thisy;
thisy = sound[thissoundhead] * 128 + 128; thissoundhead = (thissoundhead-1+SOUNDCBSIZE)%SOUNDCBSIZE; thisy = sound[thissoundhead] * 128 + 128; thissoundhead = (thissoundhead-1+SOUNDCBSIZE)%SOUNDCBSIZE;
} }
//puts( sttdebug );
} }
//Extra debugging? //Extra debugging?
@ -498,8 +521,8 @@ int main(int argc, char ** argv)
OGUSleep( (int)( SecToWait * 1000000 ) ); OGUSleep( (int)( SecToWait * 1000000 ) );
} }
SetEnvValues(); SetEnvValues( 0 );
Last = Now;
} }
} }

View file

@ -43,6 +43,9 @@ struct NoteFinder * CreateNoteFinder( int spsRec )
ret->current_note_id = 1; ret->current_note_id = 1;
ret->amplify = 1; ret->amplify = 1;
ret->compress_coefficient = 1.0;
ret->compress_exponenet = .5;
ret->ofreqs = 0; //force a re-init. ret->ofreqs = 0; //force a re-init.
RegisterValue( "octaves", PAINT, &ret->octaves, sizeof( ret->octaves ) ); RegisterValue( "octaves", PAINT, &ret->octaves, sizeof( ret->octaves ) );
@ -52,6 +55,8 @@ struct NoteFinder * CreateNoteFinder( int spsRec )
RegisterValue( "filter_iter", PAINT, &ret->filter_iter, sizeof( ret->filter_iter ) ); RegisterValue( "filter_iter", PAINT, &ret->filter_iter, sizeof( ret->filter_iter ) );
RegisterValue( "decompose_iterations", PAINT, &ret->decompose_iterations, sizeof( ret->decompose_iterations ) ); RegisterValue( "decompose_iterations", PAINT, &ret->decompose_iterations, sizeof( ret->decompose_iterations ) );
RegisterValue( "amplify", PAFLOAT, &ret->amplify, sizeof( ret->amplify ) ); RegisterValue( "amplify", PAFLOAT, &ret->amplify, sizeof( ret->amplify ) );
RegisterValue( "compress_exponent", PAFLOAT, &ret->compress_exponenet, sizeof( ret->compress_exponenet ) );
RegisterValue( "compress_coefficient", PAFLOAT, &ret->compress_coefficient, sizeof( ret->compress_coefficient ) );
RegisterValue( "dft_speedup", PAFLOAT, &ret->dft_speedup, sizeof( ret->dft_speedup ) ); RegisterValue( "dft_speedup", PAFLOAT, &ret->dft_speedup, sizeof( ret->dft_speedup ) );
RegisterValue( "dft_q", PAFLOAT, &ret->dft_q, sizeof( ret->dft_q ) ); RegisterValue( "dft_q", PAFLOAT, &ret->dft_q, sizeof( ret->dft_q ) );
RegisterValue( "default_sigma", PAFLOAT, &ret->default_sigma, sizeof( ret->default_sigma ) ); RegisterValue( "default_sigma", PAFLOAT, &ret->default_sigma, sizeof( ret->default_sigma ) );
@ -239,6 +244,21 @@ void RunNoteFinder( struct NoteFinder * nf, const float * audio_stream, int head
memset( nf->dist_takens, 0, sizeof( unsigned char ) * maxdists ); memset( nf->dist_takens, 0, sizeof( unsigned char ) * maxdists );
nf->dists = DecomposeHistogram( nf->folded_bins, freqbins, nf->dist_means, nf->dist_amps, nf->dist_sigmas, maxdists, nf->default_sigma, nf->decompose_iterations ); nf->dists = DecomposeHistogram( nf->folded_bins, freqbins, nf->dist_means, nf->dist_amps, nf->dist_sigmas, maxdists, nf->default_sigma, nf->decompose_iterations );
//Compress/normalize dist_amps
float total_dist = 0;
for( i = 0; i < nf->dists; i++ )
{
total_dist += nf->dist_amps[i];
}
float muxer = nf->compress_coefficient/powf( total_dist * nf->compress_coefficient, nf->compress_exponenet );
total_dist = muxer;
for( i = 0; i < nf->dists; i++ )
{
nf->dist_amps[i]*=total_dist;
}
{ {
int dist_sorts[nf->dists]; int dist_sorts[nf->dists];
SortFloats( dist_sorts, nf->dist_amps, nf->dists ); SortFloats( dist_sorts, nf->dist_amps, nf->dists );

View file

@ -19,6 +19,10 @@ struct NoteFinder
int filter_iter;// = 1; int filter_iter;// = 1;
int decompose_iterations;// = 1000; int decompose_iterations;// = 1000;
float amplify; // =1 (amplify input across the board) float amplify; // =1 (amplify input across the board)
float compress_coefficient; // = 1.0; How much to compress the sound by before putting it into the compressor.
float compress_exponenet; // = .5; Exponent of the compressor lower = make more uniform.
int do_progressive_dft; //= 1 int do_progressive_dft; //= 1
//at 300, there is still some minimal aliasing at higher frequencies. Increase this for less low-end distortion //at 300, there is still some minimal aliasing at higher frequencies. Increase this for less low-end distortion

View file

@ -3,7 +3,7 @@
#ifndef _PARAMETERS_H #ifndef _PARAMETERS_H
#define _PARAMETERS_H #define _PARAMETERS_H
#define PARAM_BUFF 128 #define PARAM_BUFF 160
enum ParamType enum ParamType
{ {