1 /* 2 * lingot, a musical instrument tuner. 3 * 4 * Copyright (C) 2004-2018 Iban Cereijo. 5 * Copyright (C) 2004-2008 Jairo Chapela. 6 7 * 8 * This file is part of lingot. 9 * 10 * lingot is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * (at your option) any later version. 14 * 15 * lingot is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with lingot; if not, write to the Free Software 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 23 */ 24 25 #ifndef __LINGOT_CORE_H__ 26 #define __LINGOT_CORE_H__ 27 28 #include <pthread.h> 29 30 #include "lingot-defs.h" 31 #include "lingot-complex.h" 32 #include "lingot-filter.h" 33 #include "lingot-config.h" 34 35 #include "lingot-audio.h" 36 37 #include "lingot-fft.h" 38 39 typedef struct { 40 41 // -- shared data -- 42 FLT freq; // computed analog frequency. 43 FLT* SPL; // visual portion of FFT. 44 // -- shared data -- 45 46 LingotAudioHandler audio; // audio handler. 47 48 FLT* flt_read_buffer; 49 FLT* temporal_buffer; // sample memory. 50 51 // precomputed hamming windows 52 FLT* hamming_window_temporal; 53 FLT* hamming_window_fft; 54 55 // windowed signals 56 FLT* windowed_temporal_buffer; 57 FLT* windowed_fft_buffer; 58 59 // spectral power distribution esteem. 60 FLT* spd_fft; 61 FLT* noise_level; 62 63 LingotFFTPlan fftplan; 64 65 LingotFilter antialiasing_filter; // antialiasing filter for decimation. 66 67 int running; 68 69 LingotConfig conf; // configuration structure 70 71 pthread_t thread_computation; 72 pthread_attr_t thread_computation_attr; 73 pthread_cond_t thread_computation_cond; 74 pthread_mutex_t thread_computation_mutex; 75 76 pthread_mutex_t temporal_buffer_mutex; 77 78 # ifdef DRAW_MARKERS 79 int markers[20]; 80 int markers2[20]; 81 short markers_size; 82 short markers_size2; 83 # endif 84 } LingotCore; 85 86 //---------------------------------------------------------------- 87 88 void lingot_core_new(LingotCore*, LingotConfig*); 89 void lingot_core_destroy(LingotCore*); 90 91 // start process 92 void lingot_core_start(LingotCore*); 93 94 // stop process 95 void lingot_core_stop(LingotCore*); 96 97 // tells whether the two frequencies are harmonically related, giving the 98 // multipliers to the ground frequency 99 int lingot_core_frequencies_related(FLT freq1, FLT freq2, FLT minFrequency, 100 FLT* mulFreq1ToFreq, FLT* mulFreq2ToFreq); 101 102 #endif //__LINGOT_CORE_H__ 103