本文整理汇总了C++中sample::channels方法的典型用法代码示例。如果您正苦于以下问题:C++ sample::channels方法的具体用法?C++ sample::channels怎么用?C++ sample::channels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sample
的用法示例。
在下文中一共展示了sample::channels方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prepend
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()
示例2: paste
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()
示例3: diff
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()