ajout oscillo
This commit is contained in:
1 parent
5cf2212fc0
commit
f01d3213c0
18 files changed
+741
-12
No files matched your search
@@ -0,0 +1,36 @@
|
||||
#ifndef OSCILLOPRESENTER_HPP
|
||||
#define OSCILLOPRESENTER_HPP
|
||||
|
||||
#include <gui/model/ModelListener.hpp>
|
||||
#include <mvp/Presenter.hpp>
|
||||
|
||||
using namespace touchgfx;
|
||||
|
||||
class OscilloView;
|
||||
|
||||
class OscilloPresenter : public touchgfx::Presenter, public ModelListener
|
||||
{
|
||||
public:
|
||||
OscilloPresenter(OscilloView& v);
|
||||
|
||||
/**
|
||||
* The activate function is called automatically when this screen is "switched in"
|
||||
* (ie. made active). Initialization logic can be placed here.
|
||||
*/
|
||||
virtual void activate();
|
||||
|
||||
/**
|
||||
* The deactivate function is called automatically when this screen is "switched out"
|
||||
* (ie. made inactive). Teardown functionality can be placed here.
|
||||
*/
|
||||
virtual void deactivate();
|
||||
|
||||
virtual ~OscilloPresenter() {}
|
||||
|
||||
private:
|
||||
OscilloPresenter();
|
||||
|
||||
OscilloView& view;
|
||||
};
|
||||
|
||||
#endif // OSCILLOPRESENTER_HPP
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef OSCILLOVIEW_HPP
|
||||
#define OSCILLOVIEW_HPP
|
||||
|
||||
#include <gui_generated/oscillo_screen/OscilloViewBase.hpp>
|
||||
#include <gui/oscillo_screen/OscilloPresenter.hpp>
|
||||
|
||||
class OscilloView : public OscilloViewBase
|
||||
{
|
||||
public:
|
||||
OscilloView();
|
||||
virtual ~OscilloView() {}
|
||||
virtual void setupScreen();
|
||||
virtual void tearDownScreen();
|
||||
virtual void handleTickEvent();
|
||||
|
||||
virtual void toggleClicked();
|
||||
protected:
|
||||
};
|
||||
|
||||
#endif // OSCILLOVIEW_HPP
|
||||
@@ -13,6 +13,7 @@ public:
|
||||
virtual void tearDownScreen();
|
||||
|
||||
virtual void toggleAudioOnOFF();
|
||||
virtual void slider1Changed(int value);
|
||||
protected:
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#include <gui/oscillo_screen/OscilloView.hpp>
|
||||
#include <gui/oscillo_screen/OscilloPresenter.hpp>
|
||||
|
||||
OscilloPresenter::OscilloPresenter(OscilloView& v)
|
||||
: view(v)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OscilloPresenter::activate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void OscilloPresenter::deactivate()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
#include <gui/oscillo_screen/OscilloView.hpp>
|
||||
#include <audio_analysis.h>
|
||||
#include <touchgfx/Unicode.hpp>
|
||||
|
||||
OscilloView::OscilloView()
|
||||
{
|
||||
}
|
||||
|
||||
void OscilloView::setupScreen()
|
||||
{
|
||||
OscilloViewBase::setupScreen();
|
||||
toggleButton1.forceState(AudioAnalysis_IsEnabled());
|
||||
|
||||
/* Echelle du graphe en dB (affichage uniquement, pas une mesure calibree) :
|
||||
* de -80dB (proche du plancher de bruit numerique) a +5dB de marge au-dessus
|
||||
* du 0dB nominal. */
|
||||
graph1.setGraphRangeY(-80.0f, 5.0f);
|
||||
|
||||
/* Axe X en Hz, de 0 a Fe/2 (24kHz) : ce graphe (statique, points X/Y explicites,
|
||||
* contrairement au precedent DynamicGraph a increment X automatique) recoit
|
||||
* directement la frequence de chaque bin avec addDataPoint(x, y). */
|
||||
graph1.setGraphRangeX(0.0f, (float)AUDIO_ANALYSIS_SAMPLE_RATE_HZ / 2.0f);
|
||||
}
|
||||
|
||||
void OscilloView::tearDownScreen()
|
||||
{
|
||||
OscilloViewBase::tearDownScreen();
|
||||
}
|
||||
|
||||
void OscilloView::handleTickEvent()
|
||||
{
|
||||
OscilloViewBase::handleTickEvent();
|
||||
|
||||
if (!AudioAnalysis_IsEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (AudioAnalysis_Update())
|
||||
{
|
||||
const float *magnitudesDb = AudioAnalysis_GetMagnitudesDb();
|
||||
const float binHz = (float)AUDIO_ANALYSIS_SAMPLE_RATE_HZ / (float)AUDIO_ANALYSIS_FFT_SIZE;
|
||||
|
||||
graph1.clear();
|
||||
for (int i = 0; i < (int)AUDIO_ANALYSIS_NUM_BINS; i++)
|
||||
{
|
||||
graph1.addDataPoint((float)i * binHz, magnitudesDb[i]);
|
||||
}
|
||||
|
||||
touchgfx::Unicode::snprintf(textArea2Buffer, TEXTAREA2_SIZE, "%d", (int)AudioAnalysis_GetPeakFrequencyHz());
|
||||
textArea2.setWildcard(textArea2Buffer);
|
||||
textArea2.invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void OscilloView::toggleClicked()
|
||||
{
|
||||
AudioAnalysis_SetEnabled(toggleButton1.getState());
|
||||
}
|
||||
@@ -10,6 +10,7 @@ void OverviewView::setupScreen()
|
||||
{
|
||||
OverviewViewBase::setupScreen();
|
||||
toggleButton1.forceState(AudioEffects_GetParams()->audio_on_off);
|
||||
slider1.setValue((int16_t)(AudioEffects_GetParams()->master_volume * 100.0f));
|
||||
}
|
||||
|
||||
void OverviewView::tearDownScreen()
|
||||
@@ -21,3 +22,15 @@ void OverviewView::toggleAudioOnOFF()
|
||||
{
|
||||
AudioEffects_GetParams()->audio_on_off = toggleButton1.getState();
|
||||
}
|
||||
|
||||
void OverviewView::slider1Changed(int value)
|
||||
{
|
||||
AudioEffects_GetParams()->master_volume = value / 100.0f;
|
||||
|
||||
/* Le volume pilote l'etat marche/arret (0 = off, non nul = on), mais pas
|
||||
* l'inverse : agir sur le toggle ne doit pas modifier le volume. */
|
||||
bool en = (value != 0);
|
||||
AudioEffects_GetParams()->audio_on_off = en;
|
||||
toggleButton1.forceState(en);
|
||||
toggleButton1.invalidate();
|
||||
}
|
||||
Reference in new issue
Block a user