From 2d953fc5e8633b64f2e271916d6a0e44c4ea5d51 Mon Sep 17 00:00:00 2001 From: edgeeffect Date: Sat, 14 Feb 2004 08:42:32 +0000 Subject: [PATCH] No erroneous data in meter and scope on create. Reset button in amp fixed --- SpiralSound/Plugins/AmpPlugin/AmpPlugin.C | 4 +-- SpiralSound/Plugins/AmpPlugin/AmpPlugin.h | 16 +++++----- SpiralSound/Plugins/AmpPlugin/AmpPluginGUI.C | 2 +- SpiralSound/Plugins/MeterPlugin/MeterPlugin.C | 15 +++++---- SpiralSound/Plugins/MeterPlugin/MeterPlugin.h | 3 +- .../Plugins/MeterPlugin/MeterPluginGUI.C | 3 +- SpiralSound/Plugins/ScopePlugin/ScopePlugin.C | 22 +++++++------ SpiralSound/Plugins/ScopePlugin/ScopePlugin.h | 31 +++++++++---------- .../Plugins/ScopePlugin/ScopePluginGUI.C | 24 +++++++------- .../Plugins/ScopePlugin/ScopePluginGUI.h | 12 +++---- 10 files changed, 66 insertions(+), 66 deletions(-) diff --git a/SpiralSound/Plugins/AmpPlugin/AmpPlugin.C b/SpiralSound/Plugins/AmpPlugin/AmpPlugin.C index 488df3e..53e273e 100644 --- a/SpiralSound/Plugins/AmpPlugin/AmpPlugin.C +++ b/SpiralSound/Plugins/AmpPlugin/AmpPlugin.C @@ -62,7 +62,6 @@ m_DC(0.0f) m_PluginInfo.PortTips.push_back("Gain CV"); m_PluginInfo.PortTips.push_back("DC Offset CV"); m_PluginInfo.PortTips.push_back("Output"); - m_AudioCH->Register("Gain",&m_Gain); m_AudioCH->Register("DC",&m_DC); } @@ -92,7 +91,8 @@ void AmpPlugin::Execute() in = GetInput(0,n); in *= m_Gain+GetInput(1,n); in += (-m_DC)+GetInput(2,n); - SetOutput(0,n,in); + SetOutput(0,n,in); + //cerr << m_Gain << " "; } } diff --git a/SpiralSound/Plugins/AmpPlugin/AmpPlugin.h b/SpiralSound/Plugins/AmpPlugin/AmpPlugin.h index 431128e..47eaea1 100644 --- a/SpiralSound/Plugins/AmpPlugin/AmpPlugin.h +++ b/SpiralSound/Plugins/AmpPlugin/AmpPlugin.h @@ -14,14 +14,14 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ - -#include "../SpiralPlugin.h" -#include +*/ #ifndef AMPPLUGIN #define AMPPLUGIN +#include "../SpiralPlugin.h" +#include + class AmpPlugin : public SpiralPlugin { public: @@ -37,15 +37,13 @@ public: // has to be defined in the plugin virtual void UpdateGUI() { Fl::check(); } - float GetGain() { return m_Gain; } - float GetDC() { return m_DC; } + float GetGain() { return m_Gain; } + float GetDC() { return m_DC; } void Randomise(); private: - float m_Gain; - float m_DC; - + float m_Gain, m_DC; friend std::istream &operator>>(std::istream &s, AmpPlugin &o); friend std::ostream &operator<<(std::ostream &s, AmpPlugin &o); }; diff --git a/SpiralSound/Plugins/AmpPlugin/AmpPluginGUI.C b/SpiralSound/Plugins/AmpPlugin/AmpPluginGUI.C index dd4a9a1..0478b21 100644 --- a/SpiralSound/Plugins/AmpPlugin/AmpPluginGUI.C +++ b/SpiralSound/Plugins/AmpPlugin/AmpPluginGUI.C @@ -166,7 +166,7 @@ void AmpPluginGUI::cb_NumDC (Fl_Counter* o, void* v) { inline void AmpPluginGUI::cb_Reset_i (Fl_Button* o, void* v) { m_NumGain->value (1.0); m_Gain->value (1.0); - m_GUICH->Set ("Gain", 0); + m_GUICH->Set ("Gain", 1.0f); m_NumDC->value (0.0); m_DC->value (2.0); m_GUICH->Set ("DC", 0); diff --git a/SpiralSound/Plugins/MeterPlugin/MeterPlugin.C b/SpiralSound/Plugins/MeterPlugin/MeterPlugin.C index 1b88424..b139703 100644 --- a/SpiralSound/Plugins/MeterPlugin/MeterPlugin.C +++ b/SpiralSound/Plugins/MeterPlugin/MeterPlugin.C @@ -36,6 +36,7 @@ string SpiralPlugin_GetGroupName() { return "Control"; } MeterPlugin::MeterPlugin(): m_Data (NULL), +m_DataReady (false), m_VUMode (true) { m_PluginInfo.Name = "Meter"; @@ -45,6 +46,7 @@ m_VUMode (true) m_PluginInfo.NumOutputs = 1; m_PluginInfo.PortTips.push_back ("Input"); m_PluginInfo.PortTips.push_back ("Output"); + m_AudioCH->Register ("DataReady", &m_DataReady, ChannelHandler::OUTPUT); m_Version = 1; } @@ -64,12 +66,13 @@ SpiralGUIType *MeterPlugin::CreateGUI() { } void MeterPlugin::Execute() { - // Just copy the data through. - if (GetOutputBuf (0)) GetOutputBuf (0)->Zero(); - if (GetInput (0)) { - GetOutputBuf (0)->Mix (*GetInput(0), 0); - memcpy (m_Data, GetInput (0)->GetBuffer (), m_HostInfo->BUFSIZE * sizeof (float)); - } + // Just copy the data through. + m_DataReady = InputExists (0); + if (GetOutputBuf (0)) GetOutputBuf (0)->Zero(); + if (m_DataReady) { + GetOutputBuf (0)->Mix (*GetInput(0), 0); + memcpy (m_Data, GetInput (0)->GetBuffer (), m_HostInfo->BUFSIZE * sizeof (float)); + } } void MeterPlugin::ExecuteCommands () { diff --git a/SpiralSound/Plugins/MeterPlugin/MeterPlugin.h b/SpiralSound/Plugins/MeterPlugin/MeterPlugin.h index 56ec1f8..c93832a 100644 --- a/SpiralSound/Plugins/MeterPlugin/MeterPlugin.h +++ b/SpiralSound/Plugins/MeterPlugin/MeterPlugin.h @@ -35,7 +35,8 @@ class MeterPlugin : public SpiralPlugin { enum GUICommands {NONE, SETVU, SETMM}; private: float *m_Data; - bool m_VUMode; // This value isn't USED for anything, it's here so we can save/load it + // m_VUMode isn't USED for anything, it's here so we can save/load it + bool m_DataReady, m_VUMode; }; #endif diff --git a/SpiralSound/Plugins/MeterPlugin/MeterPluginGUI.C b/SpiralSound/Plugins/MeterPlugin/MeterPluginGUI.C index b08d2bd..cbfbfa3 100644 --- a/SpiralSound/Plugins/MeterPlugin/MeterPluginGUI.C +++ b/SpiralSound/Plugins/MeterPlugin/MeterPluginGUI.C @@ -94,7 +94,8 @@ void MeterPluginGUI::draw() { SpiralGUIType::draw (); if (! m_Bypass) { float datum = 0.0; - m_GUICH->GetData ("AudioData", m_Data); + if (m_GUICH->GetBool ("DataReady")) m_GUICH->GetData ("AudioData", m_Data); + else memset (m_Data, 0, m_BufSize * sizeof (float)); // The min and max values are based on the whole buffer for (int c=0; cRegister ("DataReady", &m_DataReady, ChannelHandler::OUTPUT); } ScopePlugin::~ScopePlugin() @@ -65,10 +67,10 @@ SpiralGUIType *ScopePlugin::CreateGUI() void ScopePlugin::Execute() { // Just copy the data through. + m_DataReady = InputExists (0); if (GetOutputBuf (0)) GetOutputBuf (0)->Zero(); - if (GetInput (0)) { + if (m_DataReady) { GetOutputBuf (0)->Mix (*GetInput(0), 0); memcpy (m_Data, GetInput (0)->GetBuffer (), m_HostInfo->BUFSIZE * sizeof (float)); } } - diff --git a/SpiralSound/Plugins/ScopePlugin/ScopePlugin.h b/SpiralSound/Plugins/ScopePlugin/ScopePlugin.h index 8da071d..d15a366 100644 --- a/SpiralSound/Plugins/ScopePlugin/ScopePlugin.h +++ b/SpiralSound/Plugins/ScopePlugin/ScopePlugin.h @@ -16,27 +16,24 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../SpiralPlugin.h" -#include - #ifndef SCOPEPLUGIN #define SCOPEPLUGIN -class ScopePlugin : public SpiralPlugin -{ -public: - ScopePlugin(); - virtual ~ScopePlugin(); - - virtual PluginInfo& Initialise(const HostInfo *Host); - virtual SpiralGUIType* CreateGUI(); - virtual void Execute(); - virtual void StreamOut(std::ostream &s) {} - virtual void StreamIn(std::istream &s) {} - -private: +#include "../SpiralPlugin.h" +#include - float *m_Data; +class ScopePlugin : public SpiralPlugin { + public: + ScopePlugin(); + virtual ~ScopePlugin(); + virtual PluginInfo& Initialise(const HostInfo *Host); + virtual SpiralGUIType* CreateGUI(); + virtual void Execute(); + virtual void StreamOut(std::ostream &s) {} + virtual void StreamIn(std::istream &s) {} + private: + float *m_Data; + bool m_DataReady; }; #endif diff --git a/SpiralSound/Plugins/ScopePlugin/ScopePluginGUI.C b/SpiralSound/Plugins/ScopePlugin/ScopePluginGUI.C index 25296f9..a27e05d 100644 --- a/SpiralSound/Plugins/ScopePlugin/ScopePluginGUI.C +++ b/SpiralSound/Plugins/ScopePlugin/ScopePluginGUI.C @@ -43,6 +43,8 @@ void ScopeWidget::draw() { int ho=h()/2; fl_color (color()); fl_rectf (x(), y(), w(), h()); + fl_color (m_MarkColour); + fl_line (x(), y()+ho, x()+w(), y()+ho); if (!m_Data) return; fl_push_clip (x(), y(), w(), h()); float Value=0, NextValue=0; @@ -63,9 +65,10 @@ ScopePluginGUI::ScopePluginGUI(int w, int h, SpiralPlugin *o, ChannelHandler *ch SpiralPluginGUI(w,h,o,ch), m_Bypass(false) { - m_Scope = new ScopeWidget(5, 20, 210, 85, "Scope", Info->BUFSIZE); + m_BufSize = Info->BUFSIZE; + m_Scope = new ScopeWidget(5, 20, 210, 85, "Scope", m_BufSize); m_Scope->color (Info->SCOPE_BG_COLOUR); - m_Scope->SetWaveColour (Info->SCOPE_FG_COLOUR); + m_Scope->SetColours (Info->SCOPE_MRK_COLOUR, Info->SCOPE_FG_COLOUR); m_Attenuation = new Fl_Knob (220, 10, 40, 40, "Attenuation"); m_Attenuation->color(Info->GUI_COLOUR); m_Attenuation->type(Fl_Knob::LINELIN); @@ -91,12 +94,6 @@ m_Bypass(false) end(); } -void ScopePluginGUI::Display(const float *data) -{ - //m_Scope->m_Data=data; - if (!m_Bypass) m_Scope->redraw(); -} - void ScopePluginGUI::Update() { redraw(); @@ -104,11 +101,12 @@ void ScopePluginGUI::Update() void ScopePluginGUI::draw() { - SpiralGUIType::draw(); - const float *data; - //cerr<<"getting and drawing..."<GetData("AudioData",(void*)m_Scope->m_Data); - Display(data); + SpiralGUIType::draw(); + const float *data; + //cerr<<"getting and drawing..."<GetBool ("DataReady")) m_GUICH->GetData ("AudioData", (void*)m_Scope->m_Data); + else memset ((void*)m_Scope->m_Data, 0, m_BufSize * sizeof (float)); + if (!m_Bypass) m_Scope->redraw(); } void ScopePluginGUI::UpdateValues(SpiralPlugin* o) diff --git a/SpiralSound/Plugins/ScopePlugin/ScopePluginGUI.h b/SpiralSound/Plugins/ScopePlugin/ScopePluginGUI.h index 230b1b6..57a9dbd 100644 --- a/SpiralSound/Plugins/ScopePlugin/ScopePluginGUI.h +++ b/SpiralSound/Plugins/ScopePlugin/ScopePluginGUI.h @@ -16,15 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifndef SCOPEGUI +#define SCOPEGUI + #include #include #include "../Widgets/Fl_Knob.H" #include "ScopePlugin.h" #include "../SpiralPluginGUI.h" -#ifndef SCOPEGUI -#define SCOPEGUI - class ScopeWidget : public Fl_Widget { public: @@ -32,14 +32,14 @@ class ScopeWidget : public Fl_Widget ~ScopeWidget(); void draw(); //void SetNumChannels (int s) { m_Channels=s; } - void SetWaveColour (unsigned c) { m_WaveColour=(Fl_Color)c; } + void SetColours (unsigned m, unsigned f) { m_MarkColour=(Fl_Color)m; m_WaveColour=(Fl_Color)f; } void SetAttenuation (float c) { m_Attenuation=c; } void SetTimeBase (float c) { m_TimeBase=c; } const float *m_Data; //int m_Channels; private: //int m_GUIColour, m_GUIBGColour; - Fl_Color m_WaveColour; + Fl_Color m_MarkColour, m_WaveColour; float m_Attenuation, m_TimeBase; int m_Bufsize; }; @@ -52,11 +52,11 @@ class ScopePluginGUI : public SpiralPluginGUI virtual void UpdateValues (SpiralPlugin* o); virtual void Update(); virtual void draw(); - void Display (const float *data); protected: const std::string GetHelpText (const std::string &loc); private: bool m_Bypass; + int m_BufSize; // Fl_Button *Bypass; ScopeWidget *m_Scope; Fl_Knob *m_Attenuation, *m_TimeBase;