?? vsteffect.cpp
字號:
for (i = 0; i < block; i++) buffer[i] = fOutBuffer[0][i]; left->Set((samplePtr)buffer, floatSample, ls, block); if (right) { for (i = 0; i < block; i++) buffer[i] = fOutBuffer[1][i]; right->Set((samplePtr)buffer, floatSample, rs, block); } len -= block; ls += block; rs += block; if (inputs > 1) { if (TrackGroupProgress(count, (ls-lstart)/(double)originalLen)) break; } else { if (TrackProgress(count, (ls-lstart)/(double)originalLen)) break; } } return true;}void VSTEffect::End(){ if (buffer) { int i; delete[]buffer; for (i = 0; i < inputs; i++) delete fInBuffer[i]; for (i = 0; i < outputs; i++) delete fOutBuffer[i]; delete[]fInBuffer; delete[]fOutBuffer; } buffer = NULL; fInBuffer = NULL; fOutBuffer = NULL;}BEGIN_EVENT_TABLE(VSTEffectDialog, wxDialog) EVT_BUTTON(wxID_OK, VSTEffectDialog::OnOK) EVT_BUTTON(wxID_CANCEL, VSTEffectDialog::OnCancel) EVT_BUTTON(PREVIEW_ID, VSTEffectDialog::OnPreview) EVT_COMMAND_SCROLL(VSTEFFECT_SLIDER_ID, VSTEffectDialog::OnSlider) EVT_SLIDER(VSTEFFECT_SLIDER_ID, VSTEffectDialog::OnSliderCmd)END_EVENT_TABLE()VSTEffectDialog::VSTEffectDialog(wxWindow * parent, wxString effectName, int numParams, VSTEffect * vst, AEffect * aEffect, const wxPoint & pos):wxDialog(parent, -1, effectName, pos, wxSize(320, 430), wxDEFAULT_DIALOG_STYLE){ this->vst = vst; this->aEffect = aEffect; this->numParams = numParams; int y = 10; new wxStaticText(this, 0, _("VST Plug-in parameters:"), wxPoint(10, y), wxSize(300, 15)); y += 20; sliders = new wxSlider *[numParams]; labels = new wxStaticText *[numParams]; for (int p = 0; p < numParams; p++) { char paramName[256]; vst->callDispatcher(aEffect, effGetParamName, p, 0, (void *) paramName, 0.0); new wxStaticText(this, 0, wxString(paramName), wxPoint(10, y), wxSize(85, 15)); float val = vst->callGetParameter(aEffect, p); sliders[p] = new wxSlider(this, VSTEFFECT_SLIDER_ID, 1000 * val, 0, 1000, wxPoint(100, y + 5), wxSize(200, 25)); char label[256]; vst->callDispatcher(aEffect, effGetParamDisplay, p, 0, (void *) label, 0.0); char units[256]; vst->callDispatcher(aEffect, effGetParamLabel, p, 0, (void *) units, 0.0); labels[p] = new wxStaticText(this, 0, wxString::Format("%s %s", label, units), wxPoint(10, y + 15), wxSize(85, 15)); y += 35; } y += 20; wxButton *preview = new wxButton(this, PREVIEW_ID, vst->GetPreviewName(), wxPoint(10, y), wxSize(80, 30)); wxButton *cancel = new wxButton(this, wxID_CANCEL, _("Cancel"), wxPoint(130, y), wxSize(80, 30)); wxButton *ok = new wxButton(this, wxID_OK, _("OK"), wxPoint(220, y), wxSize(80, 30)); y += 40; wxSize size; size.x = 320; size.y = y;#ifdef __WXMSW__ size.y += 20;#endif Centre(wxBOTH | wxCENTER_FRAME); SetSize(size);}VSTEffectDialog::~VSTEffectDialog(){ // TODO: proper disposal here delete[]sliders; delete[]labels;}void VSTEffectDialog::OnSlider(wxScrollEvent & WXUNUSED(event)){ for (int p = 0; p < numParams; p++) { float val; val = sliders[p]->GetValue() / 1000.; vst->callSetParameter(aEffect, p, val); char label[256]; vst->callDispatcher(aEffect, effGetParamDisplay, p, 0, (void *) label, 0.0); char units[256]; vst->callDispatcher(aEffect, effGetParamLabel, p, 0, (void *) units, 0.0); labels[p]->SetLabel(wxString::Format("%s %s", label, units)); }}void VSTEffectDialog::OnSliderCmd(wxCommandEvent & WXUNUSED(event)){ for (int p = 0; p < numParams; p++) { float val; val = sliders[p]->GetValue() / 1000.; vst->callSetParameter(aEffect, p, val); char label[256]; vst->callDispatcher(aEffect, effGetParamDisplay, p, 0, (void *) label, 0.0); char units[256]; vst->callDispatcher(aEffect, effGetParamLabel, p, 0, (void *) units, 0.0); labels[p]->SetLabel(wxString::Format("%s %s", label, units)); }}void VSTEffectDialog::OnOK(wxCommandEvent & WXUNUSED(event)){ EndModal(TRUE);}void VSTEffectDialog::OnCancel(wxCommandEvent & WXUNUSED(event)){ EndModal(FALSE);}void VSTEffectDialog::OnPreview(wxCommandEvent & WXUNUSED(event)){ vst->Preview();}#ifdef __MACOSX__// Mac OS X methods//// Cross-platform VST plug-ins on the Mac are compiled as Carbon,// CFM code. Audacity is compiled as Carbon, Mach-O code. Special care// must be taken when calling funtions in the other mode - these// functions make it easier.//// MachOFunctionPointerForCFMFunctionPointer(void *cfmfp)//// Borrowed from the Apple Sample Code file "CFM_MachO_CFM.c"// This function allocates a block of CFM glue code which contains// the instructions to call CFM routinesvoid *NewMachOFromCFM(void *cfmfp){ UInt32 CFMTemplate[6] = {0x3D800000, 0x618C0000, 0x800C0000, 0x804C0004, 0x7C0903A6, 0x4E800420}; UInt32 *mfp = (UInt32*)NewPtr(sizeof(CFMTemplate)); mfp[0] = CFMTemplate[0] | ((UInt32)cfmfp >> 16); mfp[1] = CFMTemplate[1] | ((UInt32)cfmfp & 0xFFFF); mfp[2] = CFMTemplate[2]; mfp[3] = CFMTemplate[3]; mfp[4] = CFMTemplate[4]; mfp[5] = CFMTemplate[5]; MakeDataExecutable(mfp, sizeof(CFMTemplate)); return(mfp);}void DisposeMachOFromCFM(void *ptr){ DisposePtr((Ptr)ptr);}void *NewCFMFromMachO(void *machofp){ void *result = NewPtr(8); ((void **)result)[0] = machofp; ((void **)result)[1] = result; return result;}void DisposeCFMFromMachO(void *ptr){ DisposePtr((Ptr)ptr);}long VSTEffect::callDispatcher(AEffect * effect, long opCode, long index, long value, void *ptr, float opt){ long rval; dispatcherFn fp = (dispatcherFn)NewMachOFromCFM(effect->dispatcher); rval = fp(effect, opCode, index, value, ptr, opt); DisposeMachOFromCFM(fp); return rval;}void VSTEffect::callProcess(AEffect * effect, float **inputs, float **outputs, long sampleframes){ processFn fp = (processFn)NewMachOFromCFM(effect->process); fp(effect, inputs, outputs, sampleframes); DisposeMachOFromCFM(fp);}void VSTEffect::callProcessReplacing(AEffect * effect, float **inputs, float **outputs, long sampleframes){ processFn fp = (processFn)NewMachOFromCFM(effect->processReplacing); fp(effect, inputs, outputs, sampleframes); DisposeMachOFromCFM(fp);}void VSTEffect::callSetParameter(AEffect * effect, long index, float parameter){ setParameterFn fp = (setParameterFn)NewMachOFromCFM(effect->setParameter); fp(effect, index, parameter); DisposeMachOFromCFM(fp);}float VSTEffect::callGetParameter(AEffect * effect, long index){ float rval; getParameterFn fp = (getParameterFn)NewMachOFromCFM(effect->getParameter); rval = fp(effect, index); DisposeMachOFromCFM(fp); return rval;}#else // ifdef __MACOSX__long VSTEffect::callDispatcher(AEffect * effect, long opCode, long index, long value, void *ptr, float opt){ return effect->dispatcher(effect, opCode, index, value, ptr, opt);}void VSTEffect::callProcess(AEffect * effect, float **inputs, float **outputs, long sampleframes){ effect->process(effect, inputs, outputs, sampleframes);}void VSTEffect::callProcessReplacing(AEffect * effect, float **inputs, float **outputs, long sampleframes){ effect->processReplacing(effect, inputs, outputs, sampleframes);}void VSTEffect::callSetParameter(AEffect * effect, long index, float parameter){ effect->setParameter(effect, index, parameter);}float VSTEffect::callGetParameter(AEffect * effect, long index){ return effect->getParameter(effect, index);}#endif // MACOSX#endif // USE_VST// Indentation settings for Vim and Emacs and unique identifier for Arch, a// version control system. Please do not modify past this point.//// Local Variables:// c-basic-offset: 3// indent-tabs-mode: nil// End://// vim: et sts=3 sw=3// arch-tag: dae3d099-e1eb-494e-b8eb-8f0af7f674d2
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -