Exemplo n.º 1
0
//-----------------------------------------------------------------------------
// a plugin editor should call this during valueChanged from a control 
// to clear MIDI event assignments, VST parameter style
void VstChunk::setParameterMidiReset(float value)
{
	if (value > 0.5f)
	{
		// if we're in MIDI learn mode & a parameter has been selected, 
		// then erase its MIDI event assigment (if it has one)
		if ( midiLearn && (learner != kNoLearner) )
		{
			unassignParam(learner);
			setLearner(kNoLearner);
		}
		// otherwise erase all of the MIDI event assignments
		else
			clearAssignments();
	}
}
Exemplo n.º 2
0
    // static
    void QueryPlannerIXSelect::stripUnneededAssignments(MatchExpression* node,
                                                        const std::vector<IndexEntry>& indices) {
        if (MatchExpression::AND == node->matchType()) {
            for (size_t i = 0; i < node->numChildren(); i++) {
                MatchExpression* child = node->getChild(i);

                if (MatchExpression::EQ != child->matchType()) {
                    continue;
                }

                if (!child->getTag()) {
                    continue;
                }

                // We found a EQ child of an AND which is tagged.
                RelevantTag* rt = static_cast<RelevantTag*>(child->getTag());

                // Look through all of the indices for which this predicate can be answered with
                // the leading field of the index.
                for (std::vector<size_t>::const_iterator i = rt->first.begin();
                        i != rt->first.end(); ++i) {
                    size_t index = *i;

                    if (indices[index].unique && 1 == indices[index].keyPattern.nFields()) {
                        // Found an EQ predicate which can use a single-field unique index.
                        // Clear assignments from the entire tree, and add back a single assignment
                        // for 'child' to the unique index.
                        clearAssignments(node);
                        RelevantTag* newRt = static_cast<RelevantTag*>(child->getTag());
                        newRt->first.push_back(index);

                        // Tag state has been reset in the entire subtree at 'root'; nothing
                        // else for us to do.
                        return;
                    }
                }
            }
        }

        for (size_t i = 0; i < node->numChildren(); i++) {
            stripUnneededAssignments(node->getChild(i), indices);
        }
    }
Exemplo n.º 3
0
//-----------------------------------------------------------------------------
VstChunk::VstChunk(long numParameters, long numPrograms, long magic, 
					AudioEffectX *effect, unsigned long sizeofExtendedData)
:	numParameters(numParameters), numPrograms(numPrograms), effect(effect), 
	sizeofExtendedData(sizeofExtendedData)
{
	sharedChunk = 0;
	paramAssignments = 0;
	parameterIDs = 0;

	// there's nothing we can do without a pointer back to the effect
	if (effect == NULL)
		return;

	effect->programsAreChunks();	// tell host you will want to use chunks

	if (numPrograms < 1)
		numPrograms = 1;	// we do need at least 1 set of parameters
	if (numParameters < 1)
		numParameters = 1;	// come on now, what are you trying to do?

	paramAssignments = (ParameterAssignment*) malloc(numParameters * sizeof(ParameterAssignment));
	parameterIDs = (long*) malloc(numParameters * sizeof(long));

	// default to each parameter having its ID equal its index
	// (I haven't implemented anything with parameter IDs yet)
	for (long i=0; i < numParameters; i++)
		parameterIDs[i] = i;

	// calculate some data sizes that are useful to know
	sizeofProgram = sizeof(Program) + (sizeof(float) * (numParameters-2));
	sizeofParameterIDs = sizeof(long) * numParameters;
	sizeofPresetChunk = sizeofProgram 			// 1 program
						+ sizeof(ChunkInfo) 	// the special chunk header info
						+ sizeofParameterIDs;	// the table of parameter IDs
	sizeofChunk = (sizeofProgram*numPrograms)		// all of the programs
					+ sizeof(ChunkInfo)				// the special chunk header info
					+ sizeofParameterIDs			// the table of parameter IDs
					+ (sizeof(ParameterAssignment)*numParameters);	// the MIDI events assignment array

	// increase the allocation sizes if extra data must be stored
	sizeofChunk += sizeofExtendedData;
	sizeofPresetChunk += sizeofExtendedData;

	// this is the shared data that we point **data to in getChunk()
	sharedChunk = (ChunkInfo*) malloc(sizeofChunk);
	// & a few pointers to elements within that data, just for ease of use
	firstSharedParameterID = (long*) ((char*)sharedChunk + sizeof(ChunkInfo));
	firstSharedProgram = (Program*) ((char*)firstSharedParameterID + sizeofParameterIDs);
	firstSharedParamAssignment = (ParameterAssignment*) 
									((char*)firstSharedProgram + (sizeofProgram*numPrograms));

	// set all of the header infos
	chunkInfo.magic = magic;
	chunkInfo.version = effect->getVendorVersion();
	chunkInfo.lowestLoadableVersion = 0;
	chunkInfo.storedHeaderSize = sizeof(ChunkInfo);
	chunkInfo.numStoredParameters = numParameters;
	chunkInfo.numStoredPrograms = numPrograms;
	chunkInfo.storedParameterAssignmentSize = sizeof(ParameterAssignment);
	chunkInfo.storedExtendedDataSize = sizeofExtendedData;

	clearAssignments();	// initialize all of the parameters to have no MIDI event assignments
	resetLearning();	// start with MIDI learn mode off

	// default to allowing MIDI event assignment sharing instead of stealing them, 
	// unless the user has defined the environment variable DFX_PARAM_STEALMIDI
	stealAssignments = getenvBool("DFX_PARAM_STEALMIDI", false);

	// default to ignoring MIDI channel in MIDI event assignments and automation, 
	// unless the user has defined the environment variable DFX_PARAM_USECHANNEL
	useChannel = getenvBool("DFX_PARAM_USECHANNEL", false);

	// default to not allowing MIDI note or pitchbend events to be assigned to parameters
	allowNoteEvents = false;
	allowPitchbendEvents = false;

	noteRangeHalfwayDone = false;

	// default to trying to load un-matching chunks
	crisisBehaviour = kCrisisLoadWhatYouCan;

	// allow for further constructor stuff, if necessary
	init();
}
void TDefense::clearEnemies()
{
    clearProblems();
    clearAssignments();
    clearPapers();
}