| #include "analyze_peakdetect.h" | #include "analyze_peakdetect.h" | ||||
| void AudioPeak::update(void) | |||||
| void AudioAnalyzePeak::update(void) | |||||
| { | { | ||||
| audio_block_t *block; | audio_block_t *block; | ||||
| const int16_t *p, *end; | const int16_t *p, *end; | ||||
| release(block); | release(block); | ||||
| } | } | ||||
| void AudioPeak::begin(bool noReset) | |||||
| void AudioAnalyzePeak::begin(bool noReset) | |||||
| { | { | ||||
| if(!noReset) | if(!noReset) | ||||
| { | { | ||||
| } | } | ||||
| m_enabled=true; | m_enabled=true; | ||||
| } | } | ||||
| uint16_t AudioPeak::Dpp(void) | |||||
| uint16_t AudioAnalyzePeak::Dpp(void) | |||||
| { | { | ||||
| if(max>min) return max-min; else return 0; | if(max>min) return max-min; else return 0; | ||||
| } | } |
| #include "AudioStream.h" | #include "AudioStream.h" | ||||
| // TODO: this needs to be renamed to AudioAnalyzePeak | // TODO: this needs to be renamed to AudioAnalyzePeak | ||||
| class AudioPeak : public AudioStream | |||||
| class AudioAnalyzePeak : public AudioStream | |||||
| { | { | ||||
| public: | public: | ||||
| AudioPeak(void) : AudioStream(1, inputQueueArray) { } | |||||
| AudioAnalyzePeak(void) : AudioStream(1, inputQueueArray) { } | |||||
| virtual void update(void); | virtual void update(void); | ||||
| // const int myInput = AUDIO_INPUT_MIC; | // const int myInput = AUDIO_INPUT_MIC; | ||||
| AudioInputAnalog audioInput(A0); // A0 is pin 14, feel free to change. | AudioInputAnalog audioInput(A0); // A0 is pin 14, feel free to change. | ||||
| AudioPeak peak_M; | |||||
| AudioAnalyzePeak peak_M; | |||||
| AudioOutputAnalog audioOutput; // DAC pin. | AudioOutputAnalog audioOutput; // DAC pin. | ||||
| AudioConnection c1(audioInput,peak_M); | AudioConnection c1(audioInput,peak_M); |
| // const int myInput = AUDIO_INPUT_MIC; | // const int myInput = AUDIO_INPUT_MIC; | ||||
| AudioInputI2S audioInput; // audio shield: mic or line-in | AudioInputI2S audioInput; // audio shield: mic or line-in | ||||
| AudioPeak peak_L; | |||||
| AudioPeak peak_R; | |||||
| AudioAnalyzePeak peak_L; | |||||
| AudioAnalyzePeak peak_R; | |||||
| AudioOutputI2S audioOutput; // audio shield: headphones & line-out | AudioOutputI2S audioOutput; // audio shield: headphones & line-out | ||||
| AudioConnection c1(audioInput,0,peak_L,0); | AudioConnection c1(audioInput,0,peak_L,0); |
| <script type="text/javascript"> | <script type="text/javascript"> | ||||
| RED.nodes.registerType('AudioPeak',{ | |||||
| RED.nodes.registerType('AudioAnalyzePeak',{ | |||||
| shortName: "peak", | shortName: "peak", | ||||
| inputs:1, | inputs:1, | ||||
| outputs:0, | outputs:0, | ||||
| icon: "arrow-in.png" | icon: "arrow-in.png" | ||||
| }); | }); | ||||
| </script> | </script> | ||||
| <script type="text/x-red" data-help-name="AudioPeak"> | |||||
| <script type="text/x-red" data-help-name="AudioAnalyzePeak"> | |||||
| <h3>Summary</h3> | <h3>Summary</h3> | ||||
| <p>description</p> | <p>description</p> | ||||
| <h3>Audio Connections</h3> | <h3>Audio Connections</h3> | ||||
| <h3>Notes</h3> | <h3>Notes</h3> | ||||
| <p></p> | <p></p> | ||||
| </script> | </script> | ||||
| <script type="text/x-red" data-template-name="AudioPeak"> | |||||
| <script type="text/x-red" data-template-name="AudioAnalyzePeak"> | |||||
| <div class="form-row"> | <div class="form-row"> | ||||
| <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> | <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> | ||||
| <input type="text" id="node-input-name" placeholder="Name"> | <input type="text" id="node-input-name" placeholder="Name"> |