diff --git a/TODO b/TODO index bc904bc..ca66cea 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,9 @@ Still to do: - +* Figure out why silence for any reasonable length of time results in sadness for the note finder. Try this: * Separate "LED Selection" from "output" algorithms. * For light finding, pick lights off the peaks to get number of lights to use. * For light shifting (for 1d-looping light systems) shift the centers of the notes, then vernoi between the notes. +* Consider running DFT on all channels and mixing results + diff --git a/default.conf b/default.conf index a299072..9795f25 100644 --- a/default.conf +++ b/default.conf @@ -33,7 +33,7 @@ channels = 2 samplerate = 44100 sound_source = PULSE #-1 indicates left and right, 0 left, 1 right. -sample_channel = 1 +sample_channel = -1 sourcename = alsa_output.pci-0000_00_1b.0.analog-stereo.monitor ################################## diff --git a/notefinder.c b/notefinder.c index dfccf13..320e2e0 100644 --- a/notefinder.c +++ b/notefinder.c @@ -238,7 +238,7 @@ void RunNoteFinder( struct NoteFinder * nf, const float * audio_stream, int head { for( j = 0; j < nf->dists; j++ ) { - if( !nf->dist_takens[j] && !nf->note_founds[i] && fabsloop( nf->note_positions[i], nf->dist_means[j], freqbins ) < nf->note_jumpability ) + if( !nf->dist_takens[j] && !nf->note_founds[i] && fabsloop( nf->note_positions[i], nf->dist_means[j], freqbins ) < nf->note_jumpability && nf->dist_amps[j] > 0.00001 ) //0.00001 for stability. { //Attach ourselves to this bin. nf->note_peaks_to_dists_mapping[i] = j; @@ -246,7 +246,9 @@ void RunNoteFinder( struct NoteFinder * nf, const float * audio_stream, int head if( nf->enduring_note_id[i] == 0 ) nf->enduring_note_id[i] = nf->current_note_id++; nf->note_founds[i] = 1; + nf->note_positions[i] = avgloop( nf->note_positions[i], (1.-nf->note_attach_freq_iir), nf->dist_means[j], nf->note_attach_freq_iir, nf->freqbins); + //I guess you can't IIR this like normal. ////note_positions[i] * (1.-note_attach_freq_iir) + dist_means[j] * note_attach_freq_iir; @@ -261,6 +263,7 @@ void RunNoteFinder( struct NoteFinder * nf, const float * audio_stream, int head //Combine like-notes. for( i = 0; i < note_peaks; i++ ) { +// printf( "%f %f %d\n", nf->note_amplitudes[i], nf->note_positions[i], nf->enduring_note_id[i] ); for( j = 0; j < note_peaks; j++ ) { if( i == j ) continue; @@ -280,9 +283,11 @@ void RunNoteFinder( struct NoteFinder * nf, const float * audio_stream, int head b = i; a = j; } + float newp = avgloop( nf->note_positions[a], nf->note_amplitudes[a], nf->note_positions[b], nf->note_amplitudes[b], freqbins ); + //Combine B into A. nf->note_amplitudes[a] += nf->note_amplitudes[b]; - nf->note_positions[a] = avgloop( nf->note_positions[a], nf->note_amplitudes[a], nf->note_positions[b], nf->note_amplitudes[b], freqbins ); + nf->note_positions[a] = newp; nf->note_amplitudes[b] = 0; nf->note_positions[b] = -100; nf->enduring_note_id[b] = 0; diff --git a/parameters.c b/parameters.c index 49af649..22ba5b8 100644 --- a/parameters.c +++ b/parameters.c @@ -210,7 +210,7 @@ void SetParametersFromString( const char * string ) else { //p is an orphan. - printf( "Orp: %s %s\n", name, value ); +// printf( "Orp: %s %s\n", name, value ); struct Param ** n = (struct Param **)HashTableInsert( parameters, name, 0 ); *n = malloc( sizeof ( struct Param ) ); (*n)->orphan = 1;