changeset 7:f7ec6d983ec0

Begins of the polar plot.
author martinm_home <martin.morrell@eecs.qmul.ac.uk>
date Sat, 15 Sep 2012 15:07:00 +0100
parents 503cbcdd0b2a
children d967dd1eafe8
files Classic Ambisonics Decoder VST.xcodeproj/project.pbxproj Classic Ambisonics Decoder VST.xcodeproj/project.xcworkspace/xcuserdata/momont.xcuserdatad/UserInterfaceState.xcuserstate Classic Ambisonics Decoder VST.xcodeproj/xcuserdata/momont.xcuserdatad/xcschemes/Classic Ambisonics Decoder VST.xcscheme Source/GUI.cpp Source/GUI.h Source/MyPlot.cpp Source/MyPlot.h
diffstat 7 files changed, 297 insertions(+), 102 deletions(-) [+]
line wrap: on
line diff
--- a/Classic Ambisonics Decoder VST.xcodeproj/project.pbxproj	Mon Sep 10 14:03:14 2012 +0100
+++ b/Classic Ambisonics Decoder VST.xcodeproj/project.pbxproj	Sat Sep 15 15:07:00 2012 +0100
@@ -26,6 +26,7 @@
 		0C7C241B159860DE0050E903 /* audioeffect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0C7C2416159860DE0050E903 /* audioeffect.cpp */; };
 		0C7C241C159860DE0050E903 /* audioeffectx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0C7C2418159860DE0050E903 /* audioeffectx.cpp */; };
 		0C7C241D159860DE0050E903 /* vstplugmain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0C7C241A159860DE0050E903 /* vstplugmain.cpp */; };
+		0CC1308516045FA400DFB900 /* MyPlot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0C54F70415F8BB4C00953CE0 /* MyPlot.cpp */; };
 		8D01CCCE0486CAD60068D4B7 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08EA7FFBFE8413EDC02AAC07 /* Carbon.framework */; };
 		F43771F012439E4600248B30 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F47F241F11D4C30900C94CAF /* Cocoa.framework */; };
 		F43771F312439E9100248B30 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F47F241C11D4C2F600C94CAF /* Accelerate.framework */; };
@@ -277,6 +278,7 @@
 				0C54F70B15F8BB4D00953CE0 /* GUI.cpp in Sources */,
 				0C54F70D15F8BB4D00953CE0 /* SoundField.cpp in Sources */,
 				0C54F70E15F8BB4D00953CE0 /* SoundFieldMain.cpp in Sources */,
