Ejemplo n.º 1
0
// flags&1=incl. items, &2=incl. markers/regions, &4=incl. envelopes
double SNM_GetProjectLength(int _flags)
{
	double prjlen = 0.0, pos, end;
	if (_flags&2)
	{
		int x=0; bool isRgn;
		while ((x = EnumProjectMarkers2(NULL, x, &isRgn, &pos, &end, NULL, NULL))) {
			if (isRgn) { if (end > prjlen) prjlen = end; }
			else { if (pos > prjlen) prjlen = pos; }
		}
	}
	if ((_flags&1) || (_flags&4))
	{
		double len;
		for (int i=0; i <= GetNumTracks(); i++)
		{
			if (MediaTrack* tr = CSurf_TrackFromID(i, false))
			{
				int cnt= i>0 ? GetTrackNumMediaItems(tr) : 0; // skip master
				if (_flags&1) for (int j=0; j<cnt; j++)
				{
					if (MediaItem* item = GetTrackMediaItem(tr,j))
					{
						pos = *(double*)GetSetMediaItemInfo(item, "D_POSITION", NULL);
						len = *(double*)GetSetMediaItemInfo(item, "D_LENGTH", NULL);
						if ((pos+len)>prjlen) prjlen = pos+len;
					}
				}

				cnt=CountTrackEnvelopes(tr);
				if (_flags&4) for (int j=0; j<cnt; j++)
				{
					if (TrackEnvelope* env = GetTrackEnvelope(tr,j))
					{
						if (int ptcnt=CountEnvelopePoints(env))
						{
							pos=prjlen;
							GetEnvelopePoint(env, ptcnt-1, &pos, NULL, NULL, NULL, NULL);
							if (pos>prjlen) prjlen = pos;
						}
					}
				}
			}
		}
	}
	return prjlen;
}
Ejemplo n.º 2
0
		sinkbuf[0] = vecref.data();
		sink->WriteDoubles(sinkbuf, vecref.size(), 1, 0, 1);
		delete sink;
	} else
		ReaScriptError("MRP_WriteArrayToFile : could not create output file");
	return (void*)nullptr;
},
"Write MRP_Array to disk as a 32 bit floating point mono wav file"
);

function_entry MRP_CalculateEnvelopeHash("int", "TrackEnvelope*", "env", [](params) 
{
	TrackEnvelope* env = (TrackEnvelope*)arg[0];
	if (env == nullptr)
		return_null;
	int numpoints = CountEnvelopePoints(env);
	size_t seed = 0;
	for (int i = 0; i < numpoints; ++i) {
		double pt_time = 0.0;
		double pt_val = 0.0;
		double pt_tension = 0.0;
		int pt_shape = 0;
		GetEnvelopePoint(env, i, &pt_time, &pt_val, &pt_shape, &pt_tension, nullptr);
		hash_combine(seed, pt_time);
		hash_combine(seed, pt_val);
		hash_combine(seed, pt_tension);
		hash_combine(seed, pt_shape);
	}
	return_int((int)seed);
},
"This <i>function</i> isn't really <b>correct...</b> it calculates a 64 bit hash "