diff --git a/colorchord2/DisplaySHM.c b/colorchord2/DisplaySHM.c index 554759d..55f2c3e 100644 --- a/colorchord2/DisplaySHM.c +++ b/colorchord2/DisplaySHM.c @@ -14,13 +14,16 @@ #include /* For O_* constants */ #include +extern struct NoteFinder * nf; + + struct SHMDriver { int lights_file; - //int dft_file; //Not available. - //uint8_t * dft_ptr; + int dft_file; //Not available. + uint8_t * dft_ptr; uint8_t * lights_ptr; - //int total_dft; + int total_dft; int total_leds; }; @@ -29,7 +32,6 @@ static void SHMUpdate(void * id, struct NoteFinder*nf) { struct SHMDriver * d = (struct SHMDriver*)id; - if( !d->lights_file ) { const char * shm_lights = GetParameterS( "shm_lights", 0 ); @@ -46,6 +48,33 @@ static void SHMUpdate(void * id, struct NoteFinder*nf) } + if( !d->dft_file ) + { + const char * shmname = GetParameterS( "shm_dft", 0 ); + //const char * shm_dft = GetParameterS( "shm_dft", 0 ); // Not available. + + if( shmname ) + { + d->dft_file = shm_open(shmname, O_CREAT | O_RDWR, 0644); + ftruncate( d->dft_file, 16384 ); + d->dft_ptr = mmap(0,16384, PROT_READ | PROT_WRITE, MAP_SHARED, d->dft_file, 0); + } + + printf( "Got SHM: %s->%d [%p]\n", shmname, d->dft_file, d->dft_ptr ); + } + + + if( d->dft_ptr ) + { + + d->total_dft = nf->octaves * nf->freqbins; + memcpy( d->dft_ptr+0, &nf->octaves, 4 ); + memcpy( d->dft_ptr+4, &nf->freqbins, 4 ); + memcpy( d->dft_ptr+8, nf->folded_bins, nf->freqbins * sizeof(float) ); + memcpy( d->dft_ptr+8+nf->freqbins * sizeof(float), + nf->outbins, d->total_dft * sizeof(float) ); + } + if( d->lights_ptr ) { memcpy( d->lights_ptr, &d->total_leds, 4 ); diff --git a/colorchord2/shmtest.conf b/colorchord2/shmtest.conf new file mode 100644 index 0000000..fe205d2 --- /dev/null +++ b/colorchord2/shmtest.conf @@ -0,0 +1,49 @@ +cpu_autolimit = 1 + +#General GUI properties. +title = PA Test +set_screenx = 720 +set_screeny = 480 + +sample_channel = -1 +sourcename = alsa_output.pci-0000_01_00.1.hdmi-stereo-extra2.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- | grep monitor + + +#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 = 1.8000 +note_minimum_new_distribution_value = 0.0200 +note_out_chop = 0.05000 + +#compress_coefficient = 4.0 +#compress_exponent = .5 + + +#======================================================================= +#Outputs + + +#DisplayArray +outdrivers = OutputCells, DisplaySHM + +shm_lights = /cclights +shm_dft = /ccdft + +lightx = 20 +lighty = 4 +fromsides = 1 +leds = 120 +qtyamp = 120 + +satamp = 2.800 +amppow = 2.510 +distpow = 1.500 + + +