Mercurial > hg > ambi-plugin
changeset 8:d967dd1eafe8
Code update for effect and editor.
author | martinm_home <martin.morrell@eecs.qmul.ac.uk> |
---|---|
date | Sun, 16 Sep 2012 23:25:54 +0100 |
parents | f7ec6d983ec0 |
children | 53f99cbc5dbd |
files | Classic Ambisonics Decoder VST.xcodeproj/project.pbxproj Classic Ambisonics Decoder VST.xcodeproj/project.xcworkspace/xcuserdata/momont.xcuserdatad/UserInterfaceState.xcuserstate Resources/mode5_knob.knob Resources/mode5_knob.png Source/Decoder.cpp Source/Decoder.h Source/GUI.cpp Source/GUI.h Source/MyPlot.cpp Source/MyPlot.h Source/SoundField.cpp Source/SoundField.h Source/SoundFieldParameters.h |
diffstat | 13 files changed, 870 insertions(+), 131 deletions(-) [+] |
line wrap: on
line diff
--- a/Classic Ambisonics Decoder VST.xcodeproj/project.pbxproj Sat Sep 15 15:07:00 2012 +0100 +++ b/Classic Ambisonics Decoder VST.xcodeproj/project.pbxproj Sun Sep 16 23:25:54 2012 +0100 @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 0C22E51C16067A170061F1EB /* mode5_knob.png in Resources */ = {isa = PBXBuildFile; fileRef = 0C22E51B16067A170061F1EB /* mode5_knob.png */; }; 0C54F6EC15F8B97900953CE0 /* vstgui_mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0C54F6EB15F8B97900953CE0 /* vstgui_mac.mm */; }; 0C54F6F015F8B99400953CE0 /* aeffguieditor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0C54F6ED15F8B99400953CE0 /* aeffguieditor.cpp */; }; 0C54F70A15F8BB4D00953CE0 /* Decoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0C54F70015F8BB4C00953CE0 /* Decoder.cpp */; }; @@ -34,6 +35,7 @@ /* Begin PBXFileReference section */ 08EA7FFBFE8413EDC02AAC07 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; }; + 0C22E51B16067A170061F1EB /* mode5_knob.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = mode5_knob.png; path = Resources/mode5_knob.png; sourceTree = "<group>"; }; 0C54F6EB15F8B97900953CE0 /* vstgui_mac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = vstgui_mac.mm; path = "../../../../../Users/momont/libraries/vstgui-4.0.1/vstgui_mac.mm"; sourceTree = "<group>"; }; 0C54F6ED15F8B99400953CE0 /* aeffguieditor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = aeffguieditor.cpp; path = "../../../../../Users/momont/libraries/vstgui-4.0.1/plugin-bindings/aeffguieditor.cpp"; sourceTree = "<group>"; }; 0C54F6EE15F8B99400953CE0 /* aeffguieditor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = aeffguieditor.h; path = "../../../../../Users/momont/libraries/vstgui-4.0.1/plugin-bindings/aeffguieditor.h"; sourceTree = "<group>"; }; @@ -112,6 +114,7 @@ 089C167CFE841241C02AAC07 /* Resources */ = { isa = PBXGroup; children = ( + 0C22E51B16067A170061F1EB /* mode5_knob.png */, 0C54F72115F8BBA500953CE0 /* rotations.png */, 0C54F70F15F8BB7500953CE0 /* 360_knob.png */, 0C54F71015F8BB7500953CE0 /* blue_knob.png */, @@ -243,6 +246,7 @@ 0C54F71F15F8BB7500953CE0 /* stereo.png in Resources */, 0C54F72015F8BB7500953CE0 /* zoom.png in Resources */, 0C54F72215F8BBA500953CE0 /* rotations.png in Resources */, + 0C22E51C16067A170061F1EB /* mode5_knob.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; };
Binary file Classic Ambisonics Decoder VST.xcodeproj/project.xcworkspace/xcuserdata/momont.xcuserdatad/UserInterfaceState.xcuserstate has changed
--- a/Source/Decoder.cpp Sat Sep 15 15:07:00 2012 +0100 +++ b/Source/Decoder.cpp Sun Sep 16 23:25:54 2012 +0100 @@ -31,6 +31,128 @@ //Overall Functions +int Decoder::processDecoder(double &w, double &x, double &y, double &z) +{ + switch (decoderMode) { + case 1: + monoDecoder(w, x, y, z); + if (channelOrder==0) { + output[0]=outputC; + return 1; + } + else if (channelOrder==1) + output[0]=0; + output[1]=0; + output[2]=outputC; + output[3]=0; + output[4]=0; + output[5]=0; + return 6; + break; + + case 2: + stereoDecoder(w, x, y, z); + if (channelOrder==0) { + output[0]=outputL; + output[1]=outputR; + return 2; + } + else if (channelOrder==1) + output[0]=outputL; + output[1]=outputR; + output[2]=0; + output[3]=0; + output[4]=0; + output[5]=0; + return 6; + break; + + case 3: + twoOneDecoder(w, x, y, z); + if (channelOrder==0) { + output[0]=outputL; + output[1]=outputR; + output[2]=outputS; + return 3; + } + else if (channelOrder==1) + output[0]=outputL; + output[1]=outputR; + output[2]=0; + output[3]=outputS; + output[4]=0; + output[5]=0; + return 6; + break; + + case 4: + quadDecoder(w, x, y, z); + if (channelOrder==0) { + output[0]=outputL; + output[1]=outputR; + output[2]=outputSL; + output[3]=outputSR; + return 4; + } + else if (channelOrder==1) + output[0]=outputL; + output[1]=outputR; + output[2]=0; + output[3]=0; + output[4]=outputSL; + output[5]=outputSR; + return 6; + break; + + case 5: + fiveDecoder(w, x, y, z); + if (channelOrder==0) { + output[0]=outputL; + output[1]=outputR; + output[2]=outputC; + output[3]=outputSL; + output[4]=outputSR; + return 5; + } + else if (channelOrder==1) + output[0]=outputL; + output[1]=outputR; + output[2]=outputC; + output[3]=0; + output[4]=outputSL; + output[5]=outputSR; + return 6; + break; + + case 6: + fiveOneDecoder(w, x, y, z); + if (channelOrder==0) { + output[0]=outputL; + output[1]=outputR; + output[2]=outputC; + output[3]=outputS; + output[4]=outputSL; + output[5]=outputSR; + return 6; + } + else if (channelOrder==1) + output[0]=outputL; + output[1]=outputR; + output[2]=outputC; + output[3]=outputS; + output[4]=outputSL; + output[5]=outputSR; + return 6; + break; + + default: + return 0; + break; + } +}; + + + void Decoder::monoDecoder(double &w, double &x, double &y, double &z) { //Sound field rotations. Only called if the value is not 0 @@ -198,7 +320,7 @@ -void Decoder::lrcsDecoder(double &w, double &x, double &y, double &z) +void Decoder::quadDecoder(double &w, double &x, double &y, double &z) { //Sound field rotations. Only called if the value is not 0 if (Rotate!=0.0f) @@ -582,6 +704,8 @@ bHF[0] = 1/denominator; bHF[1] = -2 * bHF[0]; bHF[2] = bHF[0]; + + clearFilter(); };
--- a/Source/Decoder.h Sat Sep 15 15:07:00 2012 +0100 +++ b/Source/Decoder.h Sun Sep 16 23:25:54 2012 +0100 @@ -21,6 +21,7 @@ //Decoder Speaker Layout int decoderMode; //Decoder mode, set to same as number of outputs + int channelOrder; //Natural or 5.1 ordering //Front Stereo Speaker Decoding & Reverb double Width; //0-90 degrees @@ -47,6 +48,7 @@ double surPattern; //Rear mics pattern double surWidth; //Rear mics width double surGain; //Rear mics gain + double output[6]; //Final Output @@ -72,12 +74,8 @@ //Overall Decoding Functions - void monoDecoder(double &w, double &x, double &y, double &z); //Decode to mono - void stereoDecoder(double &w, double &x, double &y, double &z); //Decode to stereo - void twoOneDecoder(double &w, double &x, double &y, double &z); //Decode to stereo - void lrcsDecoder(double &w, double &x, double &y, double &z); //Decode to LRCS - void fiveDecoder(double &w, double &x, double &y, double &z); //Decode to 5.0 - void fiveOneDecoder(double &w, double &x, double &y, double &z); //Decode to 5.1 + int processDecoder(double &w, double &x, double &y, double &z); //Called fucntion to do the decoding + //private: @@ -115,4 +113,12 @@ void filterCoefs(); void filterLF(); void filterHF(double &w, double &x, double &y, double &z); + + //Decoder Types + void monoDecoder(double &w, double &x, double &y, double &z); //Decode to mono + void stereoDecoder(double &w, double &x, double &y, double &z); //Decode to stereo + void twoOneDecoder(double &w, double &x, double &y, double &z); //Decode to stereo + void quadDecoder(double &w, double &x, double &y, double &z); //Decode to LRCS + void fiveDecoder(double &w, double &x, double &y, double &z); //Decode to 5.0 + void fiveOneDecoder(double &w, double &x, double &y, double &z); //Decode to 5.1 }; \ No newline at end of file
--- a/Source/GUI.cpp Sat Sep 15 15:07:00 2012 +0100 +++ b/Source/GUI.cpp Sun Sep 16 23:25:54 2012 +0100 @@ -69,6 +69,7 @@ knob_red_blue = new CBitmap ("red_blue_knob.png"); knob_mode2 = new CBitmap ("mode2_knob.png"); knob_mode4 = new CBitmap ("mode4_knob.png"); + knob_mode5 = new CBitmap ("mode5_knob.png"); bRotations = new CBitmap ("rotations.png"); bZoom = new CBitmap ("zoom.png"); @@ -108,12 +109,19 @@ + //Polar Plot int plotHoz = transformsHoz; int plotEl = transformsEl + knob_mode2->getHeight()/2 + displayOffset + textDepth + 2*transformsSep; int plotSep = transformsSep; plotDisplay(plotHoz, plotEl, plotSep, newFrame); + //Settings + int settingsHoz = transformsHoz + 3*knob_red_blue->getWidth() + 2.5*transformsSep; + int settingsEl = transformsEl + knob_mode2->getHeight()/2 + displayOffset + textDepth + 2*transformsSep; + int settingsSep = transformsSep; + settingsDisplay(settingsHoz, settingsEl, settingsSep, newFrame); + @@ -179,6 +187,16 @@ controls[kMode] = knobMode; controls[kRearVerb] = knobRearVerb; controls[kHiVerb] = knobHiVerb; + //controls[kCentrePattern] = knobCentrePattern; + //controls[kCentreGain] = knobGain; + //controls[kSubGain] = knobSubGain; + //controls[kFc] = knobFc; + //controls[kSurroundMode] = knobSurMode; + //controls[kSurroundPattern] = knobSurPattern; + //controls[kSurroundWidth] = knobSurWidth; + //controls[kSurroundGain] = knobSurGain; + controls[kDecoderMode] = knobDecoder; + @@ -221,7 +239,7 @@ // // case 2: // { - for (int i = 0; i < 10; i++) + for (int i = 0; i < 10; i++)//kNumParameters setParameter (i, effect->getParameter (i)); // } // break; @@ -661,7 +679,7 @@ LabelSize.offset(0, -20); bitMode = new CTextLabel(LabelSize, 0, 0, kLeftText); - int b = effect->getParameter(103); //102 + int b = effect->getParameter(102); sprintf(text,"Bit Mode: %d", b); bitMode->setText(text); bitMode->setFont (kNormalFontSmall); @@ -680,14 +698,14 @@ //------------------------------------------------------------------------------------ void MyEditor::plotDisplay(int &plotHoz, int &plotEl, int &plotSep, CFrame* newFrame) { - CRect plotArea (0, 0, bRotations->getWidth (),bRotations->getHeight ()); + CRect plotArea (0, 0, bZoom->getWidth (),bZoom->getHeight ()); plotArea.offset(plotHoz-plotSep/2, plotEl+labelOffset-textDepthLarge); CView* plotBackground = new CView (plotArea); - plotBackground->setBackground(bRotations); + plotBackground->setBackground(bZoom); newFrame->addView (plotBackground); - CRect plotSize (0, 0, bRotations->getWidth (), bRotations->getHeight ()); + CRect plotSize (0, 0, bZoom->getWidth (), bZoom->getHeight ()); plotSize.offset(plotHoz-plotSep/2, plotEl+labelOffset-textDepthLarge); myPlot = new polarPlot(plotSize); //myPlot->setBackground(bRotations); @@ -698,6 +716,88 @@ //------------------------------------------------------------------------------------ +void MyEditor::settingsDisplay(int &settingsHoz, int &settingsEl, int &settingsSep, CFrame* newFrame) +{ + CRect plotArea (0, 0, bRotations->getWidth (),bRotations->getHeight ()); + plotArea.offset(settingsHoz-settingsSep/2, settingsEl+labelOffset-textDepthLarge); + CView* settingsBackground = new CView (plotArea); + settingsBackground->setBackground(bRotations); + newFrame->addView (settingsBackground); + + + //Label Section + LabelSize (0, 0, bRotations->getWidth (), textDepthLarge); + LabelSize.offset (settingsHoz-settingsSep/2, settingsEl+labelOffset - textDepthLarge); + CTextLabel* labelSettings = new CTextLabel (LabelSize, 0, 0, kCenterText); + labelSettings->setFont (kNormalFontBig); + labelSettings->setFontColor (kLabelText); + labelSettings->setBackColor (kBlank); + labelSettings->setFrameColor (kBlank); + labelSettings->setText("Settings"); + newFrame->addView (labelSettings); + + + + //Decoder Mode Knob + r (0, 0, knob_mode5->getWidth (), knob_mode5->getHeight () / 5); + r.offset(settingsHoz, settingsEl); + knobDecoder = new CHorizontalSwitch (r, this, kDecoderMode, 5, knob_mode5->getHeight () / 5, 5, knob_mode5, CPoint (0, 0)); + newFrame->addView (knobDecoder); + knobDecoder->forget (); + + + //Label Decoder Mode + LabelSize (0, 0, knob_mode5->getWidth (), textDepth); + LabelSize.offset (settingsHoz, settingsEl+labelOffset); + CTextLabel* labelDecoder = new CTextLabel (LabelSize, 0, 0, kCenterText); + labelDecoder->setFont (kNormalFontSmall); + labelDecoder->setFontColor (kLabelText); + labelDecoder->setBackColor (kBlank); + labelDecoder->setFrameColor (kBlank); + labelDecoder->setText("Decoding"); + newFrame->addView (labelDecoder); + + //Decoder Mode Value + DisplaySize (0, 0, knob_mode5->getWidth (), textDepth); + DisplaySize.offset (settingsHoz, settingsEl+knob_mode5->getHeight()/5); + paramDecoder = new CTextLabel (DisplaySize, 0, 0, kCenterText); + paramDecoder->setHoriAlign(kCenterText); + paramDecoder->setFont (kNormalFontVerySmall); + paramDecoder->setFontColor (kDisplayText); + paramDecoder->setBackColor (kDisplayBackground); + paramDecoder->setFrameColor (kBlackCColor); + newFrame->addView (paramDecoder); + paramDecoder->forget(); + + +// //--COptionMenu-------------------------------------- +// CRect size (0, 0, 50, 14); +// size.offset (settingsHoz, settingsEl); +// +// long style = k3DIn | kMultipleCheckStyle; +// settingsMenu = new COptionMenu (size, this, kDecoderMode, 0, 0, style); +// if (settingsMenu) +// { +// settingsMenu->setFont (kNormalFontSmall); +// settingsMenu->setFontColor (kLabelText); +// settingsMenu->setBackColor (kWhiteCColor); +// settingsMenu->setFrameColor (kLabelText); +// settingsMenu->setHoriAlign (kLeftText); +// settingsMenu->addEntry ("Stereo");//2 +// settingsMenu->addEntry ("2.1");//3 +// settingsMenu->addEntry ("LCRS");//4 +// settingsMenu->addEntry ("5.0");//5 +// settingsMenu->addEntry ("5.1");//6 +// +// +// newFrame->addView (settingsMenu); +// } + + +} + + +//------------------------------------------------------------------------------------ void MyEditor::suspendDisplay() { suspend = new CTextLabel(frameSize, 0, 0, kCenterText); @@ -734,26 +834,89 @@ //-- VSTGUI will automaticly redraw changed controls in the next idle (as this call happens to be in the process thread). if (frame && index < kNumParameters) { //First write the value into the GUI value container - controls[index]->setValue (value); + controls[index]->setValue (value); + //Call getParameterDisplay to get the char to display - getParameterDisplay (index, &displayText); + getParameterDisplay (index, &displayText); //Will this work with no switch? - //Set the polar plot variables if they've changed + //Set the polar plot variables if they've changed and the decoder mode display switch (index) { + + + //Second anything that affests the plot case kPattern: - myPlot->pattern = value; + myPlot->pattern = (double)value; myPlot->setDirty(); break; case kWidth: - myPlot->width = value*90; + myPlot->width = (double)value*90; myPlot->setDirty(); break; case kMode: - myPlot->stereo_mode = (int)value; + if (value<=0.5f) { + myPlot->stereo_mode = 0; + } + else { + myPlot->stereo_mode = 1; + } + myPlot->setDirty(); + break; + + case kCentrePattern: + myPlot->centre_pattern = (double)value; + myPlot->setDirty(); + break; + + case kCentreGain: + myPlot->centre_gain = (double)((value*24)-18); + myPlot->setDirty(); + break; + + case kSurroundMode: + if (value<=0.5f) { + myPlot->surround_mode = 0; + } + else { + myPlot->surround_mode = 1; + } + myPlot->setDirty(); + break; + + case kSurroundPattern: + myPlot->surround_pattern = (double)value; + myPlot->setDirty(); + break; + + case kSurroundWidth: + myPlot->surround_width = (double)value*90; + myPlot->setDirty(); + break; + + case kSurroundGain: + myPlot->surround_gain = (double)((value*24)-18); + myPlot->setDirty(); + break; + + case kDecoderMode: + if (value<=0.2f) { + myPlot->decoder_mode = 2; //Stereo + } + else if (value>0.2f && value<=0.4f) { + myPlot->decoder_mode = 3; //2.1 + } + else if (value>0.4f && value<=0.6f) { + myPlot->decoder_mode = 4; //LCRS + } + else if (value>0.6f && value<=0.8f) { + myPlot->decoder_mode = 5; //5.0 + } + else if (value>0.8f && value<=1.0f) { + myPlot->decoder_mode = 6; //5.1 + } myPlot->setDirty(); break; @@ -768,7 +931,7 @@ else if (frame && index == 101) { resumeDisplay(); } - + } @@ -809,6 +972,13 @@ case kHiVerb : paramHiVerb->setText(text); break; + + case kDecoderMode: + paramDecoder->setText(text); + break; + + default: + break; } }
--- a/Source/GUI.h Sat Sep 15 15:07:00 2012 +0100 +++ b/Source/GUI.h Sun Sep 16 23:25:54 2012 +0100 @@ -80,6 +80,7 @@ CTextLabel* paramHiVerb; CTextLabel* paramModeStereo; + CTextLabel* paramDecoder; polarPlot* myPlot; @@ -90,6 +91,7 @@ void stereoDisplay(int &stereoHoz, int &stereoEl, int &stereoSep, CFrame* newFrame); void nameDisplay(int &nameHoz, int &nameEl, int &nameSep, CFrame* newFrame); void plotDisplay(int &plotHoz, int &plotEl, int &plotSep, CFrame* newFrame); + void settingsDisplay(int &settingsHoz, int &settingsEl, int &settingsSep, CFrame* newFrame); void suspendDisplay(); void resumeDisplay(); @@ -113,6 +115,7 @@ CHorizontalSwitch *knobMode; CAnimKnob *knobRearVerb; CAnimKnob *knobHiVerb; + CHorizontalSwitch *knobDecoder; CRect frameSize; CRect DisplaySize; @@ -131,6 +134,7 @@ CBitmap* knob_red_blue; CBitmap* knob_mode2; CBitmap* knob_mode4; + CBitmap* knob_mode5; CBitmap *bRotations; CBitmap *bZoom;
--- a/Source/MyPlot.cpp Sat Sep 15 15:07:00 2012 +0100 +++ b/Source/MyPlot.cpp Sun Sep 16 23:25:54 2012 +0100 @@ -18,6 +18,13 @@ stereo_mode = 0; pattern = 0.5; width = 45; + centre_pattern = 0.5; + centre_gain = 0; + surround_mode = 0; + surround_pattern = 0.5; + surround_width = 60; + surround_mode = 0; + decoder_mode = 2; }; @@ -28,9 +35,53 @@ //Plot background circle circle(context); - //Stereo Mic Patterns - leftMicPattern(context); - rightMicPattern(context); + + //Plot Needed Polar Patterns + switch (decoder_mode) { + case 2: + //Stereo Mic Patterns + leftMicPattern(context); + rightMicPattern(context); + break; + + case 3: + //2.1 Mic Patterns + leftMicPattern(context); + rightMicPattern(context); + break; + + case 4: + //Quad Mic Patterns + leftMicPattern(context); + rightMicPattern(context); + lsMicPattern(context); + rsMicPattern(context); + break; + + case 5: + //5.0 Mic Patterns + leftMicPattern(context); + rightMicPattern(context); + centreMicPattern(context); + lsMicPattern(context); + rsMicPattern(context); + break; + + case 6: + //5.1 Mic Patterns + leftMicPattern(context); + rightMicPattern(context); + centreMicPattern(context); + lsMicPattern(context); + rsMicPattern(context); + break; + + + default: + break; + } + + @@ -129,10 +180,8 @@ context->drawPoint(point, redColor); context->endDraw(); - ang++; } - }; @@ -165,26 +214,128 @@ - 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 + x = size.getCenter().x - (sin(ang/180.0*M_PI)*radius); + y = size.getCenter().y - (cos(ang/180.0*M_PI)*radius); context->beginDraw(); CPoint point = CPoint((int)x, (int)y); context->drawPoint(point, blueColor); context->endDraw(); + ang++; + } +}; + + + +void polarPlot::centreMicPattern(CDrawContext* context)//To finish updating +{ + CColor yellowColor = CColor(255,255,0,255); + double radius, x, y; + int ang = 0; + + + while (ang<360) { + radius = fabs(centre_pattern+(1-centre_pattern)*(cos((ang)/180.0*M_PI))) * size.getHeight()/2*0.8; + + + x = size.getCenter().x - (sin(ang/180.0*M_PI)*radius*pow(10,(centre_gain/20))); //size.left + + y = size.getCenter().y - (cos(ang/180.0*M_PI)*radius*pow(10,(centre_gain/20))); //+ PLOT_OFFSET + + context->beginDraw(); + CPoint point = CPoint((int)x, (int)y); + context->drawPoint(point, yellowColor); + context->endDraw(); ang++; } }; + + + + + +void polarPlot::lsMicPattern(CDrawContext* context) +{ + CColor greenColor = CColor(0,255,0,255); + double radius, x, y, ptA, ptB; + int ang = 0; -//void polarPlot::setBackgroundColour (const CColor& c) -//{ -// backgroundColour = c; -//}; + while (ang<360) { + switch (surround_mode) { + case 0: + { + radius = fabs(surround_pattern+(1-surround_pattern)*(cos((ang-surround_width-180)/180.0*M_PI))) * size.getHeight()/2*0.8; + break; + } + case 1: + { + ptA = cos(surround_width/180.0*M_PI) * (surround_pattern + (1-surround_pattern)*(cos((ang-180)/180.0*M_PI))); + ptB = sin(surround_width/180.0*M_PI) * (sin((ang-180)/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*pow(10,(surround_gain/20))); + y = size.getCenter().y - (cos(ang/180.0*M_PI)*radius*pow(10,(surround_gain/20))); + + context->beginDraw(); + CPoint point = CPoint((int)x, (int)y); + context->drawPoint(point, greenColor); + context->endDraw(); + + ang++; + } +}; +void polarPlot::rsMicPattern(CDrawContext* context) +{ + CColor brownColor = CColor(139,69,19,255); + double radius, x, y, ptA, ptB; + int ang = 0; + + while (ang<360) { + switch (surround_mode) { + case 0: + { + radius = fabs(surround_pattern+(1-surround_pattern)*(cos((ang-180+surround_width)/180.0*M_PI))) * size.getHeight()/2*0.8; + break; + } + case 1: + { + ptA = cos(surround_width/180.0*M_PI) * (surround_pattern + (1-surround_pattern)*(cos((ang-180)/180.0*M_PI))); + ptB = sin(surround_width/180.0*M_PI) * (sin((ang-180)/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*pow(10,(surround_gain/20))); + y = size.getCenter().y - (cos(ang/180.0*M_PI)*radius*pow(10,(surround_gain/20))); + + context->beginDraw(); + CPoint point = CPoint((int)x, (int)y); + context->drawPoint(point, brownColor); + context->endDraw(); + + ang++; + } +};
--- a/Source/MyPlot.h Sat Sep 15 15:07:00 2012 +0100 +++ b/Source/MyPlot.h Sun Sep 16 23:25:54 2012 +0100 @@ -14,35 +14,41 @@ #ifndef __vstgui__ #include "vstgui.h" #endif -//#define PLOT_OFFSET 75 - class polarPlot : public CView { public: - + //Constructor polarPlot(const CRect &size); + //Variables int stereo_mode; double pattern; double width; + double centre_pattern; + double centre_gain; + int surround_mode; + double surround_pattern; + double surround_width; + double surround_gain; + int decoder_mode; + //Functions + void draw (CDrawContext* context); + void circle(CDrawContext* context); + void leftMicPattern(CDrawContext* context); + void rightMicPattern(CDrawContext* context); + void centreMicPattern(CDrawContext* context); + void lsMicPattern(CDrawContext* context); + void rsMicPattern(CDrawContext* context); - 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; + };
--- a/Source/SoundField.cpp Sat Sep 15 15:07:00 2012 +0100 +++ b/Source/SoundField.cpp Sun Sep 16 23:25:54 2012 +0100 @@ -45,21 +45,10 @@ //Set the number of input and output channels setNumInputs (4); // 4 Channel Classic B-Format Input - setNumOutputs (2); // MAX_CHANNELS 5.1 Output - - - // We initialize the arrangements to default values. - // Nevertheless, the host should modify them via - // appropriate calls to setSpeakerArrangement. - //allocateArrangement (&plugInput, MAX_CHANNELS); - //plugInput->type = kSpeakerArr51; - - //allocateArrangement (&plugOutput, 2); // MAX_CHANNELS, now 2 for stereo - //plugOutput->type = kSpeakerArrStereo; // kSpeakerArr51, now set output to stereo - + setNumOutputs (6); // MAX_CHANNELS 5.1 Output - setUniqueID ('MMa2'); // this should be unique, use the Steinberg web page for plugin Id registration + setUniqueID ('MMca'); // this should be unique, use the Steinberg web page for plugin Id registration if(setProcessPrecision(kVstProcessPrecision64)){ @@ -100,7 +89,19 @@ fZoomMethod = 0.f; fRearVerb = 0.f; fHiVerb = 0.f; + fCentrePattern =0.5f; + fCentreGain = 0.75f; + fSubGain = 0.75f; + fFc = 5.0f/11.0f; + fSurroundMode = 0.f; + fSurroundPattern = 0.5; + fSurroundWidth = 2.f/3.f; + fSurroundGain = 0.75f; + fDecoderMode = 0.f; + fChannelOrder = 0.f; + + // myDecoder parameters myDecoder.Rotate=0.0; myDecoder.Tilt=0.0; myDecoder.Tumble=0.0; @@ -111,23 +112,27 @@ myDecoder.Mode=0; myDecoder.RearVerb=-100; myDecoder.HiVerb=-100; + myDecoder.surMode=0; + myDecoder.surPattern=0.5; + myDecoder.surWidth=60.0; + myDecoder.subGain=0.0; + myDecoder.Fc = 120; + myDecoder.centrePattern=0.5; + myDecoder.centreGain=0.0; + myDecoder.subGain=0.0; + myDecoder.Fs = sampleRate; + myDecoder.filterCoefs(); + myDecoder.decoderMode=2; //Default mode is Stereo + myDecoder.channelOrder=0; + + + // Zero up decoder outputs as a safety myDecoder.outputL=0.0; myDecoder.outputR=0.0; myDecoder.outputC=0.0; myDecoder.outputS=0.0; myDecoder.outputSL=0.0; myDecoder.outputSR=0.0; - myDecoder.surMode=0; - myDecoder.surPattern=0.5; - myDecoder.surWidth=60.0; - myDecoder.subGain=0.0; - myDecoder.centrePattern=0.5; - myDecoder.centreGain=0.0; - myDecoder.subGain=0.0; - myDecoder.Fs = sampleRate; - myDecoder.Fc = 120; - myDecoder.filterCoefs(); - myDecoder.decoderMode=0; //Default mode to user set output, let host call over it. } @@ -162,29 +167,10 @@ //------------------------------------------------------------------------ bool SoundField::setSpeakerArrangement (VstSpeakerArrangement* pluginInput, VstSpeakerArrangement* pluginOutput) -{ - if (pluginOutput->type == kSpeakerArrStereo) - { - myDecoder.decoderMode=2; - } - else if (pluginOutput->type == kSpeakerArr40Cine) - { - myDecoder.decoderMode=4; - } - else if (pluginOutput->type == kSpeakerArr50 ) - { - myDecoder.decoderMode=5; - } - else if (pluginOutput->type == kSpeakerArr51 ) - { - myDecoder.decoderMode=6; - } - else - { - myDecoder.decoderMode=0; //Unknown speaker layout type, user will get drop down menu. - } - - +{ + numberInputs = pluginInput->numChannels; + numberOutputs = pluginOutput->numChannels; + return true; } @@ -328,6 +314,76 @@ myDecoder.HiVerb= -36+(double)value*36; } break; + case kCentrePattern: + fCentrePattern = value; + myDecoder.centrePattern = (double)value; + break; + case kCentreGain: + fCentreGain = value; + myDecoder.centreGain = ((double)value*24-18); + break; + case kSubGain: + fSubGain = value; + myDecoder.subGain = ((double)value*24-18); + break; + case kFc: + fFc = value; + myDecoder.Fc = (int)((value*220)+20); + myDecoder.filterCoefs(); + break; + case kSurroundMode: + fSurroundMode = value; + if (value<=0.5f) { + myDecoder.surMode = 0; + } + else { + myDecoder.surMode = 1; + } + break; + case kSurroundPattern: + fSurroundPattern = value; + myDecoder.surPattern = (double)value; + break; + case kSurroundWidth: + fSurroundWidth = value; + myDecoder.surWidth = (double)value*90; + break; + case kSurroundGain: + fSurroundGain = value; + myDecoder.surGain = ((double)value*24-18); + break; + case kDecoderMode: + fDecoderMode = value; + if (value<=0.2f) { + myDecoder.decoderMode = 2; //Stereo + } + else if (value>0.2f && value<=0.4f) { + myDecoder.decoderMode = 3; //2.1 + } + else if (value>0.4f && value<=0.6f) { + myDecoder.decoderMode = 4; //Quad + } + else if (value>0.6f && value<=0.8f) { + myDecoder.decoderMode = 5; //5.0 + } + else if (value>0.8f && value<=1.0f) { + myDecoder.decoderMode = 6; //5.1 + } + break; + + case kChannelOrder: + fChannelOrder = value; + if (value<=0.5f) { + myDecoder.channelOrder = 0; //Natural Outputs + } + else { + myDecoder.channelOrder = 1; //5.1 Outputs + } + break; + + + default: + break; } if (editor){ ((AEffGUIEditor*)editor)->setParameter (index, value); @@ -373,12 +429,47 @@ case kHiVerb : returnFloat = fHiVerb; break; + case kCentrePattern: + returnFloat = fCentrePattern; + break; + case kCentreGain: + returnFloat = fCentreGain; + break; + case kSubGain: + returnFloat = fSubGain; + break; + case kFc: + returnFloat = fFc; + break; + case kSurroundMode: + returnFloat = fSurroundMode; + break; + case kSurroundPattern: + returnFloat = fSurroundPattern; + break; + case kSurroundWidth: + returnFloat = fSurroundWidth; + break; + case kSurroundGain: + returnFloat = fSurroundGain; + break; + case kDecoderMode: + returnFloat = fDecoderMode; + break; + case kChannelOrder: + returnFloat = fChannelOrder; + break; + + case 102: returnFloat = bits; break; case 103: returnFloat = myDecoder.decoderMode; break; + + default: + break; } return returnFloat; //Returns the chosen Parameters value } @@ -426,6 +517,39 @@ case kHiVerb : strcpy(label, "HiVerb"); break; + case kCentrePattern: + strcpy(label, "Ctr. Pattern"); + break; + case kCentreGain: + strcpy(label, "Ctr. Gain"); + break; + case kSubGain: + strcpy(label, "Sub. Gain"); + break; + case kFc: + strcpy(label, "Sub. Xover"); + break; + case kSurroundMode: + strcpy(label, "Sur. Mode"); + break; + case kSurroundPattern: + strcpy(label, "Sur. Pattern"); + break; + case kSurroundWidth: + strcpy(label, "Sur. Width"); + break; + case kSurroundGain: + strcpy(label, "Sur. Gain"); + break; + case kDecoderMode: + strcpy(label, "Dec. Mode"); + break; + case kChannelOrder: + strcpy(label, "Ch. Order"); + break; + + default: + break; } } @@ -465,8 +589,6 @@ else { strcpy(text, "Omni."); } - - break; case kRotate : sprintf (text, "%.1f\u00B0", myDecoder.Rotate); @@ -514,6 +636,97 @@ strcpy(text, "Off"); } break; + case kCentrePattern: + if (myDecoder.centrePattern<=0.125) { + strcpy(text, "Fig-of-8"); + } + else if (myDecoder.centrePattern>0.125 && myDecoder.centrePattern<=0.375) { + strcpy(text, "Hyper-Card."); + } + else if (myDecoder.centrePattern>0.375 && myDecoder.centrePattern<=0.625) { + strcpy(text, "Cardioid"); + } + else if (myDecoder.centrePattern>0.625 && myDecoder.centrePattern<=0.875) { + strcpy(text, "Sub-Card."); + } + else { + strcpy(text, "Omni."); + } + break; + case kCentreGain: + sprintf (text, "%.2fdB", myDecoder.centreGain); + break; + case kSubGain: + sprintf (text, "%.2fdB", myDecoder.subGain); + break; + case kFc: + sprintf (text, "%dHz", myDecoder.Fc); + break; + case kSurroundMode: + switch (myDecoder.surMode) { + case 0 : + strcpy(text, "XY"); + break; + case 1 : + strcpy(text, "MS"); + break; + } + break; + case kSurroundPattern: + if (myDecoder.surPattern<=0.125) { + strcpy(text, "Fig-of-8"); + } + else if (myDecoder.surPattern>0.125 && myDecoder.surPattern<=0.375) { + strcpy(text, "Hyper-Card."); + } + else if (myDecoder.surPattern>0.375 && myDecoder.surPattern<=0.625) { + strcpy(text, "Cardioid"); + } + else if (myDecoder.surPattern>0.625 && myDecoder.surPattern<=0.875) { + strcpy(text, "Sub-Card."); + } + else { + strcpy(text, "Omni."); + } + break; + case kSurroundWidth: + sprintf (text, "%.1f\u00B0", myDecoder.surWidth); + break; + case kSurroundGain: + sprintf (text, "%.2fdB", myDecoder.surGain); + break; + case kDecoderMode: + switch (myDecoder.decoderMode) { + case 2 : + strcpy(text, "Stereo"); + break; + case 3 : + strcpy(text, "2.1"); + break; + case 4 : + strcpy(text, "Quad"); + break; + case 5 : + strcpy(text, "5.0"); + break; + case 6 : + strcpy(text, "5.1"); + break; + } + break; + case kChannelOrder: + switch (myDecoder.channelOrder) { + case 0 : + strcpy(text, "Natural"); + break; + case 1 : + strcpy(text, "5.1"); + break; + } + break; + + default: + break; } //kVstMaxParamStrLen } @@ -554,6 +767,36 @@ case kHiVerb : strcpy(label, "dB"); break; + case kCentrePattern: + strcpy(label, "Omni"); + break; + case kCentreGain: + strcpy(label, "dB"); + break; + case kSubGain: + strcpy(label, "dB"); + break; + case kFc: + strcpy(label, "Hz"); + break; + case kSurroundMode: + strcpy(label, "Microphones"); + break; + case kSurroundPattern: + strcpy(label, "Omni"); + break; + case kSurroundWidth: + strcpy(label, "Degrees"); + break; + case kSurroundGain: + strcpy(label, "dB"); + break; + case kDecoderMode: + strcpy(label, "Speakers"); + break; + case kChannelOrder: + strcpy(label, "Output"); + break; } } @@ -589,6 +832,16 @@ } + +//------------------------------------------------------------------------ +void SoundField::setSampleRate(float sampleRate) +{ + myDecoder.Fs = sampleRate; + myDecoder.filterCoefs(); +} + + + //--------------------------------------------------------------------------- void SoundField::processReplacing (float** inputs, float** outputs, VstInt32 sampleFrames) //The part that does some actual DSP. This section takes the input audio and gives the output audio back. { @@ -597,45 +850,42 @@ while (--sampleFrames >= 0) //Do this process if the audio is running { //Set the internal B-Format values as doubles. - double w=(double) *inputs[0]++; - double x=(double) *inputs[1]++; - double y=(double) *inputs[2]++; - double z=(double) *inputs[3]++; + double w, x, y, z; + switch (numberInputs) { + case 3: + w = (double) *inputs[0]++; + x = (double) *inputs[1]++; + y = (double) *inputs[2]++; + z = 0; + break; + + case 4: + w = (double) *inputs[0]++; + x = (double) *inputs[1]++; + y = (double) *inputs[2]++; + z = (double) *inputs[3]++; + break; + + default: + w = 0; + x = 0; + y = 0; + z = 0; + break; + } - if (myDecoder.decoderMode == 2) {//Stereo - myDecoder.stereoDecoder(w, x, y, z); - *outputs[0]++ = float(myDecoder.outputL); - *outputs[1]++ = float(myDecoder.outputR); + + int numOut; + numOut = myDecoder.processDecoder(w, x, y, z); //Process B-Format + + if (numOut<=numberOutputs) { + for (int i=0; i<numOut; i++) + *outputs[i]++ = float(myDecoder.output[i]); } -// else if (myDecoder.decoderMode == 3) {//2.1 -// myDecoder.twoOneDecoder(w, x, y, z); -// *outputs[0]++ = float(myDecoder.outputL); -// *outputs[1]++ = float(myDecoder.outputR); -// *outputs[2]++ = float(myDecoder.outputS); -// } - else if (myDecoder.decoderMode == 4) {//LRCS - myDecoder.fiveOneDecoder(w, x, y, z); - *outputs[0]++ = float(myDecoder.outputL); - *outputs[1]++ = float(myDecoder.outputR); - *outputs[2]++ = float(myDecoder.outputSL); - *outputs[3]++ = float(myDecoder.outputSR); + else{ + for (int i=0; i<numberOutputs; i++) + *outputs[i]++ = float(myDecoder.output[i]); } - else if (myDecoder.decoderMode == 5) {//5.0 - myDecoder.fiveOneDecoder(w, x, y, z); - *outputs[0]++ = float(myDecoder.outputL); - *outputs[1]++ = float(myDecoder.outputR); - *outputs[2]++ = float(myDecoder.outputC); - *outputs[3]++ = float(myDecoder.outputSL); - *outputs[4]++ = float(myDecoder.outputSR); - } - else if (myDecoder.decoderMode == 6) {//5.1 - myDecoder.fiveOneDecoder(w, x, y, z); - *outputs[0]++ = float(myDecoder.outputL); - *outputs[1]++ = float(myDecoder.outputR); - *outputs[2]++ = float(myDecoder.outputC); - *outputs[3]++ = float(myDecoder.outputS); - *outputs[4]++ = float(myDecoder.outputSL); - *outputs[5]++ = float(myDecoder.outputSR); - } + } }
--- a/Source/SoundField.h Sat Sep 15 15:07:00 2012 +0100 +++ b/Source/SoundField.h Sun Sep 16 23:25:54 2012 +0100 @@ -11,8 +11,7 @@ //------------------------------------------------------------------------------------------------------- #define kNumPrograms 1 //Number of Programs -//#define kNumParams 10 //Number of Parameters -#define MAX_CHANNELS 2 //Max Input/Output Count +#define MAX_CHANNELS 6 //Max Input/Output Count #define VERSION 1000 //Plugin Version #ifndef __SoundField__ @@ -73,6 +72,8 @@ virtual void getParameterDisplay (VstInt32 index, char* text); virtual void getParameterName (VstInt32 index, char* text); + virtual void setSampleRate (float sampleRate); + virtual bool getEffectName (char* name); virtual bool getVendorString (char* text); virtual bool getProductString (char* text); @@ -103,6 +104,9 @@ float* pBuffers[2]; char programName[kVstMaxProgNameLen + 1]; + + int numberOutputs; + int numberInputs; //Parameter float values float fMode; @@ -115,6 +119,16 @@ float fZoomMethod; float fRearVerb; float fHiVerb; + float fCentrePattern; + float fCentreGain; + float fSubGain; + float fSurroundMode; + float fSurroundPattern; + float fSurroundWidth; + float fSurroundGain; + float fFc; + float fDecoderMode; + float fChannelOrder; };
--- a/Source/SoundFieldParameters.h Sat Sep 15 15:07:00 2012 +0100 +++ b/Source/SoundFieldParameters.h Sun Sep 16 23:25:54 2012 +0100 @@ -22,6 +22,16 @@ kPattern, //7 kRearVerb, //8 kHiVerb, //9 + kCentrePattern, //10 + kCentreGain, //11 + kSubGain, //12 + kFc, //13 + kSurroundMode, //14 + kSurroundPattern, //15 + kSurroundWidth, //16 + kSurroundGain, //17 + kDecoderMode, //18 + kChannelOrder, //19 kNumParameters };