本文整理汇总了C++中Audio::setData方法的典型用法代码示例。如果您正苦于以下问题:C++ Audio::setData方法的具体用法?C++ Audio::setData怎么用?C++ Audio::setData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Audio
的用法示例。
在下文中一共展示了Audio::setData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addAudioPressed
void MediaDialog::addAudioPressed()
{
QString path = audioFile->text();
if (score->audio() || path.isEmpty())
return;
QFile f(path);
if (!f.open(QIODevice::ReadOnly))
return;
QByteArray ba = f.readAll();
f.close();
Audio* audio = new Audio;
audio->setPath(path);
audio->setData(ba);
score->setAudio(audio);
score->setDirty(true);
}
示例2: addAudioPressed
void MediaDialog::addAudioPressed()
{
QString path = audioFile->text();
if (score->audio() || path.isEmpty())
return;
QFile f(path);
if (!f.open(QIODevice::ReadOnly))
return;
QByteArray ba = f.readAll();
f.close();
Audio* audio = new Audio;
audio->setPath(path);
audio->setData(ba);
score->setAudio(audio);
score->setDirty(true);
mscore->updatePlayMode();
#if 0
QString wavPath = QDir::tempPath() + "/score.wav";
mscore->saveAs(score, true, wavPath, "wav");
QString program = "D:/HACK/sonic-annotator/bologna.bat";
QStringList arguments;
arguments << QDir::toNativeSeparators(path)<< QDir::toNativeSeparators(wavPath);
QProcess myProcess(this);
myProcess.start(program, arguments);
myProcess.waitForFinished();
qDebug() << myProcess.readAll();
#endif
QFileInfo fi(path);
QFile syncFile(fi.absolutePath() + "/" + fi.baseName() + ".txt");
TempoMap* tmo = score->tempomap();
if (!syncFile.open(QIODevice::ReadOnly))
return;
qreal t = 0;
int tick = 0;
qreal lastTempo = tmo->tempo(0);
TempoMap* tmn = new TempoMap();
tmn->setTempo(0, lastTempo);
int resolution = 25;
while (!syncFile.atEnd()) {
for (int i = 0; !syncFile.atEnd() && i < resolution-1; i++)
syncFile.readLine();
if (syncFile.atEnd())
break;
QByteArray line = syncFile.readLine();
QString s(line);
QStringList sl = s.split(":");
qreal tScore = sl[0].trimmed().toDouble();
qreal tPerformance = sl[1].trimmed().toDouble();
// timestamp of last
int scoreTick = tmo->time2tick(tScore);
qreal deltaError = tmo->tick2time(scoreTick) - tScore;
int dt = scoreTick - tick;
qreal deltaTime = tPerformance - t;
if (deltaTime > 0) {
qreal tempo = dt / (480 * deltaTime);
if(tempo != lastTempo) {
qDebug() << tempo;
tmn->setTempo(tick, tempo);
lastTempo = tempo;
}
}
t = tPerformance - deltaError;
tick = scoreTick;
}
score->setTempomap(tmn);
syncFile.close();
QMessageBox::information(0, "Done", "Done");
}