本文整理汇总了C++中AudioDevice::putSamples方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioDevice::putSamples方法的具体用法?C++ AudioDevice::putSamples怎么用?C++ AudioDevice::putSamples使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioDevice
的用法示例。
在下文中一共展示了AudioDevice::putSamples方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: play
void Tool::play(char **argv)
{
AudioDevice *dev;
PlayStream playfile;
const char *path = *argv;
Linear buffer;
Info info;
unsigned bufcount, pages;
dev = getDevice();
if(!hasDevice() && !dev)
{
cerr << "no device supported" << endl;
exit(-1);
}
else if(!dev)
{
cerr << "device unavailable" << endl;
exit(-1);
}
playfile.open(argv);
if(!playfile.isOpen())
{
cerr << "audiotool: " << path << ": unable to access" << endl;
exit(-1);
}
if(!playfile.isStreamable())
{
cerr << "audiotool: " << path << ": missing needed codec" << endl;
exit(-1);
}
playfile.getInfo(&info);
if(!dev->setAudio((Rate)info.rate, isStereo(info.encoding), 10))
{
cerr << "audiotool: sound device does not support rate" << endl;
exit(-1);
}
bufcount = playfile.getCount();
if(isStereo(info.encoding))
buffer = new Sample[bufcount * 2];
else
buffer = new Sample[bufcount];
for(;;)
{
if(isStereo(info.encoding))
pages = playfile.getStereo(buffer, 1);
else
pages = playfile.getMono(buffer, 1);
if(!pages)
break;
dev->putSamples(buffer, bufcount);
}
dev->sync();
delete dev;
playfile.close();
exit(0);
}