+				0CC1308516045FA400DFB900 /* MyPlot.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -340,7 +342,7 @@
 			isa = XCBuildConfiguration;
 			buildSettings = {
 				ARCHS = "$(ONLY_ACTIVE_ARCH_PRE_XCODE_3_1)";
-				CURRENT_PROJECT_VERSION = 0.0.0.123;
+				CURRENT_PROJECT_VERSION = "";
 				DSTROOT = "/tmp/$(PROJECT_NAME).dst";
 				GCC_PREPROCESSOR_DEFINITIONS = "";
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
@@ -352,7 +354,7 @@
 				MACOSX_DEPLOYMENT_TARGET = 10.5;
 				ONLY_ACTIVE_ARCH_PRE_XCODE_3_1 = "$(NATIVE_ARCH_ACTUAL)";
 				PREBINDING = NO;
-				VERSIONING_SYSTEM = "apple-generic";
+				VERSIONING_SYSTEM = "";
 			};
 			name = Debug;
 		};
@@ -361,7 +363,7 @@
 			buildSettings = {
 				ARCHS = "$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)";
 				ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = "x86_64 i386 ppc";
-				CURRENT_PROJECT_VERSION = 0.0.0.123;
+				CURRENT_PROJECT_VERSION = "";
 				DSTROOT = "/tmp/$(PROJECT_NAME).dst";
 				GCC_PREPROCESSOR_DEFINITIONS = "";
 				GCC_WARN_ABOUT_RETURN_TYPE = YES;
@@ -371,7 +373,7 @@
 				INFOPLIST_PREPROCESS = YES;
 				MACOSX_DEPLOYMENT_TARGET = 10.5;
 				PREBINDING = NO;
-				VERSIONING_SYSTEM = "apple-generic";
+				VERSIONING_SYSTEM = "";
 			};
 			name = Release;
 		};
Binary file Classic Ambisonics Decoder VST.xcodeproj/project.xcworkspace/xcuserdata/momont.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/Classic Ambisonics Decoder VST.xcodeproj/xcuserdata/momont.xcuserdatad/xcschemes/Classic Ambisonics Decoder VST.xcscheme	Mon Sep 10 14:03:14 2012 +0100
+++ b/Classic Ambisonics Decoder VST.xcodeproj/xcuserdata/momont.xcuserdatad/xcschemes/Classic Ambisonics Decoder VST.xcscheme	Sat Sep 15 15:07:00 2012 +0100
@@ -42,6 +42,12 @@
       <PathRunnable
          FilePath = "/Applications/VSTLord.app">
       </PathRunnable>
+      <CommandLineArguments>
+         <CommandLineArgument
+            argument = "-f &quot;/Library/Audio/Plug-Ins/VST/Absynth 5.vst&quot;"
+            isEnabled = "YES">
+         </CommandLineArgument>
+      </CommandLineArguments>
       <AdditionalOptions>
       </AdditionalOptions>
    </LaunchAction>
--- a/Source/GUI.cpp	Mon Sep 10 14:03:14 2012 +0100
+++ b/Source/GUI.cpp	Sat Sep 15 15:07:00 2012 +0100
@@ -34,6 +34,9 @@
 #include "GUI.h"
 #include <stdio.h>
 #include <vstgui.h>
+#define _USE_MATH_DEFINES
+#include <cmath>
+
 
 
 
@@ -52,7 +55,7 @@
     rect.left   = 0;
     rect.top    = 0;
     rect.right  = 545;//plugin_background->getWidth ();
-    rect.bottom = 360;//plugin_background->getHeight ();
+    rect.bottom = 495;//360;//plugin_background->getHeight ();
 }
 
 //------------------------------------------------------------------------------------
@@ -72,12 +75,10 @@
     
 	
 	
-	frameSize (0, 0, 545, 360);
+	frameSize (0, 0, 545, 495);
 	CFrame* newFrame = new CFrame (frameSize, ptr, this);
 	newFrame->setBackgroundColor (CColor(23,25,26,255));
-    
-
-
+    newFrame->setDirty();
 
 	kDisplayText = CColor(255,255,255,255);//(R,G,B,Alpha)
 	kDisplayBackground = CColor(94,102,106,255);//(R,G,B,Alpha)
@@ -107,38 +108,51 @@
 	
 	
     
+    int plotHoz = transformsHoz;
+    int plotEl = transformsEl + knob_mode2->getHeight()/2 + displayOffset + textDepth + 2*transformsSep;
+    int plotSep = transformsSep;
+    plotDisplay(plotHoz, plotEl, plotSep, newFrame);
+    
+    
+    
+    
+    
     //Info Display
     int nameHoz = transformsHoz;
-    int nameEl = transformsEl + knob_mode2->getHeight()/2 + displayOffset + textDepth + 2*transformsSep;
+    int nameEl = plotEl + knob_mode2->getHeight()/2 + displayOffset + textDepth + 2*transformsSep;
     int nameSep = transformsSep;
     nameDisplay(nameHoz, nameEl, nameSep, newFrame);
     
 
     
-    switch ((int)effect->getParameter(103)) {
-        case 0:
-        {
-    
-        }
-        break;
-            
-        case 2:
-        {
+//    switch ((int)effect->getParameter(103)) {
+//        case 0:
+//        {
+//    
+//        }
+//        break;
+//            
+//        case 2:
+//        {
             //Stereo Decoding
             int stereoHoz = transformsHoz;
-            int stereoEl = transformsEl + knob_mode2->getHeight()/2 + displayOffset + textDepth + 2*transformsSep;
+            int stereoEl = plotEl + knob_mode2->getHeight()/2 + displayOffset + textDepth + 2*transformsSep;
             int stereoSep = transformsSep;
             stereoDisplay(stereoHoz, stereoEl, stereoSep, newFrame);
-        }
-        break;
+//        }
+//        break;
+//
+//            
+//
+//    }
 
-            
-
-    }
 
     
+    
+    
 
-
+    
+    
     
 	
 	//Forget Images
@@ -196,22 +210,22 @@
 //------------------------------------------------------------------------------------
 void MyEditor::syncParameters()
 {
-	switch ((int)effect->getParameter(103)) {
-        case 0:
-        {
-            int sync_paramerts [] = {0,1,2,3,4};
-            for (int i = 0; i < 5; i++) //sizeof(syncParameters())
-            setParameter (i, effect->getParameter (sync_paramerts[i]));
-        }
-        break;
-            
-        case 2:
-        {
+//	switch ((int)effect->getParameter(103)) {
+//        case 0:
+//        {
+//            int sync_paramerts [] = {0,1,2,3,4};
+//            for (int i = 0; i < 5; i++) //sizeof(syncParameters())
+//            setParameter (i, effect->getParameter (sync_paramerts[i]));
+//        }
+//        break;
+//            
+//        case 2:
+//        {
             for (int i = 0; i < 10; i++)
             setParameter (i, effect->getParameter (i));
-        }
-        break;
-    }
+//        }
+//        break;
+//    }
     
 }
 
@@ -543,7 +557,7 @@
 	//Mode Value
 	DisplaySize (0, 0, knob_red_blue->getWidth (), textDepth); 
 	DisplaySize.offset (stereoHoz, stereoEl+knob_red_blue->getHeight()/110+displayOffset);
-	paramMode = new CTextLabel (DisplaySize, 0, 0, kCenterText); 
+	paramMode = new CTextLabel (DisplaySize, 0, 0, kCenterText);
 	paramMode->setHoriAlign(kCenterText);
 	paramMode->setFont (kNormalFontVerySmall); 
 	paramMode->setFontColor (kDisplayText); 
@@ -664,9 +678,22 @@
 
 
 //------------------------------------------------------------------------------------
-void MyEditor::stereoPlot(int &plotHoz, int &plotEl)
+void MyEditor::plotDisplay(int &plotHoz, int &plotEl, int &plotSep, CFrame* newFrame)
 {
+    CRect plotArea (0, 0, bRotations->getWidth (),bRotations->getHeight ());
+    plotArea.offset(plotHoz-plotSep/2, plotEl+labelOffset-textDepthLarge);
+    CView* plotBackground = new CView (plotArea);
+    plotBackground->setBackground(bRotations);
+    newFrame->addView (plotBackground);
 	
+    
+    CRect plotSize (0, 0, bRotations->getWidth (), bRotations->getHeight ());
+    plotSize.offset(plotHoz-plotSep/2, plotEl+labelOffset-textDepthLarge);
+    myPlot = new polarPlot(plotSize);
+    //myPlot->setBackground(bRotations);
+    //myPlot->setDirty();
+    newFrame->addView (myPlot);
+    
 }
 
 
@@ -702,7 +729,6 @@
 //------------------------------------------------------------------------------------
 void MyEditor::setParameter (VstInt32 index, float value)
 {
-    //paramModeStereo->setText("tits");
 	//-- setParameter is called when the host automates one of the effects parameter.
 	//-- The UI should reflect this state so we set the value of the control to the new value.
 	//-- VSTGUI will automaticly redraw changed controls in the next idle (as this call happens to be in the process thread).
@@ -712,9 +738,32 @@
         
         //Call getParameterDisplay to get the char to display
         getParameterDisplay (index, &displayText);
+        
+        
+        //Set the polar plot variables if they've changed
+        switch (index) {
+            case kPattern:
+                myPlot->pattern = value;
+                myPlot->setDirty();
+                break;
+               
+            case kWidth:
+                myPlot->width = value*90;
+                myPlot->setDirty();
+                break;
+                
+            case kMode:
+                myPlot->stereo_mode = (int)value;
+                myPlot->setDirty();
+                break;
+                
+            default:
+                break;
+        }
 	}
     else if (frame && index == 100) {
         suspendDisplay();
+        
     }
     else if (frame && index == 101) {
         resumeDisplay();
@@ -776,22 +825,3 @@
 //------------------------------------------------------------------------
 //------------------------------------------------------------------------
 
-
-
-MyPlot::MyPlot(CRect& size, CControlListener* listener, int tag, CBitmap *Background, CPoint& offset)
-: CControl(size, listener, tag)
-{
-    
-}
-
-
-MyPlot::~MyPlot()
-{
-}
-
-
-void MyPlot::draw(CDrawContext* context)
-{
-    
-    
-};
--- a/Source/GUI.h	Mon Sep 10 14:03:14 2012 +0100
+++ b/Source/GUI.h	Sat Sep 15 15:07:00 2012 +0100
@@ -40,21 +40,9 @@
 //#include <stream.h>
 //#include <stdio.h>
 #include "SoundFieldParameters.h"
-//#include "MyPlot.h"
+#include "MyPlot.h"
 
 
-class MyPlot : public CControl
-{
-public:
-	MyPlot(CRect& size, CControlListener* listener, int tag,
-           CBitmap *Background, CPoint& offset);
-	MyPlot();
-    virtual ~MyPlot();
-    
-public:
-	void draw(CDrawContext* piccy);
-};
-
 
 
 
@@ -93,10 +81,7 @@
     CTextLabel*         paramModeStereo;
     
     
-    //CDrawContext*		stereoPlotDraw;
-	
-	MyPlot              *MicPlot;
-    
+    polarPlot*          myPlot;
     
     
     // own function
@@ -104,7 +89,7 @@
 	void zoomDisplay(int &zoomHoz, int &zoomEl, int &zoomSep, CFrame* newFrame);
 	void stereoDisplay(int &stereoHoz, int &stereoEl, int &stereoSep, CFrame* newFrame);
     void nameDisplay(int &nameHoz, int &nameEl, int &nameSep, CFrame* newFrame);
-	void stereoPlot(int &plotHoz, int &plotEl);
+	void plotDisplay(int &plotHoz, int &plotEl, int &plotSep, CFrame* newFrame);
     void suspendDisplay();
     void resumeDisplay();
 	
@@ -162,5 +147,8 @@
 
 
 
+
+
+
 #endif // __MyEditor__
 
--- a/Source/MyPlot.cpp	Mon Sep 10 14:03:14 2012 +0100
+++ b/Source/MyPlot.cpp	Sat Sep 15 15:07:00 2012 +0100
@@ -9,30 +9,183 @@
 #include "MyPlot.h"
 
 
-//MyPlot::MyPlot(CRect& size, CControlListener* listener, int tag, CBitmap* Background, CPoint &offset)
-//: CControl(size, listener, tag)
-//{
-//}
 
 
-MyPlot::MyPlot(CRect& size, CControlListener* listener, int tag, CBitmap *Background, CPoint& offset)
-    : CControl(size, listener, tag)
+
+    
+polarPlot::polarPlot(const CRect &size): CView (size)
 {
+    stereo_mode = 0;
+    pattern = 0.5;
+    width = 45;
+};
     
-}
 
+    
+    
+void polarPlot::draw (CDrawContext* context)
+{
+    //Plot background circle
+    circle(context);
+    
+    //Stereo Mic Patterns
+    leftMicPattern(context);
+    rightMicPattern(context);
+   
 
-MyPlot::~MyPlot()
-{
-}
 
 
-void MyPlot::draw(CDrawContext* context)
-{
-
-
+    
+    setDirty(false);
+    
+    
+    
+    //context->beginDraw();
+    //context->drawRect(size);
+    
+    
+    //        CBitmap *knob_knob = new CBitmap ("360_knob.png");
+    //        context->drawBitmap(knob_knob, size);
+    //
+    //
+    //        //Plot Ellipse
+    //        context->setLineWidth (6);
+    //        CColor eclColor = CColor(120,120,120,255);
+    //        context->setFrameColor(eclColor);
+    //        CRect hi = CRect(20, 20, 130, 130);
+    //        context->drawEllipse(hi);
+    
+    
+    //        double x = 75;
+    //        double y=75;
+    //        context->setFrameColor(kBlueCColor);
+    //        context->setLineWidth (2);
+    //        CRect fatPoint = CRect(x-1,y-1,x+1,y+1);
+    //        context->drawEllipse(fatPoint);
+    
+    
+    //CPoint *myPoint = new CPoint(50,50);
+    //context->drawPolygon(myPoint, 3);
+    
+    //context->setFillColor(eclColor);
+    //context->setFrameColor(eclColor);
+    
+    
+    //context->endDraw();
+    
+    
+    //setDirty (false);
 };
 
 
+void polarPlot::circle(CDrawContext *context)
+{
+    //Plot Ellipse
+    context->setLineWidth (3);
+    CColor eclColor = CColor(120,120,120,125);
+    context->setFrameColor(eclColor);
+    ;
+    CRect circleSize = CRect(size.getCenter().x-size.getHeight()/2*0.82, size.getCenter().y-size.getHeight()/2*0.82, size.getCenter().x+size.getHeight()/2*0.82,  size.getCenter().y+size.getHeight()/2*0.82);
+    context->drawEllipse(circleSize);
+};
 
 
+    
+void polarPlot::leftMicPattern(CDrawContext* context)
+{
+    CColor redColor = CColor(255,0,0,255);
+    double radius, x, y, ptA, ptB;
+    int ang = 0;
+    
+    
+    while (ang<360) {
+        
+        switch (stereo_mode) {
+            case 0:
+            {
+                radius = fabs(pattern+(1-pattern)*(cos((ang-width)/180.0*M_PI))) * size.getHeight()/2*0.8;
+                break;
+            }
+            case 1:
+            {
+                ptA = cos(width/180.0*M_PI) * (pattern + (1-pattern)*(cos(ang/180.0*M_PI)));
+                ptB = sin(width/180.0*M_PI) * (sin(ang/180.0*M_PI));
+                
+                radius = fabs(ptA + ptB) * size.getHeight()/2*0.8;
+                break;
+            }
+                
+            default:
+                break;
+        }
+        
+        
+        
+        x = size.getCenter().x - (sin(ang/180.0*M_PI)*radius); //size.left +
+        y = size.getCenter().y - (cos(ang/180.0*M_PI)*radius); //+ PLOT_OFFSET
+        
+        context->beginDraw();
+        CPoint point = CPoint((int)x, (int)y);
+        context->drawPoint(point, redColor);
+        context->endDraw();
+        
+        
+        ang++;
+    }
+    
+};
+
+
+void polarPlot::rightMicPattern(CDrawContext* context)
+{
+    CColor blueColor = CColor(0,0,255,255);
+    double radius, x, y, ptA, ptB;
+    int ang = 0;
+    
+    while (ang<360) {
+        
+        switch (stereo_mode) {
+            case 0:
+            {
+                radius = fabs(pattern+(1-pattern)*(cos((ang+width)/180.0*M_PI))) * size.getHeight()/2*0.8;
+                break;
+            }
+            case 1:
+            {
+                ptA = cos(width/180.0*M_PI) * (pattern + (1-pattern)*(cos(ang/180.0*M_PI)));
+                ptB = sin(width/180.0*M_PI) * (sin(ang/180.0*M_PI));
+                
+                radius = fabs(ptA - ptB) * size.getHeight()/2*0.8;
+                break;
+            }
+                
+            default:
+                break;
+        }
+
+        
+        
+        x = size.getCenter().x - (sin(ang/180.0*M_PI)*radius); //size.left +
+        y = size.getCenter().y - (cos(ang/180.0*M_PI)*radius); //+ PLOT_OFFSET
+        
+        context->beginDraw();
+        CPoint point = CPoint((int)x, (int)y);
+        context->drawPoint(point, blueColor);
+        context->endDraw();
+        
+        
+        ang++;
+    }
+};
+    
+    
+//void polarPlot::setBackgroundColour (const CColor& c)
+//{
+//    backgroundColour = c;
+//};
+
+
+
+
+
+
--- a/Source/MyPlot.h	Mon Sep 10 14:03:14 2012 +0100
+++ b/Source/MyPlot.h	Sat Sep 15 15:07:00 2012 +0100
@@ -14,20 +14,36 @@
 #ifndef __vstgui__
 #include "vstgui.h"
 #endif
+//#define PLOT_OFFSET  75
 
 
 
-
-class MyPlot : public CControl
+class polarPlot : public CView
 {
 public:
-	MyPlot(CRect& size, CControlListener* listener, int tag,
-           CBitmap *Background, CPoint& offset);
-	MyPlot();
-    virtual ~MyPlot();
     
-public:
-	void draw(CDrawContext* piccy);
+    polarPlot(const CRect &size);
+    
+    int     stereo_mode;
+    double  pattern;
+    double  width;
+    
+    
+    void draw (CDrawContext* context);
+    void circle(CDrawContext* context);
+    void leftMicPattern(CDrawContext* context);
+    void rightMicPattern(CDrawContext* context);
+    
+    
+        
+    //void setBackgroundColour (const CColor& c) { backgroundColour = c; }
+    //void setPoint (CPoint& p) { myPoint = p; }
+    
+    
+protected:
+	//CColor backgroundColour;
+    //CPoint myPoint;
 };
 
 
+