コード例 #1
0
ファイル: audioeffect.cpp プロジェクト: Fooway/ChuckDelay
/*!
	The constructor of your class is passed a parameter of the type \e audioMasterCallback. The actual 
	mechanism in which your class gets constructed is not important right now. Effectively your class is 
	constructed by the hosting application, which passes an object of type \e audioMasterCallback that 
	handles the interaction with the plug-in. You pass this on to the base class' constructor and then 
	can forget about it.

	\param audioMaster Passed by the Host and handles interaction
	\param numPrograms Pass the number of programs the plug-in provides
	\param numParams Pass the number of parameters the plug-in provides
	
\code
MyPlug::MyPlug (audioMasterCallback audioMaster)
: AudioEffectX (audioMaster, 1, 1)    // 1 program, 1 parameter only
{
	setNumInputs (2); // stereo in
	setNumOutputs (2); // stereo out
	setUniqueID ('MyPl'); // you must change this for other plug-ins!
	canProcessReplacing (); // supports replacing mode
}
\endcode

	\sa setNumInputs, setNumOutputs, setUniqueID, canProcessReplacing
*/
AudioEffect::AudioEffect (audioMasterCallback audioMaster, VstInt32 numPrograms, VstInt32 numParams)
: audioMaster (audioMaster)
, editor (0)
, sampleRate (44100.f)
, blockSize (1024)
, numPrograms (numPrograms)
, numParams (numParams)
, curProgram (0)
{
	memset (&cEffect, 0, sizeof (cEffect));

	cEffect.magic = kEffectMagic;
	cEffect.dispatcher = dispatchEffectClass;
	cEffect.DECLARE_VST_DEPRECATED (process) = DECLARE_VST_DEPRECATED (processClass);
	cEffect.setParameter = setParameterClass;
	cEffect.getParameter = getParameterClass;
	cEffect.numPrograms  = numPrograms;
	cEffect.numParams    = numParams;
	cEffect.numInputs  = 1;		// mono input
	cEffect.numOutputs = 2;		// stereo output
	cEffect.DECLARE_VST_DEPRECATED (ioRatio) = 1.f;
	cEffect.object = this;
	cEffect.uniqueID = CCONST ('N', 'o', 'E', 'f');
	cEffect.version  = 1;
	cEffect.processReplacing = processClassReplacing;

#if VST_2_4_EXTENSIONS
	canProcessReplacing (); // mandatory in VST 2.4!
	cEffect.processDoubleReplacing = processClassDoubleReplacing;
#endif
}
コード例 #2
0
ファイル: TutorialVST2Effect.cpp プロジェクト: DaniM/lyngo
//------------------------------------------------------------------------------------
TutorialVST2Effect::TutorialVST2Effect (audioMasterCallback audioMaster)
: AudioEffectX (audioMaster, 1, kNumParameters)
{
	setUniqueID (CCONST('G', 'U', 'I', '0'));
	setNumInputs (2);
	setNumOutputs (2);
	parameters[kLeftVolumeParameter] = 1.f;
	parameters[kRightVolumeParameter] = 1.f;

	extern AEffGUIEditor* createEditor (AudioEffectX*);
	setEditor (createEditor (this));
}
コード例 #3
0
ファイル: audioeffect.cpp プロジェクト: Fooway/ChuckDelay
//-------------------------------------------------------------------------------------------------------
VstIntPtr AudioEffect::dispatcher (VstInt32 opcode, VstInt32 index, VstIntPtr value, void* ptr, float opt)
{
	VstIntPtr v = 0;
	
	switch (opcode)
	{
		case effOpen:				open ();											break;
		case effClose:				close ();											break;
		case effSetProgram:			if (value < numPrograms) setProgram ((VstInt32)value); break;
		case effGetProgram:			v = getProgram ();									break;
		case effSetProgramName: 	setProgramName ((char*)ptr);						break;
		case effGetProgramName: 	getProgramName ((char*)ptr);						break;
		case effGetParamLabel:		getParameterLabel (index, (char*)ptr);				break;
		case effGetParamDisplay:	getParameterDisplay (index, (char*)ptr);			break;
		case effGetParamName:		getParameterName (index, (char*)ptr);				break;

		case effSetSampleRate:		setSampleRate (opt);								break;
		case effSetBlockSize:		setBlockSize ((VstInt32)value);						break;
		case effMainsChanged:		if (!value) suspend (); else resume ();				break;
	#if !VST_FORCE_DEPRECATED
		case effGetVu:				v = (VstIntPtr)(getVu () * 32767.);					break;
	#endif

		//---Editor------------
		case effEditGetRect:		if (editor) v = editor->getRect ((ERect**)ptr) ? 1 : 0;	break;
		case effEditOpen:			if (editor) v = editor->open (ptr) ? 1 : 0;			break;
		case effEditClose:			if (editor) editor->close ();						break;		
		case effEditIdle:			if (editor) editor->idle ();						break;
		
	#if (TARGET_API_MAC_CARBON && !VST_FORCE_DEPRECATED)
		case effEditDraw:			if (editor) editor->draw ((ERect*)ptr);				break;
		case effEditMouse:			if (editor) v = editor->mouse (index, value);		break;
		case effEditKey:			if (editor) v = editor->key (value);				break;
		case effEditTop:			if (editor) editor->top ();							break;
		case effEditSleep:			if (editor) editor->sleep ();						break;
	#endif
		
		case DECLARE_VST_DEPRECATED (effIdentify):	v = CCONST ('N', 'v', 'E', 'f');	break;

		//---Persistence-------
		case effGetChunk:			v = getChunk ((void**)ptr, index ? true : false);	break;
		case effSetChunk:			v = setChunk (ptr, (VstInt32)value, index ? true : false);	break;
	}
	return v;
}
コード例 #4
0
bool CSelectPluginDlg::VerifyPlug(VSTPluginLib *plug, CWnd *parent)
//-----------------------------------------------------------------
{
#ifndef NO_VST
	// TODO: Keep these lists up-to-date.
	static const struct
	{
		int32 id1;
		int32 id2;
		char *name;
		char *problem;
	} problemPlugs[] =
	{
		{ kEffectMagic, CCONST('N', 'i', '4', 'S'), "Native Instruments B4", "*  v1.1.1 hangs on playback. Do not proceed unless you have v1.1.5 or newer.  *" },
		{ kEffectMagic, CCONST('m', 'd', 'a', 'C'), "MDA Degrade", "*  Old versions of this plugin can crash OpenMPT.\nEnsure that you have the latest version of this plugin.  *" },
		{ kEffectMagic, CCONST('f', 'V', '2', 's'), "Farbrausch V2", "*  This plugin can cause OpenMPT to freeze if being used in a combination with various other plugins.\nIt is recommended to not use V2 in combination with any other plugins or use it brigded mode only.  *" },
		{ kEffectMagic, CCONST('f', 'r', 'V', '2'), "Farbrausch V2", "*  This plugin can cause OpenMPT to freeze if being used in a combination with various other plugins.\nIt is recommended to not use V2 in combination with any other plugins or use it brigded mode only.  *" },
		{ kEffectMagic, CCONST('M', 'M', 'I', 'D'), "MIDI Input Output", "* The MIDI Input / Output plugin is now built right into OpenMPT and should not be loaded from an external file. *" },
	};

	// Plugins that should always be bridged.
	static const struct
	{
		int32 id1;
		int32 id2;
		bool useBridge;
		bool shareInstance;
	} bridgedPlugs[] =
	{
		{ kEffectMagic, CCONST('f', 'V', '2', 's'), true, true },	// Single instances of V2 can communicate (I think)
		{ kEffectMagic, CCONST('f', 'r', 'V', '2'), true, false },
		{ kEffectMagic, CCONST('S', 'K', 'V', '3'), false, true },	// SideKick v3 always has to run in a shared instance
		{ kEffectMagic, CCONST('Y', 'W', 'S', '!'), false, true },	// You Wa Shock ! always has to run in a shared instance
	};

	for(auto &p : problemPlugs)
	{
		if(p.id2 == plug->pluginId2 && p.id1 == plug->pluginId1)
		{
			std::string s = mpt::String::Print("WARNING: This plugin has been identified as %1,\nwhich is known to have the following problem with OpenMPT:\n\n%2\n\nWould you still like to add this plugin to the library?", p.name, p.problem);
			if(Reporting::Confirm(s, false, false, parent) == cnfNo)
			{
				return false;
			}
			break;
		}
	}

	for(auto &p : bridgedPlugs)
	{
		if(p.id2 == plug->pluginId2 && p.id1 == plug->pluginId1)
		{
			plug->useBridge = p.useBridge;
			plug->shareBridgeInstance = p.shareInstance;
			plug->WriteToCache();
			break;
		}
	}
#endif // NO_VST
	return true;
}
コード例 #5
0
void CSelectPluginDlg::OnOK()
//---------------------------
{
	if(m_pPlugin==nullptr) { CDialog::OnOK(); return; }

	bool changed = false;
	CVstPluginManager *pManager = theApp.GetPluginManager();
	VSTPluginLib *pNewPlug = GetSelectedPlugin();
	VSTPluginLib *pFactory = nullptr;
	IMixPlugin *pCurrentPlugin = nullptr;
	if (m_pPlugin) pCurrentPlugin = m_pPlugin->pMixPlugin;
	if ((pManager) && (pManager->IsValidPlugin(pNewPlug))) pFactory = pNewPlug;

	if (pFactory)
	{
		// Plugin selected
		if ((!pCurrentPlugin) || &pCurrentPlugin->GetPluginFactory() != pFactory)
		{
			CriticalSection cs;

			// Destroy old plugin, if there was one.
			m_pPlugin->Destroy();

			// Initialize plugin info
			MemsetZero(m_pPlugin->Info);
			m_pPlugin->Info.dwPluginId1 = pFactory->pluginId1;
			m_pPlugin->Info.dwPluginId2 = pFactory->pluginId2;
			m_pPlugin->editorX = m_pPlugin->editorY = int32_min;

#ifndef NO_VST
			if(m_pPlugin->Info.dwPluginId1 == kEffectMagic)
			{
				switch(m_pPlugin->Info.dwPluginId2)
				{
					// Enable drymix by default for these known plugins
				case CCONST('S', 'c', 'o', 'p'):
					m_pPlugin->SetWetMix();
					break;
				}
			}
#endif // NO_VST

			mpt::String::Copy(m_pPlugin->Info.szName, pFactory->libraryName.ToLocale().c_str());
			mpt::String::Copy(m_pPlugin->Info.szLibraryName, pFactory->libraryName.ToUTF8().c_str());

			cs.Leave();

			// Now, create the new plugin
			if(pManager && m_pModDoc)
			{
				pManager->CreateMixPlugin(*m_pPlugin, m_pModDoc->GetrSoundFile());
				if (m_pPlugin->pMixPlugin)
				{
					IMixPlugin *p = m_pPlugin->pMixPlugin;
					const CString name = p->GetDefaultEffectName();
					if(!name.IsEmpty())
					{
						mpt::String::Copy(m_pPlugin->Info.szName, name.GetString());
					}
					// Check if plugin slot is already assigned to any instrument, and if not, create one.
					if(p->IsInstrument() && m_pModDoc->HasInstrumentForPlugin(m_nPlugSlot) == INSTRUMENTINDEX_INVALID)
					{
						m_pModDoc->InsertInstrumentForPlugin(m_nPlugSlot);
					}
				} else
				{
					MemsetZero(m_pPlugin->Info);
				}
			}
			changed = true;
		}
	} else if(m_pPlugin->IsValidPlugin())
	{
		// No effect
		CriticalSection cs;
		m_pPlugin->Destroy();
		// Clear plugin info
		MemsetZero(m_pPlugin->Info);
		changed = true;
	}

	//remember window size:
	SaveWindowPos();

	if(changed)
	{
		if(m_pPlugin->Info.dwPluginId2)
			TrackerSettings::Instance().gnPlugWindowLast = m_pPlugin->Info.dwPluginId2;
		if(m_pModDoc)
		{
			m_pModDoc->UpdateAllViews(nullptr, PluginHint(static_cast<PLUGINDEX>(m_nPlugSlot + 1)).Info().Names());
		}
		CDialog::OnOK();
	} else
	{
		CDialog::OnCancel();
	}
}