Exemple #1
0
void sample :: prepend(const sample& s) {
	if (!assertWarning(rate() == s.rate(), "prepend failed: different rates") ||
		!assertWarning(channels() == s.channels(),
			"prepend failed: different channel counts"))
		return;
	audioSample *snd = new audioSample[audioSize() + s.audioSize()];
	memcpy(snd, s.data, s.bytes());
	memcpy(snd + s.audioSize(), data, bytes());
	delete[] data;
	data = snd;
	info.length += s.length();
} // prepend()
Exemple #2
0
void sample :: paste(const sample& clip, int start, bool replaceFlag) {
	if (!assertWarning(rate() == clip.rate(),"paste failed: different rates") ||
		!assertWarning(channels() == clip.channels(),
			"paste failed: different channel counts"))
		return;
	int limit = clip.length();
	if (start + limit > length())
		limit = length() - start;
	if (replaceFlag)
		memcpy(data+start*channels(), clip.data,
				limit * channels() * sizeof(audioSample));
	else
		for (int i = 0; i < limit * channels(); i++, start++)
			data[start] = audioLimit(clip.data[i] + data[start]);
} // paste()
Exemple #3
0
int sample :: diff(const sample& t) const {
	if (!assertWarning(rate() == t.rate(),"diff: sample rates") ||
		!assertWarning(length() == t.length(),"diff: different lengths") ||
		!assertWarning(channels() == t.channels(), "diff: channel counts"))
		return 1;
	int diffs = 0;
	for (int i=0; (i<audioSize()) && (diffs<10); i++)
		if (data[i] != t.data[i]) {
			if (parameters->debug("sample", "basic"))
				cerr << "Data differs at " << i << " of " << audioSize() <<endl;
			diffs++;
		}
	if (parameters->debug("sample", "basic") && !diffs)
		cerr << "No diffs" << endl;
	return diffs;
} // diffs()