2015-07-29 07:56:18 +02:00
|
|
|
//Copyright 2015 <>< Charles Lohr under the ColorChord License.
|
|
|
|
|
2015-04-02 04:59:12 +02:00
|
|
|
#ifndef _EMBEDDEDNF_H
|
|
|
|
#define _EMBEDDEDNF_H
|
|
|
|
|
2015-07-29 07:56:18 +02:00
|
|
|
#include <ccconfig.h>
|
|
|
|
|
2015-04-03 20:10:25 +02:00
|
|
|
//Use a 32-bit DFT. It won't work for AVRs, but for any 32-bit systems where
|
|
|
|
//they can multiply quickly, this is the bees knees.
|
|
|
|
#define USE_32DFT
|
2015-04-02 04:59:12 +02:00
|
|
|
|
2015-04-03 21:34:11 +02:00
|
|
|
#ifndef DFREQ
|
2015-04-02 04:59:12 +02:00
|
|
|
#define DFREQ 8000
|
2015-04-03 21:34:11 +02:00
|
|
|
#endif
|
|
|
|
|
2015-07-29 07:56:18 +02:00
|
|
|
//You may make this a float. If PRECOMPUTE_FREQUENCY_TABLE is defined, then
|
|
|
|
//it will create the table at compile time, and the float will never be used
|
|
|
|
//runtime.
|
|
|
|
#define BASE_FREQ 55.0
|
2015-04-02 04:59:12 +02:00
|
|
|
|
|
|
|
//The higher the number the slackier your FFT will be come.
|
2015-08-03 07:19:11 +02:00
|
|
|
#ifndef FUZZ_IIR_BITS
|
2015-04-02 04:59:12 +02:00
|
|
|
#define FUZZ_IIR_BITS 1
|
2015-08-03 07:19:11 +02:00
|
|
|
#endif
|
2015-04-02 04:59:12 +02:00
|
|
|
|
|
|
|
//Notes are the individually identifiable notes we receive from the sound.
|
|
|
|
//We track up to this many at one time. Just because a note may appear to
|
|
|
|
//vaporize in one frame doesn't mean it is annihilated immediately.
|
2015-08-03 07:19:11 +02:00
|
|
|
#ifndef MAXNOTES
|
2015-04-04 08:23:53 +02:00
|
|
|
#define MAXNOTES 12
|
2015-08-03 07:19:11 +02:00
|
|
|
#endif
|
2015-04-02 04:59:12 +02:00
|
|
|
|
2015-04-05 03:19:46 +02:00
|
|
|
//We take the raw signal off of the
|
2015-08-03 07:19:11 +02:00
|
|
|
#ifndef FILTER_BLUR_PASSES
|
2019-06-18 11:43:17 +02:00
|
|
|
#define FILTER_BLUR_PASSES 1
|
2015-08-03 07:19:11 +02:00
|
|
|
#endif
|
2015-04-05 00:35:03 +02:00
|
|
|
|
2015-04-05 03:19:46 +02:00
|
|
|
//Determines bit shifts for where notes lie. We represent notes with an
|
|
|
|
//uint8_t. We have to define all of the possible locations on the note line
|
|
|
|
//in this. note_frequency = 0..((1<<SEMIBITSPERBIN)*FIXBPERO-1)
|
2015-08-03 07:19:11 +02:00
|
|
|
#ifndef SEMIBITSPERBIN
|
2015-04-02 04:59:12 +02:00
|
|
|
#define SEMIBITSPERBIN 3
|
2015-08-03 07:19:11 +02:00
|
|
|
#endif
|
|
|
|
|
2015-04-03 23:50:14 +02:00
|
|
|
#define NOTERANGE ((1<<SEMIBITSPERBIN)*FIXBPERO)
|
2015-04-02 04:59:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
//If there is detected note this far away from an established note, we will
|
2015-04-05 03:19:46 +02:00
|
|
|
//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.
|
2015-08-03 07:19:11 +02:00
|
|
|
#ifndef MAX_JUMP_DISTANCE
|
2015-04-05 00:35:03 +02:00
|
|
|
#define MAX_JUMP_DISTANCE 4
|
2015-08-03 07:19:11 +02:00
|
|
|
#endif
|
2015-04-04 08:23:53 +02:00
|
|
|
|
2015-08-03 07:19:11 +02:00
|
|
|
#ifndef MAX_COMBINE_DISTANCE
|
2015-04-05 04:16:55 +02:00
|
|
|
#define MAX_COMBINE_DISTANCE 7
|
2015-08-03 07:19:11 +02:00
|
|
|
#endif
|
2015-04-02 04:59:12 +02:00
|
|
|
|
2015-04-05 03:19:46 +02:00
|
|
|
//These control how quickly the IIR for the note strengths respond. AMP 1 is
|
|
|
|
//the response for the slow-response, or what we use to determine size of
|
|
|
|
//splotches, AMP 2 is the quick response, or what we use to see the visual
|
|
|
|
//strength of the notes.
|
2015-08-03 07:19:11 +02:00
|
|
|
#ifndef AMP_1_IIR_BITS
|
2015-07-21 03:18:07 +02:00
|
|
|
#define AMP_1_IIR_BITS 4
|
2015-08-03 07:19:11 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef AMP_2_IIR_BITS
|
2015-04-05 04:16:55 +02:00
|
|
|
#define AMP_2_IIR_BITS 2
|
2015-08-03 07:19:11 +02:00
|
|
|
#endif
|
2015-04-02 04:59:12 +02:00
|
|
|
|
2015-04-04 08:23:53 +02:00
|
|
|
//This is the amplitude, coming from folded_bins. If the value is below this
|
|
|
|
//it is considered a non-note.
|
2015-08-03 07:19:11 +02:00
|
|
|
#ifndef MIN_AMP_FOR_NOTE
|
2015-04-05 04:16:55 +02:00
|
|
|
#define MIN_AMP_FOR_NOTE 80
|
2015-08-03 07:19:11 +02:00
|
|
|
#endif
|
2015-04-05 03:19:46 +02:00
|
|
|
|
|
|
|
//If the strength of a note falls below this, the note will disappear, and be
|
|
|
|
//recycled back into the unused list of notes.
|
2015-08-03 07:19:11 +02:00
|
|
|
#ifndef MINIMUM_AMP_FOR_NOTE_TO_DISAPPEAR
|
2015-04-05 04:16:55 +02:00
|
|
|
#define MINIMUM_AMP_FOR_NOTE_TO_DISAPPEAR 64
|
2015-08-03 07:19:11 +02:00
|
|
|
#endif
|
2015-04-04 08:23:53 +02:00
|
|
|
|
2015-07-29 07:56:18 +02:00
|
|
|
//This prevents compilation of any floating-point code, but it does come with
|
|
|
|
//an added restriction: Both DFREQ and BASE_FREQ must be #defined to be
|
|
|
|
//constants.
|
|
|
|
#define PRECOMPUTE_FREQUENCY_TABLE
|
2015-04-03 20:10:25 +02:00
|
|
|
|
|
|
|
#include "DFT32.h"
|
|
|
|
|
2015-04-02 04:59:12 +02:00
|
|
|
extern uint16_t fuzzed_bins[]; //[FIXBINS] <- The Full DFT after IIR, Blur and Taper
|
|
|
|
|
2015-08-03 07:19:11 +02:00
|
|
|
extern uint16_t folded_bins[]; //[FIXBPERO] <- The folded fourier output.
|
|
|
|
|
2015-04-05 03:19:46 +02:00
|
|
|
//frequency of note; Note if it is == 255, then it means it is not set. It is
|
|
|
|
//generally a value from
|
2015-08-03 07:19:11 +02:00
|
|
|
extern uint8_t note_peak_freqs[]; //[MAXNOTES]
|
2015-04-02 04:59:12 +02:00
|
|
|
extern uint16_t note_peak_amps[]; //[MAXNOTES]
|
2015-08-03 07:19:11 +02:00
|
|
|
extern uint16_t note_peak_amps2[]; //[MAXNOTES] (Responds quicker)
|
|
|
|
extern uint8_t note_jumped_to[]; //[MAXNOTES] When a note combines into another one,
|
2015-04-03 21:34:11 +02:00
|
|
|
//this records where it went. I.e. if your note just disappeared, check this flag.
|
2015-04-02 04:59:12 +02:00
|
|
|
|
2015-07-29 07:56:18 +02:00
|
|
|
void UpdateFreqs(); //Not user-useful on most systems.
|
|
|
|
void HandleFrameInfo(); //Not user-useful on most systems
|
|
|
|
|
|
|
|
|
2015-04-02 04:59:12 +02:00
|
|
|
|
2015-07-29 07:56:18 +02:00
|
|
|
//Call this when starting.
|
|
|
|
void InitColorChord();
|
2015-04-02 04:59:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|