Пример #1
0
bool Instrument::unmapInstrument (void)
{
#ifdef CONFIG_MIDI_INSTRUMENT

	if (m_iMap < 0 || m_iBank < 0 || m_iProg < 0)
		return false;

	MainForm *pMainForm = MainForm::getInstance();
	if (pMainForm == NULL)
		return false;
	if (pMainForm->client() == NULL)
		return false;

	lscp_midi_instrument_t instr;

	instr.map  = m_iMap;
	instr.bank = (m_iBank & 0x0fff);
	instr.prog = (m_iProg & 0x7f);

	if (::lscp_unmap_midi_instrument(pMainForm->client(), &instr) != LSCP_OK) {
		pMainForm->appendMessagesClient("lscp_unmap_midi_instrument");
		return false;
	}

	return true;

#else

	return false;

#endif
}
Пример #2
0
// Instrument map name enumerator.
QStringList Instrument::getMapNames (void)
{
	QStringList maps;

	MainForm *pMainForm = MainForm::getInstance();
	if (pMainForm == NULL)
		return maps;
	if (pMainForm->client() == NULL)
		return maps;

#ifdef CONFIG_MIDI_INSTRUMENT
	int *piMaps = ::lscp_list_midi_instrument_maps(pMainForm->client());
	if (piMaps == NULL) {
		if (::lscp_client_get_errno(pMainForm->client()))
			pMainForm->appendMessagesClient("lscp_list_midi_instruments");
	} else {
		for (int iMap = 0; piMaps[iMap] >= 0; iMap++) {
			const QString& sMapName = getMapName(piMaps[iMap]);
			if (!sMapName.isEmpty())
				maps.append(sMapName);
		}
	}
#endif

	return maps;
}
Пример #3
0
// Sync methods.
bool Instrument::mapInstrument (void)
{
#ifdef CONFIG_MIDI_INSTRUMENT

	MainForm *pMainForm = MainForm::getInstance();
	if (pMainForm == NULL)
		return false;
	if (pMainForm->client() == NULL)
		return false;

	if (m_iMap < 0 || m_iBank < 0 || m_iProg < 0)
		return false;

	lscp_midi_instrument_t instr;

	instr.map  = m_iMap;
	instr.bank = (m_iBank & 0x0fff);
	instr.prog = (m_iProg & 0x7f);

	lscp_load_mode_t load_mode;
	switch (m_iLoadMode) {
		case 3:
			load_mode = LSCP_LOAD_PERSISTENT;
			break;
		case 2:
			load_mode = LSCP_LOAD_ON_DEMAND_HOLD;
			break;
		case 1:
			load_mode = LSCP_LOAD_ON_DEMAND;
			break;
		case 0:
		default:
			load_mode = LSCP_LOAD_DEFAULT;
			break;
	}

	if (::lscp_map_midi_instrument(pMainForm->client(), &instr,
			m_sEngineName.toUtf8().constData(),
			qsamplerUtilities::lscpEscapePath(
				m_sInstrumentFile).toUtf8().constData(),
			m_iInstrumentNr, m_fVolume, load_mode,
			m_sName.toUtf8().constData()) != LSCP_OK) {
		pMainForm->appendMessagesClient("lscp_map_midi_instrument");
		return false;
	}

	return true;

#else

	return false;

#endif
}
Пример #4
0
void Options::setMaxStreams(int iMaxStreams) {
#ifdef CONFIG_MAX_VOICES
	if (iMaxStreams < 0) return;

	MainForm *pMainForm = MainForm::getInstance();
	if (!pMainForm || !pMainForm->client())
		return;

	lscp_status_t result =
		::lscp_set_streams(pMainForm->client(), iMaxStreams);

	if (result != LSCP_OK) {
		pMainForm->appendMessagesClient("lscp_set_streams");
		return;
	}

	this->iMaxStreams = iMaxStreams;
#endif // CONFIG_MAX_VOICES
}
Пример #5
0
QList<int> FxSend::allFxSendsOfSamplerChannel(int samplerChannelID) {
	QList<int> sends;

	MainForm *pMainForm = MainForm::getInstance();
	if (!pMainForm || !pMainForm->client())
		return sends;

#ifdef CONFIG_FXSEND
	int *piSends = ::lscp_list_fxsends(pMainForm->client(), samplerChannelID);
	if (!piSends) {
		if (::lscp_client_get_errno(pMainForm->client()))
			pMainForm->appendMessagesClient("lscp_list_fxsends");
	} else {
		for (int iSend = 0; piSends[iSend] >= 0; ++iSend)
			sends.append(piSends[iSend]);
	}
#endif // CONFIG_FXSEND

	return sends;
}
Пример #6
0
bool FxSend::getFromSampler() {
#if CONFIG_FXSEND
	m_bModified = false;

	// in case this is a new, actually not yet existing FX send, ignore update
	if (isNew())
		return true;

	MainForm *pMainForm = MainForm::getInstance();
	if (!pMainForm || !pMainForm->client())
		return false;

	lscp_fxsend_info_t* pFxSendInfo =
		::lscp_get_fxsend_info(
			pMainForm->client(),
			m_iSamplerChannelID,
			m_iFxSendID);

	if (!pFxSendInfo) {
		pMainForm->appendMessagesClient("lscp_get_fxsend_info");
		return false;
	}

	m_FxSendName = qsamplerUtilities::lscpEscapedTextToRaw(pFxSendInfo->name);
	m_MidiCtrl   = pFxSendInfo->midi_controller;
	m_Depth      = pFxSendInfo->level;

	m_AudioRouting.clear();
	if (pFxSendInfo->audio_routing)
		for (int i = 0; pFxSendInfo->audio_routing[i] != -1; ++i)
			m_AudioRouting[i] = pFxSendInfo->audio_routing[i];

	return true;
#else // CONFIG_FXSEND
	return false;
#endif // CONFIG_FXSEND
}
Пример #7
0
// Instrument map name enumerator.
QString Instrument::getMapName ( int iMidiMap )
{
	QString sMapName;

	MainForm *pMainForm = MainForm::getInstance();
	if (pMainForm == NULL)
		return sMapName;
	if (pMainForm->client() == NULL)
		return sMapName;

#ifdef CONFIG_MIDI_INSTRUMENT
	const char *pszMapName
		= ::lscp_get_midi_instrument_map_name(pMainForm->client(), iMidiMap);
	if (pszMapName == NULL) {
		pszMapName = " -";
		if (::lscp_client_get_errno(pMainForm->client()))
			pMainForm->appendMessagesClient("lscp_get_midi_instrument_name");
	}
	sMapName = QString("%1 - %2").arg(iMidiMap)
		.arg(qsamplerUtilities::lscpEscapedTextToRaw(pszMapName));
#endif

	return sMapName;
}
Пример #8
0
bool FxSend::applyToSampler() {
#if CONFIG_FXSEND
	MainForm *pMainForm = MainForm::getInstance();
	if (!pMainForm || !pMainForm->client())
		return false;

	// in case FX send doesn't exist on sampler side yet, create it
	if (isNew()) {
		// doesn't exist and scheduled for deletion? nothing to do
		if (deletion()) {
			m_bModified = false;
			return true;
		}

		int result =
			::lscp_create_fxsend(
				pMainForm->client(),
				m_iSamplerChannelID,
				m_MidiCtrl, NULL
			);
		if (result == -1) {
			pMainForm->appendMessagesClient("lscp_create_fxsend");
			return false;
		}
		m_iFxSendID = result;
	}

	lscp_status_t result;

	// delete FX send on sampler side
	if (deletion()) {
		result =
			::lscp_destroy_fxsend(
				pMainForm->client(), m_iSamplerChannelID, m_iFxSendID
			);
		if (result != LSCP_OK) {
			pMainForm->appendMessagesClient("lscp_destroy_fxsend");
			return false;
		}
		m_bModified = false;
		return true;
	}

	// set FX send depth MIDI controller
	result =
		::lscp_set_fxsend_midi_controller(
			pMainForm->client(),
			m_iSamplerChannelID, m_iFxSendID, m_MidiCtrl
		);
	if (result != LSCP_OK) {
		pMainForm->appendMessagesClient("lscp_set_fxsend_midi_controller");
		return false;
	}

#if CONFIG_FXSEND_RENAME
	// set FX send's name
	result =
		::lscp_set_fxsend_name(
			pMainForm->client(),
			m_iSamplerChannelID, m_iFxSendID,
			qsamplerUtilities::lscpEscapeText(
				m_FxSendName
			).toUtf8().constData()
		);
	if (result != LSCP_OK) {
		pMainForm->appendMessagesClient("lscp_set_fxsend_name");
		return false;
	}
#endif // CONFIG_FXSEND_RENAME

	// set FX send current send level
	result =
		::lscp_set_fxsend_level(
			pMainForm->client(),
			m_iSamplerChannelID, m_iFxSendID, m_Depth
		);
	if (result != LSCP_OK) {
		pMainForm->appendMessagesClient("lscp_set_fxsend_level");
		return false;
	}

	// set FX send's audio routing
	for (int i = 0; i < m_AudioRouting.size(); ++i) {
		result =
			::lscp_set_fxsend_audio_channel(
				pMainForm->client(), m_iSamplerChannelID, m_iFxSendID,
				i, /*audio source*/
				m_AudioRouting[i] /*audio destination*/
			);
		if (result != LSCP_OK) {
			pMainForm->appendMessagesClient("lscp_set_fxsend_audio_channel");
			return false;
		}
	}

	m_bModified = false;
	return true;
#else // CONFIG_FXSEND
	return false;
#endif // CONFIG_FXSEND
}
Пример #9
0
bool Instrument::getInstrument (void)
{
#ifdef CONFIG_MIDI_INSTRUMENT

	if (m_iMap < 0 || m_iBank < 0 || m_iProg < 0)
		return false;

	MainForm *pMainForm = MainForm::getInstance();
	if (pMainForm == NULL)
		return false;
	if (pMainForm->client() == NULL)
		return false;

	lscp_midi_instrument_t instr;

	instr.map  = m_iMap;
	instr.bank = (m_iBank & 0x0fff);
	instr.prog = (m_iProg & 0x7f);

	lscp_midi_instrument_info_t *pInstrInfo
		= ::lscp_get_midi_instrument_info(pMainForm->client(), &instr);
	if (pInstrInfo == NULL) {
		pMainForm->appendMessagesClient("lscp_get_midi_instrument_info");
		return false;
	}

	m_sName = qsamplerUtilities::lscpEscapedTextToRaw(pInstrInfo->name);
	m_sEngineName = pInstrInfo->engine_name;
	m_sInstrumentName = qsamplerUtilities::lscpEscapedTextToRaw(
		pInstrInfo->instrument_name);
	m_sInstrumentFile = qsamplerUtilities::lscpEscapedPathToPosix(
		pInstrInfo->instrument_file);
	m_iInstrumentNr = pInstrInfo->instrument_nr;
	m_fVolume = pInstrInfo->volume;

	switch (pInstrInfo->load_mode) {
		case LSCP_LOAD_PERSISTENT:
			m_iLoadMode = 3;
			break;
		case LSCP_LOAD_ON_DEMAND_HOLD:
			m_iLoadMode = 2;
			break;
		case LSCP_LOAD_ON_DEMAND:
			m_iLoadMode = 1;
			break;
		case LSCP_LOAD_DEFAULT:
		default:
			m_iLoadMode = 0;
			break;
	}

	// Fix something.
	if (m_sName.isEmpty())
		m_sName = m_sInstrumentName;

	return true;

#else

	return false;

#endif
}
Пример #10
0
// Channel dialog setup formal initializer.
void InstrumentForm::setup ( Instrument *pInstrument )
{
	m_pInstrument = pInstrument;

	m_iDirtySetup = 0;
	m_iDirtyCount = 0;
	m_iDirtyName  = 0;

	if (m_pInstrument == NULL)
		return;

	// Check if we're up and connected.
	MainForm* pMainForm = MainForm::getInstance();
	if (pMainForm == NULL)
		return;
	if (pMainForm->client() == NULL)
		return;

	Options *pOptions = pMainForm->options();
	if (pOptions == NULL)
		return;

	// It can be a brand new channel, remember?
	bool bNew = (m_pInstrument->bank() < 0 || m_pInstrument->prog() < 0);
	if (!bNew) {
		m_pInstrument->getInstrument();
		m_iDirtyName++;
	}

	// Avoid nested changes.
	m_iDirtySetup++;

	// Load combo box history...
	pOptions->loadComboBoxHistory(m_ui.InstrumentFileComboBox);

	// Populate maps list.
	m_ui.MapComboBox->clear();
	m_ui.MapComboBox->insertItems(0, Instrument::getMapNames());

	// Populate Engines list.
	const char **ppszEngines
		= ::lscp_list_available_engines(pMainForm->client());
	if (ppszEngines) {
		m_ui.EngineNameComboBox->clear();
		for (int iEngine = 0; ppszEngines[iEngine]; iEngine++)
			m_ui.EngineNameComboBox->addItem(ppszEngines[iEngine]);
	}
	else pMainForm->appendMessagesClient("lscp_list_available_engines");

	// Read proper instrument information,
	// and populate the instrument form fields.

	// Instrument map name...
	int iMap = (bNew ? pOptions->iMidiMap : m_pInstrument->map());
	if (iMap < 0)
		iMap = 0;
	const QString& sMapName = Instrument::getMapName(iMap);
	if (!sMapName.isEmpty()) {
		m_ui.MapComboBox->setCurrentIndex(
			m_ui.MapComboBox->findText(sMapName,
				Qt::MatchExactly | Qt::MatchCaseSensitive));
	}

	// It might be no maps around...
	bool bMapEnabled = (m_ui.MapComboBox->count() > 0);
	m_ui.MapTextLabel->setEnabled(bMapEnabled);
	m_ui.MapComboBox->setEnabled(bMapEnabled);

	// Instrument bank/program...
	int iBank = (bNew ? pOptions->iMidiBank : m_pInstrument->bank());
	int iProg = (bNew ? pOptions->iMidiProg : m_pInstrument->prog()) + 1;
	if (bNew && iProg > 128) {
		iProg = 1;
		iBank++;
	}
	m_ui.BankSpinBox->setValue(iBank);
	m_ui.ProgSpinBox->setValue(iProg);

	// Instrument name...
	m_ui.NameLineEdit->setText(m_pInstrument->name());

	// Engine name...
	QString sEngineName = m_pInstrument->engineName();
	if (sEngineName.isEmpty() || bNew)
		sEngineName = pOptions->sEngineName;
	if (sEngineName.isEmpty())
		sEngineName = Channel::noEngineName();
	if (m_ui.EngineNameComboBox->findText(sEngineName,
			Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) {
		m_ui.EngineNameComboBox->addItem(sEngineName);
	}
	m_ui.EngineNameComboBox->setCurrentIndex(
		m_ui.EngineNameComboBox->findText(sEngineName,
			Qt::MatchExactly | Qt::MatchCaseSensitive));

	// Instrument filename and index...
	QString sInstrumentFile = m_pInstrument->instrumentFile();
	if (sInstrumentFile.isEmpty())
		sInstrumentFile = Channel::noInstrumentName();
	m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile);
	m_ui.InstrumentNrComboBox->clear();
	m_ui.InstrumentNrComboBox->insertItems(0,
		Channel::getInstrumentList(sInstrumentFile,
		pOptions->bInstrumentNames));
	m_ui.InstrumentNrComboBox->setCurrentIndex(m_pInstrument->instrumentNr());

	// Instrument volume....
	int iVolume = (bNew ? pOptions->iVolume :
		::lroundf(100.0f * m_pInstrument->volume()));
	m_ui.VolumeSpinBox->setValue(iVolume);

	// Instrument load mode...
	int iLoadMode = (bNew ? pOptions->iLoadMode :
		m_pInstrument->loadMode());
	m_ui.LoadModeComboBox->setCurrentIndex(iLoadMode);

	// Done.
	m_iDirtySetup--;
	stabilizeForm();
}
Пример #11
0
void Channel::appendMessagesClient( const QString& s ) const
{
	MainForm *pMainForm = MainForm::getInstance();
	if (pMainForm)
		pMainForm->appendMessagesClient(channelName() + ' ' + s);
}