Skip to content

Commit

Permalink
Windows/MSVC: Trivial cleanups (surge-synthesizer#2707)
Browse files Browse the repository at this point in the history
- Fix unused variable, unreachable code warnings
- Remove WIN_X86 define
  • Loading branch information
mvf authored Sep 26, 2020
1 parent 1be8ec0 commit c695f15
Show file tree
Hide file tree
Showing 13 changed files with 12 additions and 62 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,6 @@ elseif( WIN32 )
if( ${CMAKE_SIZEOF_VOID_P} EQUAL 4 )
set( WIN_DLL_BASENAME "Surge_x86" )
set( PNG_LINK_DIR "libs/libpng/win/x86/lib" )
list( APPEND OS_COMPILE_DEFINITIONS WIN_X86=1 )
else()
set( WIN_DLL_BASENAME "Surge" )
set( PNG_LINK_DIR "libs/libpng/win/x64/lib" )
Expand Down
1 change: 0 additions & 1 deletion src/common/SurgePatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1996,7 +1996,6 @@ unsigned int SurgePatch::save_xml(void** data) // allocates mem, must be freed b
{
if (scene[sc].lfo[l].shape.val.i == ls_mseg)
{
char txt[256], txt2[256];
TiXmlElement p("mseg");
p.SetAttribute("scene", sc);
p.SetAttribute("i", l);
Expand Down
6 changes: 0 additions & 6 deletions src/common/SurgeSynthesizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1228,8 +1228,6 @@ void SurgeSynthesizer::channelController(char channel, int cc, int value)
}
}

int n = storage.getPatch().param_ptr.size();

if (learn_param >= 0)
{
if (learn_param < n_global_params)
Expand Down Expand Up @@ -1471,8 +1469,6 @@ ControllerModulationSource* SurgeSynthesizer::AddControlInterpolator(int Id, boo

void SurgeSynthesizer::setParameterSmoothed(long index, float value)
{
float oldval = storage.getPatch().param_ptr[index]->get_value_f01();

bool AlreadyExisted;
ControllerModulationSource* mc = AddControlInterpolator(index, AlreadyExisted);

Expand Down Expand Up @@ -2429,8 +2425,6 @@ void SurgeSynthesizer::getParameterMeta(long index, parametermeta& pm)
}
else if (index >= metaparam_offset)
{
int c = index - metaparam_offset;

pm.flags = 0;
pm.fmin = 0.f;
pm.fmax = 1.f;
Expand Down
2 changes: 0 additions & 2 deletions src/common/gui/CHSwitch2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ CMouseEventResult CHSwitch2::onMouseDown(CPoint& where, const CButtonState& butt
mouseDowns --;
return res;
}

return kMouseEventNotHandled;
}
CMouseEventResult CHSwitch2::onMouseUp(CPoint& where, const CButtonState& buttons)
{
Expand Down
3 changes: 0 additions & 3 deletions src/common/gui/CLFOGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,6 @@ void CLFOGui::draw(CDrawContext* dc)
{
auto size = getViewSize();

int w = size.getWidth() - splitpoint;
int h = size.getHeight();
auto shiftTranslate = CGraphicsTransform().translate( size.left, size.top ).translate( splitpoint, 0 );
CDrawContext::Transform shiftTranslatetransform( *dc, shiftTranslate );

Expand Down Expand Up @@ -818,7 +816,6 @@ void CLFOGui::drawStepSeq(VSTGUI::CDrawContext *dc, VSTGUI::CRect &maindisp, VST

int minSamples = ( 1 << 3 ) * (int)( boxo.right - boxo.left );
int totalSamples = std::max( (int)minSamples, (int)(totalSampleTime * samplerate / BLOCK_SIZE) );
float drawnTime = totalSamples * samplerate_inv * BLOCK_SIZE;
float cycleSamples = cyclesec * samplerate / BLOCK_SIZE;


Expand Down
1 change: 0 additions & 1 deletion src/common/gui/CModulationSourceButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ void CModulationSourceButton::draw(CDrawContext* dc)

// source position in bitmap

bool ActiveArrow = state > 4;
bool SelectedModSource = (state & 3) == 1;
bool ActiveModSource = (state & 3) == 2;
bool UsedOrActive = used || (state & 3);
Expand Down
6 changes: 0 additions & 6 deletions src/common/gui/COscillatorDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ void COscillatorDisplay::draw(CDrawContext* dc)
if (uses_wavetabledata(oscdata->type.val.i))
h -= wtbheight;

int midline = h >> 1;
int topline = midline - 0.4f * h;
int bottomline = midline + 0.4f * h;


int totalSamples = ( 1 << 4 ) * (int)getWidth();
int averagingWindow = 4; // this must be both less than BLOCK_SIZE_OS and BLOCK_SIZE_OS must be an integer multiple of it

Expand Down Expand Up @@ -167,7 +162,6 @@ void COscillatorDisplay::draw(CDrawContext* dc)
float f1 = storage->note_to_pitch(bracket);
float f2 = storage->note_to_pitch(bracket+1);
float frac = (pit - f1)/ (f2-f1);
float newp = storage->note_to_pitch(bracket + frac);
disp_pitch_rs = bracket + frac;
}
else
Expand Down
4 changes: 0 additions & 4 deletions src/common/gui/CSnapshotMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ bool CSnapshotMenu::canSave()
void CSnapshotMenu::populate()
{
int main = 0, sub = 0;
bool do_nothing = false;
const long max_main = 128, max_sub = 256;

int idx = 0;
Expand Down Expand Up @@ -85,13 +84,11 @@ bool CSnapshotMenu::loadSnapshotByIndex( int idx )
{
auto type = typeD.front();
typeD.pop();
auto tn = type->Attribute( "name" );
int type_id = 0;
type->Attribute("i", &type_id);
TiXmlElement* snapshot = TINYXML_SAFE_TO_ELEMENT(type->FirstChild("snapshot"));
while (snapshot)
{
auto n = snapshot->Attribute("name");
int snapshotTypeID = type_id, tmpI = 0;
if (snapshot->Attribute("i", &tmpI) != nullptr)
{
Expand Down Expand Up @@ -841,7 +838,6 @@ void CFxMenu::addToTopLevelTypeMenu(TiXmlElement *type, VSTGUI::COptionMenu *sub
auto user_add = subMenu->addEntry("USER PRESETS");
user_add->setEnabled(0);

int fidx = idx + 10000;
for( auto &ps : userPresets[type_id] )
{
auto fxName = ps.name;
Expand Down
1 change: 0 additions & 1 deletion src/common/gui/MSEGEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,6 @@ struct MSEGMainEd : public CViewContainer {
this->skin = skin;

int controlHeight = 85;
int outputWidth = 320;
auto msegCanv = new MSEGCanvas( CRect( CPoint( 0, 0 ), CPoint( size.getWidth(), size.getHeight() - controlHeight ) ), lfodata, ms, skin, bmp );

auto msegControl = new MSEGControlRegion(CRect( CPoint( 0, size.getHeight() - controlHeight ), CPoint( size.getWidth(), controlHeight ) ), msegCanv,
Expand Down
23 changes: 4 additions & 19 deletions src/common/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ struct RememberForgetGuard {
~RememberForgetGuard() {
if( t )
{
auto rc = t->release();
t->release();
}
}
T *t = nullptr;
Expand Down Expand Up @@ -214,8 +214,6 @@ std::string specialTagToString( special_tags t )
default:
return "ERROR";
}
return "ERROR";

}

SurgeGUIEditor::SurgeGUIEditor(void* effect, SurgeSynthesizer* synth, void* userdata) : super(effect)
Expand Down Expand Up @@ -2487,7 +2485,6 @@ void SurgeGUIEditor::setParameter(long index, float value)
return;
if (index > synth->storage.getPatch().param_ptr.size())
return;
Parameter* p = synth->storage.getPatch().param_ptr[index];

// if(param[index])
{
Expand Down Expand Up @@ -3170,8 +3167,6 @@ int32_t SurgeGUIEditor::controlModifierClicked(CControl* control, CButtonState b
{
Parameter* p = synth->storage.getPatch().param_ptr[ptag];

auto ctrl = dynamic_cast<CSurgeSlider*>(control);

// don't show RMB context menu for filter subtype if it's hidden/not applicable
auto f1type = synth->storage.getPatch().scene[current_scene].filterunit[0].type.val.i;
auto f2type = synth->storage.getPatch().scene[current_scene].filterunit[1].type.val.i;
Expand Down Expand Up @@ -3225,18 +3220,14 @@ int32_t SurgeGUIEditor::controlModifierClicked(CControl* control, CButtonState b
std::string helpurl = helpURLFor(p);
if( helpurl == "" )
{
auto fnmi = contextMenu->addEntry((char *)p->get_full_name(), eid++);
contextMenu->addEntry((char*)p->get_full_name(), eid++);
}
else
{
std::string helpstr = "[?] ";
auto lurl = fullyResolvedHelpURL(helpurl);
auto fnmi = addCallbackMenu(contextMenu, std::string(helpstr + p->get_full_name()).c_str(),
[lurl]()
{
Surge::UserInteractions::openURL( lurl );
}
);
addCallbackMenu(contextMenu, std::string(helpstr + p->get_full_name()).c_str(),
[lurl]() { Surge::UserInteractions::openURL(lurl); });
eid++;
}
contextMenu->addSeparator(eid++);
Expand Down Expand Up @@ -3747,9 +3738,6 @@ int32_t SurgeGUIEditor::controlModifierClicked(CControl* control, CButtonState b
{
contextMenu->addSeparator(eid++);

int detailedMode = Surge::Storage::getUserDefaultValue(&(this->synth->storage), "highPrecisionReadouts", 0);


for (int k = 1; k < n_modsources; k++)
{
modsources ms = (modsources)k;
Expand Down Expand Up @@ -4379,8 +4367,6 @@ void SurgeGUIEditor::valueChanged(CControl* control)
{
int ptag = tag - start_paramtags;

int detailedMode = Surge::Storage::getUserDefaultValue(&(this->synth->storage), "highPrecisionReadouts", 0);

if ((ptag >= 0) && (ptag < synth->storage.getPatch().param_ptr.size()))
{
Parameter* p = synth->storage.getPatch().param_ptr[ptag];
Expand Down Expand Up @@ -5565,7 +5551,6 @@ VSTGUI::COptionMenu* SurgeGUIEditor::makeUserSettingsMenu(VSTGUI::CRect& menuRec
middleCSubMenu->forget();

// patch defaults
int pdid = 0;
COptionMenu* patchDefMenu = new COptionMenu(menuRect, 0, 0, 0, 0,
VSTGUI::COptionMenu::kNoDrawStyle |
VSTGUI::COptionMenu::kMultipleCheckStyle);
Expand Down
3 changes: 0 additions & 3 deletions src/vst3/SurgeVst3Processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,6 @@ tresult PLUGIN_API SurgeVst3Processor::process(ProcessData& data)

_fpuState.set();

int32 numChannels = 2;
int32 numSamples = data.numSamples;

surgeInstance->process_input = data.numInputs != 0 && data.inputs != nullptr;
Expand All @@ -450,7 +449,6 @@ tresult PLUGIN_API SurgeVst3Processor::process(ProcessData& data)

int i;
int numOutputs = data.numOutputs;
int numInputs = data.numInputs;
int noteEventIndex = 0;
int parameterEventIndex = 0;

Expand Down Expand Up @@ -489,7 +487,6 @@ tresult PLUGIN_API SurgeVst3Processor::process(ProcessData& data)
}

// move clock
timedata* td = &(surgeInstance->time_data);
surgeInstance->time_data.tempo = tempo;
surgeInstance->time_data.ppqPos +=
(double)BLOCK_SIZE * tempo / (60. * data.processContext->sampleRate);
Expand Down
19 changes: 5 additions & 14 deletions src/vst3/SurgeVst3Processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,11 @@ class SurgeVst3Processor : public Steinberg::Vst::SingleComponentEffect,
void updateDisplay();
void setParameterAutomated(int externalparam, float value);

#if WIN_X86
// For some undebuggable reason, 32 bit windows doesn't like hte PLUGIN_API
// 32 bit vst3 is worth 0 time debugging; this fix makes it work.
virtual tresult beginEdit(Steinberg::Vst::ParamID id);
virtual tresult performEdit(Steinberg::Vst::ParamID id,
Steinberg::Vst::ParamValue valueNormalized);
virtual tresult endEdit(Steinberg::Vst::ParamID id);
#else
virtual tresult PLUGIN_API beginEdit(Steinberg::Vst::ParamID id) override;
virtual tresult PLUGIN_API performEdit(Steinberg::Vst::ParamID id,
Steinberg::Vst::ParamValue valueNormalized) override;
virtual tresult PLUGIN_API endEdit(Steinberg::Vst::ParamID id) override;
#endif

tresult beginEdit(Steinberg::Vst::ParamID id) override;
tresult performEdit(Steinberg::Vst::ParamID id,
Steinberg::Vst::ParamValue valueNormalized) override;
tresult endEdit(Steinberg::Vst::ParamID id) override;

protected:
void createSurge();
void destroySurge();
Expand Down
4 changes: 3 additions & 1 deletion src/windows/UserInteractionsWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ void showHTML( const std::string &html )
{
TCHAR lpTempPathBuffer[MAX_PATH];

auto dwRetVal = GetTempPath(MAX_PATH, lpTempPathBuffer);
if (!GetTempPath(MAX_PATH, lpTempPathBuffer))
return;

std::ostringstream fns;
fns << lpTempPathBuffer << "surge-data." << rand() << ".html";

Expand Down

0 comments on commit c695f15

Please sign in to comment.