COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 01-28-2017, 11:46 PM   #1
Caiminatrix
Human being with feelings
 
Join Date: Oct 2016
Posts: 24
Default Workaround for MIDI CC for VST3

It seems like MIDI CC messages (e.g. the Pitch Wheel, Mod Wheel) are not yet handled by WDL-OL for VST3, like NoteOn and NoteOff are. When I debug my code I put a breakpoint at the start of ProcessMidiMsg(IMidiMsg *pMsg) and then I roll the pitch bend wheel. It does get called when I NoteOn/Off. My pitch wheel does work in Reaper on ReaSynth, so I know it's sending MIDI CC messages to Reaper.

Has anyone found a workaround?
Caiminatrix is offline   Reply With Quote
Old 01-28-2017, 11:49 PM   #2
Caiminatrix
Human being with feelings
 
Join Date: Oct 2016
Posts: 24
Default

Code:
void MySynth::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
{
	// Mutex is already locked for us.

	double* out1 = outputs[0];
	double* out2 = outputs[1];

	for (int offset = 0; offset < nFrames; ++offset, ++out1, ++out2)
	{

		// process MIDI
		while (!mMidiQueue.Empty())
		{
			IMidiMsg* pMsg = mMidiQueue.Peek();
			if (pMsg->mOffset > offset) break;

			int status = pMsg->StatusMsg();

			switch (status)
			{
			case IMidiMsg::kPitchWheel:
			{
				double bend = pMsg->PitchWheel();
				m_Synth.setPitchBend(bend);
				break;
			}
			case IMidiMsg::kNoteOn:
			{
				int note = pMsg->NoteNumber();
				int vel = pMsg->Velocity(); // [0, 127]
				m_Synth.beginAttack(note, vel);
				break;
			}
			case IMidiMsg::kNoteOff:
			{
				int note = pMsg->NoteNumber();
				m_Synth.beginRelease(note);
				break;
			}

			default:
			{
				break;
			}
			}

			mMidiQueue.Remove();
		}

		// process audio
		*out1 = 0.0;
		*out2 = 0.0;

		m_Synth.process(out1, out2);

	}
	mMidiQueue.Flush(nFrames);
}

void MySynth::ProcessMidiMsg(IMidiMsg *pMsg)
{

// break point here doesn't trigger when I roll pitch wheel on my MIDI controller
// pitch wheel works on ReaSynth in REAPER


	IMidiMsg::EStatusMsg status = pMsg->StatusMsg();
	if (status == IMidiMsg::kNoteOn || status == IMidiMsg::kNoteOff || status == IMidiMsg::kPitchWheel)
	{
		mMidiQueue.Add(pMsg);
	}
}
Caiminatrix is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.