ERIS CORE

◆ init()

void FLASHMEM AppCQT::init ( )
inlineprotected

Definition at line 86 of file appCQT.h.

86  {
87  update_priority = 0;
88  osc_bank_size = OSC_BANK_SIZE;
89  char buffer[32]; //used to build the stream names
90  sprintf(name, "AppCQT"); //set the applications name
91  if (ad == NULL || am== NULL) return;
92  AudioNoInterrupts();
93  for (int16_t i=0; i < osc_bank_size; i++){
94  sprintf(buffer, "waveform:%d", i+1);
95  //request the object from the audio director
97  //init the object to the default state
98  if (osc[i]!=NULL) osc[i]->begin(0.0, 0, WAVEFORM_SINE);
99  }
100  AudioInterrupts();
101  //take care to downcast fetched objects to the correct type!
104  if(fft == NULL || fft2 == NULL) return;
105  fft2->toggleActiveRange(); //switch to low range
106  //zero out the data variables
107  memset(&fftRVal,0,sizeof(FFTReadRange));
108  memset(&oscBank,0,sizeof(FFTReadRange)* OSC_BANK_SIZE);
109  //init the data dictionary value(s)
110  am->data->create(OCTAVE_DOWN_INTERVAL,(int32_t)0);
111  //init the QCT bins by loading the frequency ranges for each music note using a look up table
112  float flow;
113  float fhigh;
114  high_range = CQT_HIGHRANGE_SPLIT_AT_BIN;
115  for (uint16_t i=0;i < NOTE_ARRAY_LENGTH;i++){
116  flow = 0;
117  fhigh = 0;
118  if (i > 0 && i < NOTE_ARRAY_LENGTH-1){
119  //calculate the high and low frequencies for the given note
120  //this is done by splitting the frequency differences from the music note above and below
121  flow = note_freq[i] - (note_freq[i] - note_freq[i-1])/2.0;
122  fhigh = note_freq[i] + (note_freq[i+1] - note_freq[i])/2.0;
123  }else{
124  flow = 0;
125  fhigh = 0;
126  }
127  //zero out the destination within the array
128  memset(&fftHighRR[i],0,sizeof(FFTReadRange));
129  memset(&fftLowRR[i],0,sizeof(FFTReadRange));
130  //write the ranges to the bins, split between the high and low range fft
131  if (i >= high_range){
132  fftHighRR[i].cqtBin =i;
133  fftLowRR[i].cqtBin =i;
134 
135  fftHighRR[i].startFrequency = flow;
136  fftLowRR[i].startFrequency =0;
137 
138  fftHighRR[i].stopFrequency =fhigh;
139  fftLowRR[i].stopFrequency =0;
140 
141  }
142  else{
143  fftHighRR[i].cqtBin =i;
144  fftLowRR[i].cqtBin =i;
145 
146  fftHighRR[i].startFrequency =0;
147  fftLowRR[i].startFrequency =flow;
148 
149  fftHighRR[i].stopFrequency =0;
150  fftLowRR[i].stopFrequency =fhigh;
151  }
152  }
153 
154  rt_calls = 0;
155  update_calls = 0;
156  pll_p=0.0;
157  pll_f=1.0;
158  //enable the fft blocks
162  is_active = true;
163  am->data->create(FFT_AGE_THRESHOLD,(int32_t)6);
164  AudioNoInterrupts();
165  fft->enableFFT(true);
166  fft2->enableFFT(true);
167  AudioInterrupts();
168  };
static const float note_freq[]
Definition: Eris.h:745
AppManager * am
Definition: AppBaseClass.h:38
char name[MAX_NAME_LENGTH]
Definition: AppBaseClass.h:74
uint16_t update_priority
Definition: AppBaseClass.h:52
AudioDirector * ad
Definition: AppBaseClass.h:37
float64_t pll_p
Definition: appCQT.h:76
erisAudioSynthWaveform * osc[OSC_BANK_SIZE]
Definition: appCQT.h:78
float64_t pll_f
Definition: appCQT.h:77
uint16_t high_range
Definition: appCQT.h:75
double rt_calls
Definition: appCQT.h:69
int16_t osc_bank_size
Definition: appCQT.h:74
bool is_active
Definition: appCQT.h:68
uint8_t fft_buffer_select_for_serial_transmit
Definition: appCQT.h:71
FFTReadRange fftLowRR[NOTE_ARRAY_LENGTH]
Definition: appCQT.h:83
erisAudioAnalyzeFFT1024 * fft
Definition: appCQT.h:79
FFTReadRange fftHighRR[NOTE_ARRAY_LENGTH]
Definition: appCQT.h:82
elapsedMillis fft_buffer_serial_transmit_elapsed
Definition: appCQT.h:72
FFTReadRange oscBank[OSC_BANK_SIZE]
Definition: appCQT.h:84
elapsedMillis cqt_serial_transmit_elapsed
Definition: appCQT.h:73
double update_calls
Definition: appCQT.h:70
FFTReadRange fftRVal
Definition: appCQT.h:81
erisAudioAnalyzeFFT1024 * fft2
Definition: appCQT.h:80
SvcDataDictionary * data
Definition: AppManager.h:63
AudioStream * getAudioStreamObjByName(const char *AudioStreamObjName)
void begin(short t_type)
bool create(const char *key, int32_t val, uint32_t *owner)
create a record with ownership
void enableFFT(bool enable_state)

References AppBaseClass::ad, AppBaseClass::am, AudioSynthWaveformhd::begin(), cqt_serial_transmit_elapsed, SvcDataDictionary::create(), AppManager::data, erisAudioAnalyzeFFT1024::enableFFT(), fft, fft2, fft_buffer_select_for_serial_transmit, fft_buffer_serial_transmit_elapsed, fftHighRR, fftLowRR, fftRVal, AudioDirector::getAudioStreamObjByName(), high_range, is_active, AppBaseClass::name, note_freq, osc, osc_bank_size, oscBank, pll_f, pll_p, rt_calls, erisAudioAnalyzeFFT1024::toggleActiveRange(), update_calls, and AppBaseClass::update_priority.

Referenced by AppCQT().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: