Пример #1
0
//! Return a string indicating the frequency in Hz
QString SignalDisplayData::sampleToFreqString(int sample) const
{
	double duration_ms = sampleToTime((unsigned)abs(sample)); //((double)abs(sample) * (double)duration) / (double)sampleCount();
	double f = 1000 / (duration_ms);
	if (f > 1000)
		return QString("%0 kHz").arg(round(f / 10) / 100);
	else
		return QString("%0 Hz").arg(round(f * 100) / 100);
}
Пример #2
0
void Spectrogram::paintTimeAxis(QPainter *painter, QRect rect)
{
	// Round up for firstLine and round each to nearest linesPerGraduation
	int firstLine = ((rect.y() + linesPerGraduation - 1) / linesPerGraduation) * linesPerGraduation;
	int lastLine = ((rect.y() + rect.height()) / linesPerGraduation) * linesPerGraduation;

	painter->save();
	QPen pen(Qt::white, 1, Qt::SolidLine);
	painter->setPen(pen);
	QFontMetrics fm(painter->font());
	int textOffset = fm.ascent() / 2 - 1;
	for (int line = firstLine; line <= lastLine; line += linesPerGraduation) {
		painter->drawLine(0, line, 10, line);
		painter->drawText(12, line + textOffset, sampleToTime(lineToSample(line)));
	}
	painter->restore();
}
Пример #3
0
//! Return a string indicating the duration of sample. Floating point version
QString SignalDisplayData::sampleToTimeString(double sample) const
{
	return timeScaleToString(sampleToTime(fabs(sample)));
}
Пример #4
0
//! Return a string indicating the duration of sample. Integer version
QString SignalDisplayData::sampleToTimeString(int sample) const
{
	return timeScaleToString(sampleToTime((unsigned)abs(sample)));
}