From 580e5d5882e74e6e357625dc81e6c2a4efa83511 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Thu, 23 Feb 2017 22:46:13 -0500 Subject: [PATCH] Initial porting done --- AnechoicRoomSimulator/ASupaEditor.cpp | 36 +++---- AnechoicRoomSimulator/ASupaEditor.h | 22 ++-- AnechoicRoomSimulator/CMakeLists.txt | 28 +++++ AnechoicRoomSimulator/DelayExample.cpp | 116 ++++++++++++++------- AnechoicRoomSimulator/DelayExample.def | 3 - AnechoicRoomSimulator/DelayExample.hpp | 42 ++++---- AnechoicRoomSimulator/DelayExampleMain.cpp | 49 +-------- AnechoicRoomSimulator/TextDisplay.cpp | 9 +- AnechoicRoomSimulator/TextDisplay.h | 7 -- AnechoicRoomSimulator/asciitable.cpp | 2 +- CMakeLists.txt | 2 +- 11 files changed, 161 insertions(+), 155 deletions(-) create mode 100644 AnechoicRoomSimulator/CMakeLists.txt delete mode 100644 AnechoicRoomSimulator/DelayExample.def diff --git a/AnechoicRoomSimulator/ASupaEditor.cpp b/AnechoicRoomSimulator/ASupaEditor.cpp index a37baa9..9951e56 100644 --- a/AnechoicRoomSimulator/ASupaEditor.cpp +++ b/AnechoicRoomSimulator/ASupaEditor.cpp @@ -6,9 +6,8 @@ #include "DelayExample.hpp" #include #include "math.h" -#include "resource.h" -ASupaEditor::ASupaEditor(AudioEffect *effect):AEffGUIEditor (effect) +ASupaEditor::ASupaEditor(AudioEffect *effect) : AEffGUIEditor(effect) { sizeKnob = 0; sizeDisplay = 0; @@ -25,18 +24,19 @@ ASupaEditor::~ASupaEditor() { } -long ASupaEditor::open (void *ptr) +bool ASupaEditor::open(void *ptr) { AEffGUIEditor::open(ptr); - CBitmap *hBackground = new CBitmap(IDB_BACK); - CBitmap *distknob = new CBitmap(IDB_KNOB); - CBitmap *greyText = new CBitmap(IDB_TYPE); - CBitmap *splashBitmap = new CBitmap(IDB_SPLASH); + CBitmap *hBackground = new CBitmap("back.png"); + CBitmap *distknob = new CBitmap("knob.png"); + CBitmap *greyText = new CBitmap("type.png"); + CBitmap *splashBitmap = new CBitmap("splash.png"); //init frame CRect size(0, 0, hBackground->getWidth (), hBackground->getHeight ()); - frame = new CFrame(size, ptr, this); + frame = new CFrame(size, this); + frame->open(ptr); frame->setBackground(hBackground); setKnobMode(kLinearMode); @@ -72,19 +72,20 @@ long ASupaEditor::open (void *ptr) return true; } -void ASupaEditor::close () +void ASupaEditor::close() { sizeKnob = 0; sizeDisplay = 0; splash = 0; - if(frame != 0) - delete frame; - - frame = 0; + if (frame != 0) { + CFrame *oldFrame = frame; + frame = 0; + oldFrame->forget(); + } } -void ASupaEditor::setParameter (long index, float value) +void ASupaEditor::setParameter(VstInt32 index, float value) { if (frame == 0) return; @@ -104,11 +105,9 @@ void ASupaEditor::setParameter (long index, float value) case CDelayExample::kSize : if(sizeDisplay) sizeDisplay->setText(temp); break; } } - - postUpdate(); } -void ASupaEditor::valueChanged (CDrawContext* context, CControl* control) +void ASupaEditor::valueChanged(CControl* control) { long tag = control->getTag(); @@ -125,9 +124,6 @@ void ASupaEditor::valueChanged (CDrawContext* context, CControl* control) //update control... effect->setParameterAutomated(tag, control->getValue ()); } - - if(context != 0) - control->update(context); } diff --git a/AnechoicRoomSimulator/ASupaEditor.h b/AnechoicRoomSimulator/ASupaEditor.h index fc1dd5c..4babffe 100644 --- a/AnechoicRoomSimulator/ASupaEditor.h +++ b/AnechoicRoomSimulator/ASupaEditor.h @@ -2,36 +2,26 @@ // ////////////////////////////////////////////////////////////////////// -#if !defined(AFX_ASUPAEDITOR_H__B92F8BC1_D048_11D3_9312_C56A22663A38__INCLUDED_) -#define AFX_ASUPAEDITOR_H__B92F8BC1_D048_11D3_9312_C56A22663A38__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 -#include "vstgui.h" +#include "plugin-bindings/aeffguieditor.h" #include "TextDisplay.h" -class ASupaEditor:public AEffGUIEditor, public CControlListener +class ASupaEditor:public AEffGUIEditor, public IControlListener { public: ASupaEditor(AudioEffect *effect); virtual ~ASupaEditor(); - virtual long open (void *ptr); - virtual void close (); + virtual bool open(void *ptr) override; + virtual void close () override; - virtual void setParameter (long index, float value); - virtual void valueChanged (CDrawContext* context, CControl* control); + virtual void setParameter(VstInt32 index, float value) override; + virtual void valueChanged(CControl* control) override; protected: - CAnimKnob *sizeKnob; - CTextDisplay *sizeDisplay; - CSplashScreen *splash; }; - -#endif // !defined(AFX_ASUPAEDITOR_H__B92F8BC1_D048_11D3_9312_C56A22663A38__INCLUDED_) diff --git a/AnechoicRoomSimulator/CMakeLists.txt b/AnechoicRoomSimulator/CMakeLists.txt new file mode 100644 index 0000000..177077e --- /dev/null +++ b/AnechoicRoomSimulator/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.5) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../common/common.cmake) + +pre_build() + +project(AnechoicRoomSimulator) + +set(PROJECT_SOURCE + ${CMAKE_CURRENT_SOURCE_DIR}/asciitable.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/asciitable.h + ${CMAKE_CURRENT_SOURCE_DIR}/ASupaEditor.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ASupaEditor.h + ${CMAKE_CURRENT_SOURCE_DIR}/DelayExample.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/DelayExample.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/DelayExampleMain.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/TextDisplay.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/TextDisplay.h +) + +set(PROJECT_IMAGES + ${CMAKE_CURRENT_SOURCE_DIR}/images/back.png + ${CMAKE_CURRENT_SOURCE_DIR}/images/knob.png + ${CMAKE_CURRENT_SOURCE_DIR}/images/splash.png + ${CMAKE_CURRENT_SOURCE_DIR}/images/type.png +) + +build_vst_gui(AnechoicRoomSimulator "${PROJECT_SOURCE}" "${PROJECT_IMAGES}") diff --git a/AnechoicRoomSimulator/DelayExample.cpp b/AnechoicRoomSimulator/DelayExample.cpp index c2f8978..e28771a 100644 --- a/AnechoicRoomSimulator/DelayExample.cpp +++ b/AnechoicRoomSimulator/DelayExample.cpp @@ -2,6 +2,12 @@ #include "ASupaEditor.h" #include "math.h" +void vstint2string(const VstInt32 number, char* str) +{ + std::stringstream ss; + ss << number; + strcpy(str, ss.str().c_str()); +} //----------------------------------------------------------------------------- CDelayExample::CDelayExample(audioMasterCallback audioMaster) : AudioEffectX(audioMaster, kNumPrograms, kNumParams) @@ -9,7 +15,6 @@ CDelayExample::CDelayExample(audioMasterCallback audioMaster) : AudioEffectX(aud setNumInputs(kNumInputChannels); // stereo in setNumOutputs(kNumOutputChannels); // stereo out setUniqueID('AneC'); // TODO: Change for plugin identification - canMono(); // makes sense to feed both inputs with the same signal canProcessReplacing(); // supports both accumulating and replacing output //clear buffers! @@ -37,7 +42,7 @@ CDelayExample::~CDelayExample() /////////////////////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------------------- -void CDelayExample::setParameter(long index, float value) +void CDelayExample::setParameter(VstInt32 index, float value) { // save the parameter for the host... savedParameters[index] = value; @@ -57,7 +62,7 @@ void CDelayExample::setParameter(long index, float value) } //----------------------------------------------------------------------------------------- -float CDelayExample::getParameter(long index) +float CDelayExample::getParameter(VstInt32 index) { // you should only really change this in special occasions // for example, when you use programs!! @@ -68,7 +73,7 @@ float CDelayExample::getParameter(long index) } //----------------------------------------------------------------------------------------- -void CDelayExample::getParameterName(long index, char *label) +void CDelayExample::getParameterName(VstInt32 index, char *label) { // TODO: give the parameters names, make sure you don't use more than 24 characters! switch(index) @@ -79,19 +84,19 @@ void CDelayExample::getParameterName(long index, char *label) } //----------------------------------------------------------------------------------------- -void CDelayExample::getParameterDisplay(long index, char *text) +void CDelayExample::getParameterDisplay(VstInt32 index, char *text) { // TODO: give the parameters displays // you could use float2string(), dB2string(), long2string() or roll your own switch(index) { - case kSize : long2string((long)(savedParameters[index]*10000.f), text); break; + case kSize : vstint2string((VstInt32)(savedParameters[index]*10000.f), text); break; default : strcpy(text, ""); break; } } //----------------------------------------------------------------------------------------- -void CDelayExample::getParameterLabel(long index, char *label) +void CDelayExample::getParameterLabel(VstInt32 index, char *label) { // TODO: give the parameters labels switch(index) @@ -121,7 +126,7 @@ void CDelayExample::getProgramName(char *name) } //----------------------------------------------------------------------------------------- -void CDelayExample::setProgram(long index) +void CDelayExample::setProgram(VstInt32 index) { // this template does not use programs yet }; @@ -132,29 +137,72 @@ void CDelayExample::setProgram(long index) // the actual processing /////////////////////////////////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------------------- -void CDelayExample::process(float **inputs, float **outputs, long sampleFrames) -{ - // reminder : VST allows for sampleFrames to be different every block - - // this will only work if you have two in's and two out's!! - float *in1 = inputs[0]; - float *in2 = inputs[1]; - float *out1 = outputs[0]; - float *out2 = outputs[1]; - // accumilate into output - // watch out: in and out might actualy be the SAME array!!! - for(long i=0;igetAeffect (); -} - -#if MAC -#pragma export off -#endif - - -#if WIN32 -#include -void* hInstance; -BOOL WINAPI DllMain (HINSTANCE hInst, DWORD dwReason, LPVOID lpvReserved) -{ - hInstance = hInst; - return 1; + return new CDelayExample(audioMaster); } -#endif diff --git a/AnechoicRoomSimulator/TextDisplay.cpp b/AnechoicRoomSimulator/TextDisplay.cpp index ca0699b..1688d1e 100644 --- a/AnechoicRoomSimulator/TextDisplay.cpp +++ b/AnechoicRoomSimulator/TextDisplay.cpp @@ -3,7 +3,6 @@ ////////////////////////////////////////////////////////////////////// #include "TextDisplay.h" -#include "resource.h" #include "asciitable.h" ////////////////////////////////////////////////////////////////////// @@ -46,7 +45,7 @@ void CTextDisplay::draw (CDrawContext* pContext) pContext->setFrameColor(_rectColor); pContext->drawRect(size); - pContext->fillRect(size); + //pContext->fillRect(size); CRect sourcerect; CPoint bitmapoffset; @@ -80,11 +79,11 @@ void CTextDisplay::draw (CDrawContext* pContext) } if(middle) - left += (size.width() - totalWidth) / 2; + left += (size.getWidth() - totalWidth) / 2; else - left += size.width() - totalWidth; + left += size.getWidth() - totalWidth; - for(i=0;i<256;i++) + for(int i=0;i<256;i++) { if(_todisplay[i] == 0) break; diff --git a/AnechoicRoomSimulator/TextDisplay.h b/AnechoicRoomSimulator/TextDisplay.h index a36ff85..afe1317 100644 --- a/AnechoicRoomSimulator/TextDisplay.h +++ b/AnechoicRoomSimulator/TextDisplay.h @@ -2,12 +2,7 @@ // ////////////////////////////////////////////////////////////////////// -#if !defined(AFX_TEXTDISPLAY_H__05B21240_4B75_11D4_B567_002018B8E8B7__INCLUDED_) -#define AFX_TEXTDISPLAY_H__05B21240_4B75_11D4_B567_002018B8E8B7__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 #include "vstgui.h" @@ -30,5 +25,3 @@ class CTextDisplay : public CParamDisplay CColor _rectColor; bool middle; }; - -#endif // !defined(AFX_TEXTDISPLAY_H__05B21240_4B75_11D4_B567_002018B8E8B7__INCLUDED_) diff --git a/AnechoicRoomSimulator/asciitable.cpp b/AnechoicRoomSimulator/asciitable.cpp index 6cd6c68..812fcab 100644 --- a/AnechoicRoomSimulator/asciitable.cpp +++ b/AnechoicRoomSimulator/asciitable.cpp @@ -66,6 +66,6 @@ void fillasciitable() //ASCII = place ASCII[0] = 0; - for(i=1;i<256;i++) + for(int i=1;i<256;i++) ASCII[i] = ASCII[i-1] + DASCII[i-1]; } diff --git a/CMakeLists.txt b/CMakeLists.txt index 27e9972..b3a0be9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(Smartelectronix) enable_testing() -#add_subdirectory(AnechoicRoomSimulator) +add_subdirectory(AnechoicRoomSimulator) #add_subdirectory(Bitmurderer) add_subdirectory(Bouncy) add_subdirectory(CrazyIvan)