diff --git a/default.conf b/default.conf index 0ccc958..e441a2d 100644 --- a/default.conf +++ b/default.conf @@ -17,7 +17,7 @@ buffer = 128 play = 0 rec = 1 channels = 2 -samplerate = 8000 +samplerate = 11025 wininput = 0 #Compiled version will default this. diff --git a/embeddednf.c b/embeddednf.c index ff69855..3a3f9e1 100644 --- a/embeddednf.c +++ b/embeddednf.c @@ -6,6 +6,7 @@ uint16_t fuzzed_bins[FIXBINS]; uint8_t note_peak_freqs[MAXNOTES]; uint16_t note_peak_amps[MAXNOTES]; uint16_t note_peak_amps2[MAXNOTES]; +uint8_t note_jumped_to[MAXNOTES]; static const float bf_table[24] = { @@ -215,7 +216,7 @@ void HandleFrameInfo() if( thisfreq > 255-(1<>15; - note_peak_amps[i] = amp1 + amp2; - note_peak_amps[j] = 0; note_peak_freqs[i] = newnote; + note_peak_amps[i] = (note_peak_amps[i]+note_peak_amps[j])>>1; + note_peak_amps2[i] = (note_peak_amps2[i]+note_peak_amps2[j])>>1; + note_peak_freqs[j] = 255; - note_peak_amps2[i] += note_peak_amps2[j]; + note_peak_amps[j] = 0; + note_jumped_to[j] = i; } @@ -338,7 +341,7 @@ void HandleFrameInfo() } //We now have notes!!! -#if 1 +#if 0 for( i = 0; i < MAXNOTES; i++ ) { if( note_peak_freqs[i] == 255 ) continue; @@ -350,10 +353,12 @@ void HandleFrameInfo() #if 0 for( i = 0; i < FIXBPERO; i++ ) { - printf( "%5d ", folded_bins[i] ); + printf( "%4d ", folded_bins[i] ); } printf( "\n" ); #endif + + } diff --git a/embeddednf.h b/embeddednf.h index bc953da..098b0ac 100644 --- a/embeddednf.h +++ b/embeddednf.h @@ -5,7 +5,10 @@ //they can multiply quickly, this is the bees knees. #define USE_32DFT +#ifndef DFREQ #define DFREQ 8000 +#endif + #define BASE_FREQ 55.0 // You may make this a float. //The higher the number the slackier your FFT will be come. @@ -23,14 +26,14 @@ //This is the amplitude, coming from folded_bins. If the value is below this //it is considered a non-note. -#define MIN_AMP_FOR_NOTE 128 +#define MIN_AMP_FOR_NOTE 64 //If there is detected note this far away from an established note, we will //then consider this new note the same one as last time, and move the established //note. This is also used when combining notes. It is this distance times two. #define MAX_JUMP_DISTANCE 7 -#define MINIMUM_AMP_FOR_NOTE_TO_DISAPPEAR 64 +#define MINIMUM_AMP_FOR_NOTE_TO_DISAPPEAR 32 #define AMP_1_NERFING_BITS 5 #define AMP_2_NERFING_BITS 3 @@ -48,6 +51,8 @@ extern uint16_t fuzzed_bins[]; //[FIXBINS] <- The Full DFT after IIR, Blur and extern uint8_t note_peak_freqs[]; extern uint16_t note_peak_amps[]; //[MAXNOTES] extern uint16_t note_peak_amps2[]; //[MAXNOTES] (Responds quicker) +extern uint8_t note_jumped_to[]; //[MAXNOTES] When a note combines into another one, + //this records where it went. I.e. if your note just disappeared, check this flag. //XXX: TODO: Consider doing the fuzz IIR on the folded bins. That way we can //save several bytes of RAM on not having to keep fuzzed_bins around. diff --git a/embeddedx86/Makefile b/embeddedx86/Makefile index 5a0d78b..af6483a 100644 --- a/embeddedx86/Makefile +++ b/embeddedx86/Makefile @@ -1,13 +1,13 @@ all : embeddedcc -CFLAGS:=-Ofast -DCCEMBEDDED -I.. -flto -m32 +CFLAGS:=-Ofast -DCCEMBEDDED -I.. -flto -m32 -DDFREQ=11025 LDFLAGS:=-ffunction-sections -Wl,--gc-sections -fno-asynchronous-unwind-tables -Wl,--strip-all embeddedcc : ../embeddednf.c ../DFT32.c embeddedcc.c gcc -o $@ $^ $(CFLAGS) $(LDFLAGS) runembedded : embeddedcc - parec --format=u8 --rate=8000 --channels=1 --device=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor | ./embeddedcc + parec --format=u8 --rate=11025 --channels=1 --device=alsa_output.pci-0000_00_1b.0.analog-stereo.monitor | ./embeddedcc clean : rm -rf embeddedcc *~