diff --git a/demos/audio/widget.cpp b/demos/audio/widget.cpp index 1836ddc..8d5a6f6 100644 --- a/demos/audio/widget.cpp +++ b/demos/audio/widget.cpp @@ -23,11 +23,12 @@ Widget::Widget(QWidget *parent) m_series = new QLineSeries; m_chart->addSeries(m_series); QValueAxis *axisX = new QValueAxis; - axisX->setRange(0, 8000); + axisX->setRange(0, 4000); QValueAxis *axisY = new QValueAxis; axisY->setRange(0, 256); m_chart->setAxisX(axisX, m_series); m_chart->setAxisY(axisY, m_series); + m_chart->legend()->hide(); m_chart->setTitle("Data from microphone"); QVBoxLayout *mainLayout = new QVBoxLayout; @@ -48,7 +49,6 @@ Widget::Widget(QWidget *parent) m_device = new XYSeriesIODevice(m_series, this); m_device->open(QIODevice::WriteOnly); - m_audioInput->setBufferSize(10); m_audioInput->start(m_device); } diff --git a/demos/audio/xyseriesiodevice.cpp b/demos/audio/xyseriesiodevice.cpp index e3bea15..a833d4a 100644 --- a/demos/audio/xyseriesiodevice.cpp +++ b/demos/audio/xyseriesiodevice.cpp @@ -16,20 +16,20 @@ qint64 XYSeriesIODevice::readData(char * data, qint64 maxSize) qint64 XYSeriesIODevice::writeData(const char * data, qint64 maxSize) { - qint64 range = 8000; + qint64 range = 4000; QList oldPoints = m_series->points(); QList points; if (oldPoints.count() < range) { points = m_series->points(); } else { - for (int i = maxSize; i < oldPoints.count(); i++) - points.append(QPointF(i - maxSize, oldPoints.at(i).y())); + for (int i = maxSize/2; i < oldPoints.count(); i++) + points.append(QPointF(i - maxSize/2, oldPoints.at(i).y())); } qint64 size = points.count(); - for (int k = 0; k < maxSize; k++) - points.append(QPointF(k + size, (quint8)data[k])); + for (int k = 0; k < maxSize/2; k++) + points.append(QPointF(k + size, (quint8)data[2 * k])); m_series->replace(points); return maxSize;