本文整理汇总了C++中SoundFile::setSampleRate方法的典型用法代码示例。如果您正苦于以下问题:C++ SoundFile::setSampleRate方法的具体用法?C++ SoundFile::setSampleRate怎么用?C++ SoundFile::setSampleRate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoundFile
的用法示例。
在下文中一共展示了SoundFile::setSampleRate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createSoundFile
SoundFile* AbcFile::createSoundFile() {
SoundFile * soundFile = new SoundFile();
soundFile->setBitDepth(bitRate);
soundFile->setSampleRate(sampleRate);
soundFile->setNumberOfChannels((int)instruments.size());
int samplesPerCount = (int)ceil(60.0*sampleRate/tempo);
for(int i = 0; i < instruments.size(); i++) {
SoundFile * otherChannels = new SoundFile();
otherChannels->setBitDepth(bitRate);
otherChannels->setSampleRate(sampleRate);
otherChannels->setNumberOfChannels((int)instruments.size());
SoundGenerator::SoundBuilder builder;
builder.setAttack(instruments[i]->getAttack()).setDecay(instruments[i]->getDecay()).setRelease(instruments[i]->getRelease()).setDuration((instruments[i]->findTotalCount() * 60 / tempo)).setSampleRate(sampleRate).setSustain(instruments[i]->getSustain());
int numSamples = 0;
for(int j = 0; j < instruments[i]->getScore().size(); j++) {
SoundFile * tempFile = new SoundFile();
tempFile->setBitDepth(bitRate);
tempFile->setSampleRate(sampleRate);
SoundGenerator soundGenerator = builder.setDuration((instruments[i]->getScore()[j]->getCount() * 60 / tempo)).setBitDepth(bitRate).build();
tempFile->setNumberOfChannels((int)instruments.size());
int waveForm = instruments[i]->getWaveform();
if(waveForm == 1) {
numSamples +=sineWave(instruments[i]->getScore()[j],samplesPerCount,tempFile);
} else if(waveForm == 2) {
numSamples +=sawtoothWave(instruments[i]->getScore()[j],samplesPerCount,tempFile);
} else if (waveForm == 3) {
numSamples +=triangleWave(instruments[i]->getScore()[j],samplesPerCount,tempFile);
} else {
numSamples +=pulseWave(instruments[i]->getScore()[j],samplesPerCount,tempFile);
}
soundGenerator.handleEnvelop(tempFile);
if(i == 0) {
*soundFile += tempFile;
} else {
*otherChannels += tempFile;
}
}
for (int k = numSamples + 1; k < getMaxSamples(instruments); ++k) {
SampleLine *sampleLine = new SampleLine();
sampleLine->addNewChannel(0);
if(i == 0) {
soundFile->addSample(sampleLine);
} else {
otherChannels->addSample(sampleLine);
}
}
if(std::find(mute.begin(),mute.end(),i) != mute.end()) {
if(i == 0) {
*soundFile * 0;
} else {
*otherChannels * 0;
}
}
if(i != 0) {
*soundFile | otherChannels;
}
}
return soundFile;
}