HRESULT CControlSurfaceProbe::MidiInShortMsg( DWORD dwShortMsg )
{
	// TODO: Handle a MIDI short message which has just been sent
	// *from* the surface.  In other words, the user has just moved
	// a fader or pressed a button; the surface sent a MIDI message;
	// SONAR received the message, and routed back into this DLL.

	// A typical implementation of this would be:

	// [1] "Crack" the MIDI message to determine its type (note, CC, etc.)

	// [2] Confirm that the message did actually come from the surface.
	// (The user may have daisy-chained gear, and you may have been
	//	given data sent from some other device.)

	// [3] Based on the type of message and the state of the surface
	// module, update a SONAR mixer or transport parameter, i.e., make
	// a call to m_pMixer->SetMixParam or m_pTransport->SetTransportState.
	// Or, particularly if your surface has buttons, you might respond by
	// setting some internal state, i.e.,
	//		m_bEffectSelected = TRUE;

	CCriticalSectionAuto csa( &m_cs );

	return S_OK;
}
HRESULT CControlSurfaceProbe::RefreshSurface( DWORD fdwRefresh, DWORD dwCookie )
{
	CCriticalSectionAuto csa( &m_cs );

	m_dwUpdateCount++;

	return S_OK;
}
HRESULT CMackieControlBase::Connect( IUnknown* pUnk, HWND hwndApp )
{
//	TRACE("CMackieControlBase::Connect()\n");

	// Note: You will probably not need to change this implementation.
	// The wizard has already generated code to obtain all of the ISonarXXX
	// interfaces that are available.

	CCriticalSectionAuto csa( &m_cs );

	HRESULT hr = S_OK;

	releaseSonarInterfaces();
	if (FAILED( hr = pUnk->QueryInterface( IID_ISonarMidiOut, (void**)&m_pMidiOut ) ))
		return hr;
	if (FAILED( hr = pUnk->QueryInterface( IID_ISonarKeyboard, (void**)&m_pKeyboard ) ))
		return hr;
	if (FAILED( hr = pUnk->QueryInterface( IID_ISonarCommands, (void**)&m_pCommands ) ))
		return hr;
	if (FAILED( hr = pUnk->QueryInterface( IID_ISonarProject, (void**)&m_pProject ) ))
		return hr;
	if (FAILED( hr = pUnk->QueryInterface( IID_ISonarMixer, (void**)&m_pMixer ) ))
		return hr;
	if (FAILED( hr = pUnk->QueryInterface( IID_ISonarTransport, (void**)&m_pTransport ) ))
		return hr;

	if (FAILED(      pUnk->QueryInterface( IID_ISonarIdentity, (void**)&m_pSonarIdentity ) ))
	{
		// Don't worry of this fails, it means it's an old version of SONAR
		TRACE("No ISonarIdentity interface available\n");
		m_pSonarIdentity = NULL; // Just in case

		// In this case, use our internal id generator
		m_dwUniqueId = m_cState.GetNextUniqueId();
	}
	else if ( FAILED ( hr = m_pSonarIdentity->GetUniqueSurfaceId( this, &m_dwUniqueId ) ) )
		return hr;

	if ( FAILED( pUnk->QueryInterface( IID_ISonarMixer2, (void**)&m_pMixer2) ) )
		m_pMixer2 = NULL;
	
	if ( FAILED( pUnk->QueryInterface( IID_ISonarParamMapping, (void**)&m_pParamMapping ) ) )
		m_pParamMapping = NULL;
	
	if ( FAILED( pUnk->QueryInterface( IID_ISonarIdentity2, (void**)&m_pSonarIdentity2 ) ) )
		m_pSonarIdentity2 = NULL;
	else if ( FAILED ( hr = m_pSonarIdentity2->GetSupportedRefreshFlags( &m_dwSupportedRefreshFlags ) ) )
		return hr;

	// Call the child class OnConnect()...
	OnConnect();

	// OK, now we're connected
	m_bConnected = true;

	return hr;
}
Example #4
0
bool MainThreadTaskManager::addTask(MainThreadTask * task)
{
	ACSWrapper csa(&m_lock);
	if(m_shutdown)
		return false;
	m_tasks.push_back(task);
	m_empty = false;
	return true;
}
void CControlSurfaceProbe::SetValue( SONAR_MIXER_STRIP eMixerStrip, DWORD dwStripNum, SONAR_MIXER_PARAM eMixerParam, DWORD dwParamNum, float fValue )
{
	CCriticalSectionAuto csa( &m_cs );

	if (!m_pMixer)
		return;

	m_pMixer->SetMixParam(eMixerStrip, dwStripNum, eMixerParam, dwParamNum, fValue, MIX_TOUCH_NORMAL);
}
void CControlSurfaceProbe::SetStripNum(DWORD dwStripNum)
{
	CCriticalSectionAuto csa( &m_cs );

	m_dwStripNum = dwStripNum;

	if ( m_pSonarParamMapping )
		m_pSonarParamMapping->OnContextSwitch( m_dwSurfaceID );
}
void CControlSurfaceProbe::SetTransportState(SONAR_TRANSPORT_STATE eTransportState, bool bEnable)
{
	CCriticalSectionAuto csa( &m_cs );

	if (!m_pTransport)
		return;

	HRESULT hr = m_pTransport->SetTransportState(eTransportState, (bEnable) ? TRUE : FALSE);
}
void CControlSurfaceProbe::SetMixerStrip(SONAR_MIXER_STRIP eMixerStrip)
{
	CCriticalSectionAuto csa( &m_cs );

	m_eMixerStrip = eMixerStrip;

	if ( m_pSonarParamMapping )
		m_pSonarParamMapping->OnContextSwitch( m_dwSurfaceID );
}
HRESULT CACTController::Connect( IUnknown* pUnk, HWND hwndApp )
{
	// Note: You will probably not need to change this implementation.
	// The wizard has already generated code to obtain all of the ISonarXXX
	// interfaces that are available.

	CCriticalSectionAuto csa( &m_cs );

	HRESULT hr = S_OK;

	releaseSonarInterfaces();
	if (FAILED( hr = pUnk->QueryInterface( IID_ISonarMidiOut, (void**)&m_pMidiOut ) ))
		return hr;
	if (FAILED( hr = pUnk->QueryInterface( IID_ISonarKeyboard, (void**)&m_pKeyboard ) ))
		return hr;
	if (FAILED( hr = pUnk->QueryInterface( IID_ISonarCommands, (void**)&m_pCommands ) ))
		return hr;
	if (FAILED( hr = pUnk->QueryInterface( IID_ISonarProject, (void**)&m_pProject ) ))
		return hr;
	if (FAILED( hr = pUnk->QueryInterface( IID_ISonarMixer, (void**)&m_pMixer ) ))
		return hr;
	if (FAILED( hr = pUnk->QueryInterface( IID_ISonarTransport, (void**)&m_pTransport ) ))
		return hr;

	// try to obtain the optional ISonarIdentity Interface from the host
	hr = pUnk->QueryInterface( IID_ISonarIdentity, (void**)&m_pSonarIdentity );
	if ( SUCCEEDED( hr ))
	{
		// Obtain a unique instance ID.  This ID will be the same for this surface each time
		// the host is restarted as long as the same surfaces are active in the host.
		m_dwSurfaceId = 0;
		hr = m_pSonarIdentity->GetUniqueSurfaceId( reinterpret_cast<IControlSurface*>(this), &m_dwSurfaceId );
		if ( FAILED( hr ))
			return hr;
	}

	if (FAILED( pUnk->QueryInterface( IID_ISonarParamMapping, (void**)&m_pSonarParamMapping ) ))
	{
		// Just in case
		m_pSonarParamMapping = NULL;
	}

	if (FAILED( pUnk->QueryInterface( IID_ISonarMixer2, (void**)&m_pSonarMixer2 ) ))
	{
		// Just in case
		m_pSonarMixer2 = NULL;
	}

	// Call the child class OnConnect()...
	OnConnect();

	// OK, now we're connected
	m_bConnected = true;

	return hr;
}
HRESULT CMackieControlXT::GetSizeMax( ULARGE_INTEGER* pcbSize )
{
	CCriticalSectionAuto csa( &m_cs );

	// Assign the size of the data you write to the registry in Save() to pcbSize->LowPart
	pcbSize->LowPart = 0;
	pcbSize->HighPart = 0;

	return S_OK;
}
//////////////////////////////////////////////////////////////////
// Return the count of ACT parameters you are maintaining
HRESULT CSampleSurface::GetDynamicControlCount( DWORD* pdwCount )
{
	if (!pdwCount)
		return E_POINTER;

	CSFKCriticalSectionAuto csa( m_cs );

	*pdwCount = 0;

	return S_OK;
}
HRESULT C$$Safe_root$$::Disconnect()
{
	// Note: You will probably not need to change this implementation.
	// The wizard has already generated code to release all ISonarXXX
	// interfaces currently held.

	CCriticalSectionAuto csa( &m_cs );

	releaseSonarInterfaces();
	return S_OK;
}
CMackieControlBase::~CMackieControlBase() 
{
//	TRACE("CMackieControlBase::~CMackieControlBase()\n");

	CCriticalSectionAuto csa(m_cState.GetCS());
	m_cState.RemoveUnit(this);

	releaseSonarInterfaces();
	::DeleteCriticalSection( &m_cs );
	::InterlockedDecrement( &g_lComponents );
}
CMackieControlBase::CMackieControlBase() :
	m_cRef( 1 ),
	m_bDirty( FALSE ),
	m_dwUniqueId( 0 ),
	m_pMidiOut( NULL ),
	m_pKeyboard( NULL ),
	m_pCommands( NULL ),
	m_pProject( NULL ),
	m_pMixer( NULL ),
	m_pMixer2( NULL ),
	m_pParamMapping( NULL ),
	m_pTransport( NULL ),
	m_pSonarIdentity( NULL ),
	m_pSonarIdentity2( NULL ),
	m_dwSupportedRefreshFlags( 0 ),
	m_hwndApp( NULL )
{ 
//	TRACE("CMackieControlBase::CMackieControlBase()\n");

	::InterlockedIncrement( &g_lComponents );
	::InitializeCriticalSection( &m_cs );

	m_bConnected = false;
	m_dwRefreshCount = 0;
	m_bExpectedDeviceType = 0x00;
	m_bDeviceType = 0x00;
	m_bHaveSerialNumber = false;
	::memset(m_bSerialNumber, 0, LEN_SERIAL_NUMBER);
	m_dwUnitStripNumOffset = 0;
	m_bBindMuteSoloArm = false;

	// We don't use all of these, but it makes indexing easier
	for (int n = 0; n < NUM_SWITCH_AND_LED_IDS; n++)
	{
		m_bSwitches[n] = false;
		m_bLEDs[n] = 0xFF;
	}

	m_bRefreshWhenDone = false;
	m_bForceRefreshWhenDone = false;
	m_bRefreshAllWhenDone = false;
	m_bForceRefreshAllWhenDone = false;

	CCriticalSectionAuto csa(m_cState.GetCS());

	m_cState.AddUnit(this);

	// Load the plugin mappings here so that we can locate the .ini file correctly
	m_cState.LoadPluginMappings();

	UpdateToolbarDisplay(true);
}
HRESULT CMackieControlXT::Save( IStream* pStm, BOOL bClearDirty )
{
	CCriticalSectionAuto csa( &m_cs );

	// Here you should write any data to pStm which you wish to store.
	// Typically you will write values for all of your properties.
	// Save() and Load() are used for the host application to provide "Presets"
	// and to persist your effect in application project files.

	// Valid IPersistStream::Write() errors include only STG_E_MEDIUMFULL
	// and STG_E_CANTSAVE. Don't simply return whatever IStream::Write() returned.
	return S_OK;
}
HRESULT CMackieControlXT::Load( IStream* pStm )
{
	CCriticalSectionAuto csa( &m_cs );

	// Here you should read the data using the format you used in Save().
	// Save() and Load() are used for the host application to provide "Presets"
	// and to persist your effect in application project files.
	
	// Note: IStream::Read() can return S_FALSE, so don't use SUCCEEDED()
	// Valid IPersistStream::Load() errors include only E_OUTOFMEMORY and
	// E_FAIL. Don't simply return whatever IStream::Read() returned.
	return S_OK;
}
void CControlSurfaceProbe::GetMetersValues(CString *str)
{
	CCriticalSectionAuto csa( &m_cs );

	if (!m_pVUMeters)
	{
		*str = _T("m_pVUMeters is NULL");
		return;
	}

	DWORD dwCount = 0;

	HRESULT hr = m_pVUMeters->GetMeterChannelCount(m_eMixerStrip, m_dwStripNum, &dwCount);

	if (FAILED(hr))
	{
		*str = _T("GetMeterChannelCount FAILED");
		return;
	}

	if (!m_pIdentity)
	{
		*str = "m_pIdentity is NULL";
		return;
	}

	float *fVals = new float[dwCount];

	hr = m_pVUMeters->GetMeterValues(m_eMixerStrip, m_dwStripNum, m_dwSurfaceID, fVals, &dwCount);

	if (FAILED(hr))
	{
		*str = _T("GetMeterValues FAILED");
	}
	else
	{
		CString tmp;

		str->Empty();

		for (DWORD n = 0; n < dwCount; n++)
		{
			double dB = -60 + 60 * fVals[n];
			tmp.Format(_T("%.2fdB\r\n"), dB );
			*str += tmp;
		}
	}

	delete[] fVals;
}
void CMackieControlMaster::OnConnect()
{
//	TRACE("CMackieControlMaster::OnConnect()\n");

	// Tell the XT section too
	CMackieControlXT::OnConnect();

	// Wire these up now that we have a valid m_pMixer
	m_SwMasterFader.Setup(m_pMixer, m_pTransport);
	m_SwMasterFaderPan.Setup(m_pMixer, m_pTransport);

	CCriticalSectionAuto csa(m_cState.GetCS());
	ReconfigureMaster(true);
}
HRESULT CControlSurfaceProbe::GetNoEchoMask( WORD* pwMask, BOOL* pbNoEchoSysx )
{
	if (NULL == pwMask || NULL == pbNoEchoSysx)
		return E_POINTER;

	CCriticalSectionAuto csa( &m_cs );

	// TODO: Tell SONAR about any channels (or sysx) that do not require echo.
	
	*pwMask = 0;
	*pbNoEchoSysx = FALSE;

	return S_OK;
}
HRESULT CMackieControlBase::GetNoEchoMask( WORD* pwMask, BOOL* pbNoEchoSysx )
{
	if (NULL == pwMask || NULL == pbNoEchoSysx)
		return E_POINTER;

	CCriticalSectionAuto csa( &m_cs );

	// since the Mackie is a dedicated Mixer Control Surface, we'll just grab
	// the whole port...  All channels and Sysex
	
	*pwMask = 0xFFFF;
	*pbNoEchoSysx = TRUE;

	return S_OK;
}
CMackieControlMaster::CMackieControlMaster()
{
//	TRACE("CMackieControlMaster::CMackieControlMaster()\n");

	m_bExpectedDeviceType = 0x14;

	m_bWasInEQFreqGainMode = false;

	m_eCurrentTransportDir = DIR_FORWARD;
	m_fTransportTimeout = 0;

	m_bKeyRepeatKey = 0;
	m_fKeyRepeatTimeout = 0;
	
	int n = 0;

	// Wire everything up together
	for (n = 0; n < NUM_VSELECT_DISPLAY_CELLS; n++)
		m_cVSelectDisplay[n].Setup(this, 0x0A + NUM_VSELECT_DISPLAY_CELLS - n - 1);

	for (n = 0; n < NUM_TIME_CODE_DISPLAY_CELLS; n++)
		m_cTimeCodeDisplay[n].Setup(this, NUM_TIME_CODE_DISPLAY_CELLS - n - 1);

	m_HwMasterFader.Setup(this, 8);

	CCriticalSectionAuto csa(m_cState.GetCS());

	// Default user key and foot bindings
	m_cState.SetUserFunctionKey(0, CMD_VIEW_NEW_EXPLORER);
	m_cState.SetUserFunctionKey(1, CMD_VIEW_NEW_LOOP_CONSTR);
	m_cState.SetUserFunctionKey(2, CMD_VIEW_CONSOLE);
	m_cState.SetUserFunctionKey(3, CMD_VIEW_NEW_EVENT_LIST);
	m_cState.SetUserFunctionKey(4, CMD_VIEW_NEW_PIANO_ROLL);
	m_cState.SetUserFunctionKey(5, CMD_VIEW_VIDEO);
	m_cState.SetUserFunctionKey(6, CMD_VIEW_NEW_STAFF);
	m_cState.SetUserFunctionKey(7, CMD_VIEW_NEW_LYRICS);
	m_cState.SetUserFootSwitch(0, CMD_REALTIME_PLAY);
	m_cState.SetUserFootSwitch(1, CMD_REALTIME_RECORD);

	TIMECAPS timeDevCaps;
	timeGetDevCaps(&timeDevCaps, sizeof(timeDevCaps));
	TRACE("timeDevCaps.wPeriodMin = %d\n", timeDevCaps.wPeriodMin);
	m_wTransportTimerPeriod = max(timeDevCaps.wPeriodMin, 10);
	m_wKeyRepeatTimerPeriod = max(timeDevCaps.wPeriodMin, 10);
	m_bTransportTimerActive = false;
	m_bKeyRepeatTimerActive = false;
}
HRESULT CACTController::Disconnect()
{
	// Note: You will probably not need to change this implementation.
	// The wizard has already generated code to release all ISonarXXX
	// interfaces currently held.

	CCriticalSectionAuto csa( &m_cs );

	// Call the child class OnDisonnect()...
	OnDisconnect();

	// We're no longer connected
	m_bConnected = false;

	releaseSonarInterfaces();
	return S_OK;
}
HRESULT CControlSurfaceProbe::MidiInLongMsg( DWORD cbLongMsg, const BYTE* pbLongMsg )
{
	if (NULL == pbLongMsg)
		return E_POINTER;
	if (0 == cbLongMsg)
		return S_OK; // nothing to do

	CCriticalSectionAuto csa( &m_cs );

	// TODO: Handle a MIDI long (SysX) message which has just been sent
	// *from* the surface.  In other words, the user has just moved
	// a fader or pressed a button; the surface sent a MIDI message;
	// SONAR received the message, and routed back into this DLL.

	// See MidiInShortMsg for notes on how this method might be implemented.

	return S_OK;
}
void CControlSurfaceProbe::GetValue(SONAR_MIXER_STRIP eMixerStrip, DWORD dwStripNum, SONAR_MIXER_PARAM eMixerParam, DWORD dwParamNum, float* pfValue, CString *str)
{
	CCriticalSectionAuto csa( &m_cs );

	if (!m_pMixer)
	{
		*str = _T("m_pMixer is NULL");
		return;
	}

	HRESULT hr = m_pMixer->GetMixParam(eMixerStrip, dwStripNum, eMixerParam, dwParamNum, pfValue);

	if (FAILED(hr))
	{
		*str = _T("GetMixParam FAILED");
		return;
	}

	str->Format(_T("%.2f"), *pfValue);
}
void CMackieControlXT::OnConnect()
{
//	TRACE("CMackieControlXT::OnConnect()\n");

	// Wire these up now that we have a valid m_pMixer
	for (int n = 0; n < NUM_MAIN_CHANNELS; n++)
	{
		m_SwStrip[n].Setup(m_pMixer, m_pTransport, m_dwUniqueId);
		m_SwVPot[n].Setup(m_pMixer, m_pTransport);
		m_SwRec[n].Setup(m_pMixer, m_pTransport);
		m_SwSolo[n].Setup(m_pMixer, m_pTransport);
		m_SwMute[n].Setup(m_pMixer, m_pTransport);
		m_SwArchive[n].Setup(m_pMixer, m_pTransport);
		m_SwInputEcho[n].Setup(m_pMixer, m_pTransport);
		m_SwFader[n].Setup(m_pMixer, m_pTransport);
	}

	CCriticalSectionAuto csa(m_cState.GetCS());
	ReconfigureXT(true);
}
HRESULT CMackieControlBase::RefreshSurface( DWORD fdwRefresh, DWORD dwCookie )
{
	CCriticalSectionAuto csa( &m_cs );

	if (!m_bConnected)
		return S_OK;

	if (fdwRefresh != 0 ||
		dwCookie == (DWORD)&m_bMsgRefresh ||
		dwCookie == (DWORD)&m_bMsgForceRefresh ||
		dwCookie == (DWORD)&m_bMsgRefreshAll ||
		dwCookie == (DWORD)&m_bMsgForceRefreshAll)
	{
		m_dwRefreshCount++;

		bool bForceSend = (dwCookie == (DWORD)&m_bMsgForceRefresh || dwCookie == (DWORD)&m_bMsgForceRefreshAll);

		// Detected the surface yet?
		if (!m_bHaveSerialNumber)
		{
			if (m_bExpectedDeviceType != 0x00)
				QuerySerialNumber(m_bExpectedDeviceType);
		}
		else
		{
			OnRefreshSurface(fdwRefresh, bForceSend);
		}
	}
	else if (dwCookie == (DWORD)&m_bMsgSetAllFadersToDefault)
	{
		if (m_bHaveSerialNumber)
			SetAllFadersToDefault();
	}
	else if (dwCookie == (DWORD)&m_bMsgSetAllVPotsToDefault)
	{
		if (m_bHaveSerialNumber)
			SetAllVPotsToDefault();
	}

	return S_OK;
}
HRESULT CMackieControlBase::MidiInShortMsg( DWORD dwShortMsg )
{
	CCriticalSectionAuto csa( &m_cs );

	if (!m_bConnected)
		return S_OK;

	if (!m_bHaveSerialNumber)
		return S_OK;

	ClearRefreshFlags();

	BYTE bStatus = (BYTE)(dwShortMsg & 0xFF);
	BYTE bD1 = (BYTE)((dwShortMsg >> 8) & 0xFF);
	BYTE bD2 = (BYTE)((dwShortMsg >> 16) & 0xFF);

	OnMidiInShort(bStatus, bD1, bD2);

	DispatchRefreshRequest();

	return S_OK;
}
void CControlSurfaceProbe::GetArm(CString *str)
{
	CCriticalSectionAuto csa( &m_cs );

	if (!m_pMixer)
	{
		*str = "m_pMixer is NULL";
		return;
	}

	BOOL bVal;

	HRESULT hr = m_pMixer->GetArmMixParam(m_eMixerStrip, m_dwStripNum, m_eMixerParam, m_dwParamNum, &bVal);

	if (FAILED(hr))
	{
		*str = "GetArmMixParam FAILED";
		return;
	}

	*str = (bVal) ? "True" : "False";
}
void CControlSurfaceProbe::GetNumMeters(CString *str)
{
	CCriticalSectionAuto csa( &m_cs );

	if (!m_pVUMeters)
	{
		*str = _T("m_pVUMeters is NULL");
		return;
	}

	DWORD dwCount = 0;

	HRESULT hr = m_pVUMeters->GetMeterChannelCount(m_eMixerStrip, m_dwStripNum, &dwCount);

	if (FAILED(hr))
	{
		*str = _T("GetMeterChannelCount FAILED");
		return;
	}

	str->Format(_T("%u"), dwCount);
}
void CControlSurfaceProbe::GetTransportState(SONAR_TRANSPORT_STATE eTransportState, CString *str)
{
	CCriticalSectionAuto csa( &m_cs );

	if (!m_pTransport)
	{
		*str = "m_pTransport is NULL";
		return;
	}

	BOOL bValue;

	HRESULT hr = m_pTransport->GetTransportState(eTransportState, &bValue);
	
	if (FAILED(hr))
	{
		*str = "GetTransportState FAILED";
		return;
	}

	*str = (bValue) ? "1" : "0";
}