本文整理汇总了C++中IParam::Type方法的典型用法代码示例。如果您正苦于以下问题:C++ IParam::Type方法的具体用法?C++ IParam::Type怎么用?C++ IParam::Type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IParam
的用法示例。
在下文中一共展示了IParam::Type方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetChunk
ComponentResult IPlugProcess::SetChunk(OSType chunkID, SFicPlugInChunk *chunk)
{
TRACE;
if (chunkID == mPluginID)
{
int dataSize = chunk->fSize - sizeof(SFicPlugInChunkHeader);
ByteChunk IPlugChunk;
IPlugChunk.PutBytes(chunk->fData, dataSize);
mPlug->UnserializeState(&IPlugChunk, 0);
for (int i = 0; i< mPlug->NParams(); i++)
{
IParam *p = mPlug->GetParam(i);
int idx = i+kPTParamIdxOffset;
switch (p->Type())
{
case IParam::kTypeDouble:
{
CPluginControl_Continuous *control = dynamic_cast<CPluginControl_Continuous*>(GetControl(idx));
SetControlValue(idx, control->ConvertContinuousToControl( p->Value() ));
break;
}
case IParam::kTypeInt:
case IParam::kTypeEnum:
case IParam::kTypeBool:
{
CPluginControl_Discrete *control = dynamic_cast<CPluginControl_Discrete*>(GetControl(idx));
SetControlValue(idx, control->ConvertDiscreteToControl( p->Int() ));
break;
}
default:
break;
}
}
fNumPlugInChanges++;
return noErr;
}
return kChunkRangeErr;
}
示例2: VSTDispatcher
VstIntPtr VSTCALLBACK IPlugVST::VSTDispatcher(AEffect *pEffect, VstInt32 opCode, VstInt32 idx, VstIntPtr value, void *ptr, float opt)
{
// VSTDispatcher is an IPlugVST class member, we can access anything in IPlugVST from here.
IPlugVST* _this = (IPlugVST*) pEffect->object;
if (!_this)
{
return 0;
}
IPlugBase::IMutexLock lock(_this);
// Handle a couple of opcodes here to make debugging easier.
switch (opCode)
{
case effEditIdle:
case __effIdleDeprecated:
#ifdef USE_IDLE_CALLS
_this->OnIdle();
#endif
return 0;
}
Trace(TRACELOC, "%d(%s):%d:%d", opCode, VSTOpcodeStr(opCode), idx, (int) value);
switch (opCode)
{
case effOpen:
{
_this->HostSpecificInit();
_this->OnParamReset();
return 0;
}
case effClose:
{
lock.Destroy();
DELETE_NULL(_this);
return 0;
}
case effGetParamLabel:
{
if (idx >= 0 && idx < _this->NParams())
{
strcpy((char*) ptr, _this->GetParam(idx)->GetLabelForHost());
}
return 0;
}
case effGetParamDisplay:
{
if (idx >= 0 && idx < _this->NParams())
{
_this->GetParam(idx)->GetDisplayForHost((char*) ptr);
}
return 0;
}
case effGetParamName:
{
if (idx >= 0 && idx < _this->NParams())
{
strcpy((char*) ptr, _this->GetParam(idx)->GetNameForHost());
}
return 0;
}
//could implement effGetParameterProperties to group parameters, but can't find a host that supports it
// case effGetParameterProperties:
// {
// if (idx >= 0 && idx < _this->NParams())
// {
// VstParameterProperties* props = (VstParameterProperties*) ptr;
//
// props->flags = kVstParameterSupportsDisplayCategory;
// props->category = idx+1;
// props->numParametersInCategory = 1;
// strcpy(props->categoryLabel, "test");
// }
// return 1;
// }
case effGetParameterProperties:
{
if (idx >= 0 && idx < _this->NParams())
{
VstParameterProperties* props = (VstParameterProperties*) ptr;
props->flags = 0;
IParam* pParam = _this->GetParam(idx);
if (pParam->Type() == IParam::kTypeBool) {
props->flags |= kVstParameterIsSwitch;
}
if (pParam->Type() == IParam::kTypeEnum || pParam->Type() == IParam::kTypeInt) {
props->flags |= kVstParameterUsesFloatStep;
int possibleValuesCount = (int) (pParam->GetMax() - pParam->GetMin());
props->stepFloat = 1.0 / possibleValuesCount;
props->smallStepFloat = props->stepFloat;
props->largeStepFloat = props->stepFloat;
}
}
return 1;
}
case effString2Parameter:
{
if (idx >= 0 && idx < _this->NParams())
{
if (ptr)
//.........这里部分代码省略.........
示例3: EffectInit
void IPlugProcess::EffectInit()
{
TRACE;
if (mPlug)
{
AddControl(new CPluginControl_OnOff('bypa', "Master Bypass\nMastrByp\nMByp\nByp", false, true)); // Default to off
DefineMasterBypassControlIndex(1);
int paramCount = mPlug->NParams();
for (int i=0; i<paramCount; i++)
{
IParam *p = mPlug->GetParam(i);
switch (p->Type())
{
case IParam::kTypeDouble:
AddControl(new CPluginControl_Linear(' ld '+i, p->GetNameForHost(), p->GetMin(), p->GetMax(), p->GetStep(), p->GetDefault(), p->GetCanAutomate()));
break;
case IParam::kTypeInt:
AddControl(new CPluginControl_Discrete(' ld '+i, p->GetNameForHost(), (long) p->GetMin(), (long) p->GetMax(), (long) p->GetDefault(), p->GetCanAutomate()));
break;
case IParam::kTypeEnum:
case IParam::kTypeBool:
{
std::vector<std::string> displayTexts;
for (int j=0; j<p->GetNDisplayTexts(); j++)
{
displayTexts.push_back(p->GetDisplayTextAtIdx(j));
}
assert(displayTexts.size());
AddControl(new CPluginControl_List(' ld '+i, p->GetNameForHost(), displayTexts, (long) p->GetDefault(), p->GetCanAutomate()));
break;
}
default:
break;
}
}
#if PLUG_DOES_MIDI
if (!IsAS())
{
ComponentResult result = noErr;
Cmn_Int32 requestedVersion = 7;
std::string midiNodeName(PLUG_NAME" Midi");
while (requestedVersion)
{
result = DirectMidi_RegisterClient(requestedVersion, this, reinterpret_cast<Cmn_UInt32>(this), (void **)&mDirectMidiInterface);
if (result == noErr && mDirectMidiInterface != NULL)
{
mDirectMidiInterface->CreateRTASBufferedMidiNode(0, const_cast<char *>(midiNodeName.c_str()), 1);
break;
}
requestedVersion--;
}
}
#endif
mPlug->SetIO(GetNumInputs(), GetNumOutputs());
mPlug->SetSampleRate(GetSampleRate());
mPlug->Reset();
}
}
示例4: SetHost
//.........这里部分代码省略.........
STR16(""),
0,
NPresets(),
ParameterInfo::kIsProgramChange));
}
if(!mIsInst)
{
StringListParameter * bypass = new StringListParameter(STR16("Bypass"),
kBypassParam,
0,
ParameterInfo::kCanAutomate | ParameterInfo::kIsBypass | ParameterInfo::kIsList);
bypass->appendString(STR16("off"));
bypass->appendString(STR16("on"));
parameters.addParameter(bypass);
}
for (int i=0; i<NParams(); i++)
{
IParam *p = GetParam(i);
int32 flags = 0;
UnitID unitID = kRootUnitId;
const char* paramGroupName = p->GetParamGroupForHost();
if (CSTR_NOT_EMPTY(paramGroupName))
{
for(int j = 0; j < mParamGroups.GetSize(); j++)
{
if(strcmp(paramGroupName, mParamGroups.Get(j)) == 0)
{
unitID = j+1;
}
}
if (unitID == kRootUnitId) // new unit, nothing found, so add it
{
mParamGroups.Add(paramGroupName);
unitID = mParamGroups.GetSize();
}
}
if (p->GetCanAutomate())
{
flags |= ParameterInfo::kCanAutomate;
}
switch (p->Type())
{
case IParam::kTypeDouble:
case IParam::kTypeInt:
{
Parameter* param = new RangeParameter( STR16(p->GetNameForHost()),
i,
STR16(p->GetLabelForHost()),
p->GetMin(),
p->GetMax(),
p->GetDefault(),
0, // continuous
flags,
unitID);
param->setPrecision (p->GetPrecision());
parameters.addParameter(param);
break;
}
case IParam::kTypeEnum:
case IParam::kTypeBool:
{
StringListParameter* param = new StringListParameter (STR16(p->GetNameForHost()),
i,
STR16(p->GetLabelForHost()),
flags | ParameterInfo::kIsList,
unitID);
int nDisplayTexts = p->GetNDisplayTexts();
assert(nDisplayTexts);
for (int j=0; j<nDisplayTexts; j++)
{
param->appendString(STR16(p->GetDisplayText(j)));
}
parameters.addParameter(param);
break;
}
default:
break;
}
}
}
OnHostIdentified();
RestorePreset(0);
return result;
}
示例5: VSTDispatcher
//.........这里部分代码省略.........
}
return 0;
}
case effSetChunk: {
if (ptr) {
bool isBank = (!idx);
ByteChunk* pChunk = (isBank ? &(_this->mBankState) : &(_this->mState));
pChunk->Resize(value);
memcpy(pChunk->GetBytes(), ptr, value);
int pos = 0;
int iplugVer = GetIPlugVerFromChunk(pChunk, &pos);
isBank &= (iplugVer >= 0x010000);
if (isBank) {
pos = _this->UnserializePresets(pChunk, pos);
//pos = _this->UnserializeState(pChunk, pos);
}
else {
pos = _this->UnserializeState(pChunk, pos);
_this->ModifyCurrentPreset();
}
if (pos >= 0) {
_this->RedrawParamControls();
return 1;
}
}
return 0;
}
case effProcessEvents: {
VstEvents* pEvents = (VstEvents*) ptr;
if (pEvents && pEvents->events) {
for (int i = 0; i < pEvents->numEvents; ++i) {
VstEvent* pEvent = pEvents->events[i];
if (pEvent) {
if (pEvent->type == kVstMidiType) {
VstMidiEvent* pME = (VstMidiEvent*) pEvent;
IMidiMsg msg(pME->deltaFrames, pME->midiData[0], pME->midiData[1], pME->midiData[2]);
_this->ProcessMidiMsg(&msg);
//#ifdef TRACER_BUILD
// msg.LogMsg();
//#endif
}
else if (pEvent->type == kVstSysExType) {
VstMidiSysexEvent* pSE = (VstMidiSysexEvent*) pEvent;
ISysEx sysex(pSE->deltaFrames, (const BYTE*)pSE->sysexDump, pSE->dumpBytes);
_this->ProcessSysEx(&sysex);
}
}
}
return 1;
}
return 0;
}
case effCanBeAutomated: {
return 1;
}
case effGetInputProperties: {
if (ptr && idx >= 0 && idx < _this->NInChannels()) {
VstPinProperties* pp = (VstPinProperties*) ptr;
pp->flags = kVstPinIsActive;
if (!(idx%2) && idx < _this->NInChannels()-1)
{
pp->flags |= kVstPinIsStereo;
}
sprintf(pp->label, "Input %d", idx + 1);
return 1;
}
示例6: WndProc
// static
LRESULT CALLBACK IGraphicsWin::WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg == WM_CREATE) {
LPCREATESTRUCT lpcs = (LPCREATESTRUCT) lParam;
SetWindowLongPtr(hWnd, GWLP_USERDATA, (LPARAM) (lpcs->lpCreateParams));
int mSec = int(1000.0 / sFPS);
SetTimer(hWnd, IPLUG_TIMER_ID, mSec, NULL);
SetFocus(hWnd);
return 0;
}
IGraphicsWin* pGraphics = (IGraphicsWin*) GetWindowLongPtr(hWnd, GWLP_USERDATA);
char txt[MAX_EDIT_LEN];
if (!pGraphics || hWnd != pGraphics->mPlugWnd) {
return DefWindowProc(hWnd, msg, wParam, lParam);
}
if (pGraphics->mParamEditWnd && pGraphics->mParamEditMsg == kEditing) {
if (msg == WM_RBUTTONDOWN) {
pGraphics->mParamEditMsg = kCancel;
return 0;
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
switch (msg) {
case WM_TIMER: {
if (wParam == IPLUG_TIMER_ID) {
if (pGraphics->mParamEditWnd && pGraphics->mParamEditMsg != kNone) {
switch (pGraphics->mParamEditMsg) {
case kUpdate: {
if (!pGraphics->mEdParam) break;
pGraphics->mEdParam->GetDisplayForHost(txt);
char currentText[MAX_PARAM_LEN];
SendMessage(pGraphics->mParamEditWnd, WM_GETTEXT, MAX_PARAM_LEN, (LPARAM) currentText);
if (strcmp(txt, currentText))
{
IParam* pParam = pGraphics->mEdParam;
if (pParam->GetNDisplayTexts() && (pParam->Type() == IParam::kTypeEnum || pParam->Type() == IParam::kTypeBool))
SendMessage(pGraphics->mParamEditWnd, CB_SELECTSTRING, -1, (LPARAM) txt);
else
SendMessage(pGraphics->mParamEditWnd, WM_SETTEXT, 0, (LPARAM) txt);
}
break;
}
case kCommit: {
SendMessage(pGraphics->mParamEditWnd, WM_GETTEXT, MAX_EDIT_LEN, (LPARAM) txt);
pGraphics->SetFromStringAfterPrompt(pGraphics->mEdControl, pGraphics->mEdParam, txt);
// Fall through.
}
case kCancel:
{
SetWindowLongPtr(pGraphics->mParamEditWnd, GWLP_WNDPROC, (LPARAM) pGraphics->mDefEditProc);
DestroyWindow(pGraphics->mParamEditWnd);
pGraphics->mParamEditWnd = 0;
pGraphics->mEdParam = 0;
pGraphics->mEdControl = 0;
pGraphics->mDefEditProc = 0;
}
break;
}
pGraphics->mParamEditMsg = kNone;
//return 0;
}
IRECT dirtyR;
if (pGraphics->IsDirty(&dirtyR)) {
RECT r = { dirtyR.L, dirtyR.T, dirtyR.R, dirtyR.B };
InvalidateRect(hWnd, &r, FALSE);
UpdateWindow(hWnd);
if (pGraphics->mParamEditWnd) {
pGraphics->mParamEditMsg = kUpdate;
}
}
}
return 0;
}
case WM_RBUTTONDOWN: {
if (pGraphics->mParamEditWnd) {
pGraphics->mParamEditMsg = kCancel;
return 0;
}
// Else fall through.
}
case WM_LBUTTONDOWN: {
if (pGraphics->mParamEditWnd) pGraphics->mParamEditMsg = kCommit;
SetCapture(hWnd);
pGraphics->OnMouseDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), &GetMouseMod(wParam));
return 0;
}
case WM_MOUSEMOVE: {
if (!(wParam & (MK_LBUTTON | MK_RBUTTON))) {
if (pGraphics->OnMouseOver(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), &GetMouseMod(wParam))) {
TRACKMOUSEEVENT eventTrack = { sizeof(TRACKMOUSEEVENT), TME_LEAVE, hWnd, HOVER_DEFAULT };
TrackMouseEvent(&eventTrack);
}
}
//.........这里部分代码省略.........
示例7: if
tresult PLUGIN_API IPlugVST3::initialize (FUnknown* context)
{
TRACE;
tresult result = SingleComponentEffect::initialize (context);
if (result == kResultOk)
{
addAudioInput (STR16("Audio Input"), getSpeakerArrForChans(NInChannels()) );
addAudioOutput (STR16("Audio Output"), getSpeakerArrForChans(NOutChannels()) );
if (mScChans == 1)
addAudioInput(STR16("Sidechain Input"), SpeakerArr::kMono, kAux, 0);
else if (mScChans >= 2)
{
mScChans = 2;
addAudioInput(STR16("Sidechain Input"), SpeakerArr::kStereo, kAux, 0);
}
if(mDoesMidi) {
addEventInput (STR16("MIDI In"), 1);
addEventOutput(STR16("MIDI Out"), 1);
}
for (int i=0;i<NParams();i++)
{
IParam *p = GetParam(i);
int32 flags = 0;
if (p->GetCanAutomate()) {
flags |= ParameterInfo::kCanAutomate;
}
switch (p->Type()) {
case IParam::kTypeDouble:
case IParam::kTypeInt:
{
Parameter* param = new RangeParameter ( STR16(p->GetNameForHost()),
i,
STR16(p->GetLabelForHost()),
p->GetMin(),
p->GetMax(),
p->GetDefault(),
p->GetStep(),
flags);
param->setPrecision (p->GetPrecision());
parameters.addParameter (param);
break;
}
case IParam::kTypeEnum:
case IParam::kTypeBool:
{
StringListParameter* param = new StringListParameter (STR16(p->GetNameForHost()),
i,
STR16(p->GetLabelForHost()),
flags | ParameterInfo::kIsList);
int nDisplayTexts = p->GetNDisplayTexts();
assert(nDisplayTexts);
for (int j=0; j<nDisplayTexts; j++)
{
param->appendString(STR16(p->GetDisplayText(j)));
}
parameters.addParameter (param);
break;
}
default:
break;
}
}
}
return result;
}
示例8: EffectInit
AAX_Result IPlugAAX::EffectInit()
{
TRACE;
AAX_CString bypassID = NULL;
this->GetMasterBypassParameter( &bypassID );
mBypassParameter = new AAX_CParameter<bool>(bypassID.CString(),
AAX_CString("Master Bypass"),
false,
AAX_CBinaryTaperDelegate<bool>(),
AAX_CBinaryDisplayDelegate<bool>("bypass", "on"),
true);
mBypassParameter->SetNumberOfSteps( 2 );
mBypassParameter->SetType( AAX_eParameterType_Discrete );
mParameterManager.AddParameter(mBypassParameter);
for (int i=0;i<NParams();i++)
{
IParam *p = GetParam(i);
AAX_IParameter* param = 0;
WDL_String* paramID = new WDL_String("_", 1);
paramID->SetFormatted(32, "%i", i+kAAXParamIdxOffset);
mParamIDs.Add(paramID);
switch (p->Type())
{
case IParam::kTypeDouble:
{
param = new AAX_CParameter<double>(paramID->Get(),
AAX_CString(p->GetNameForHost()),
p->GetDefault(),
AAX_CIPlugTaperDelegate<double>(p->GetMin(), p->GetMax(), p->GetShape()),
AAX_CUnitDisplayDelegateDecorator<double>( AAX_CNumberDisplayDelegate<double>(), AAX_CString(p->GetLabelForHost())),
p->GetCanAutomate());
param->SetNumberOfSteps(128); // TODO: check this https://developer.digidesign.com/index.php?L1=5&L2=13&L3=56
param->SetType(AAX_eParameterType_Continuous);
break;
}
case IParam::kTypeInt:
{
param = new AAX_CParameter<int>(paramID->Get(),
AAX_CString(p->GetNameForHost()),
(int)p->GetDefault(),
AAX_CLinearTaperDelegate<int>((int)p->GetMin(), (int)p->GetMax()),
AAX_CUnitDisplayDelegateDecorator<int>( AAX_CNumberDisplayDelegate<int>(), AAX_CString(p->GetLabelForHost())),
p->GetCanAutomate());
param->SetNumberOfSteps(128);
param->SetType(AAX_eParameterType_Continuous);
break;
}
case IParam::kTypeEnum:
case IParam::kTypeBool:
{
int nTexts = p->GetNDisplayTexts();
std::map<int, AAX_CString> displayTexts;
for (int j=0; j<p->GetNDisplayTexts(); j++)
{
int value;
const char* text = p->GetDisplayTextAtIdx(j, &value);
displayTexts.insert(std::pair<int, AAX_CString>(value, AAX_CString(text)) );
}
param = new AAX_CParameter<int>(paramID->Get(),
AAX_CString(p->GetNameForHost()),
(int)p->GetDefault(),
AAX_CLinearTaperDelegate<int>((int)p->GetMin(), (int)p->GetMax()),
AAX_CStringDisplayDelegate<int>(displayTexts),
p->GetCanAutomate());
param->SetNumberOfSteps(nTexts);
param->SetType(AAX_eParameterType_Discrete);
break;
}
default:
break;
}
mParameterManager.AddParameter(param);
}
AAX_CSampleRate sr;
Controller()->GetSampleRate(&sr);
SetSampleRate(sr);
Reset();
return AAX_SUCCESS;
}