##// END OF EJS Templates
Copyright header changes...
Copyright header changes Copyright header changes for Qt 5.5. Change-Id: I2b8e9356997de2c87a7436bcefd4d0948d566259 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com>

File last commit:

r2776:bc1f6aa59d42
r2776:bc1f6aa59d42
Show More
widget.cpp
80 lines | 2.5 KiB | text/x-c | CppLexer
Miikka Heikkinen
Added copyright headers to *.h/*.cpp files missing them...
r2435 /****************************************************************************
**
Titta Heikkala
Copyright header changes...
r2776 ** Copyright (C) 2015 The Qt Company Ltd
Miikka Heikkinen
Added copyright headers to *.h/*.cpp files missing them...
r2435 ** All rights reserved.
Titta Heikkala
Copyright header changes...
r2776 ** For any questions to The Qt Company, please use contact form at http://qt.io
Miikka Heikkinen
Added copyright headers to *.h/*.cpp files missing them...
r2435 **
Titta Heikkala
Updated license headers...
r2740 ** This file is part of the Qt Charts module.
Miikka Heikkinen
Added copyright headers to *.h/*.cpp files missing them...
r2435 **
Titta Heikkala
Updated license headers...
r2740 ** Licensees holding valid commercial license for Qt may use this file in
** accordance with the Qt License Agreement provided with the Software
** or, alternatively, in accordance with the terms contained in a written
Titta Heikkala
Copyright header changes...
r2776 ** agreement between you and The Qt Company.
Miikka Heikkinen
Added copyright headers to *.h/*.cpp files missing them...
r2435 **
** If you have questions regarding the use of this file, please use
Titta Heikkala
Updated license headers...
r2740 ** contact form at http://qt.io
Miikka Heikkinen
Added copyright headers to *.h/*.cpp files missing them...
r2435 **
****************************************************************************/
Marek Rosa
Added audio input demo
r2155 #include "widget.h"
Titta Heikkala
Fix include syntax...
r2714 #include <QtMultimedia/QAudioDeviceInfo>
#include <QtMultimedia/QAudioInput>
#include <QtCharts/QChartView>
#include <QtCharts/QLineSeries>
#include <QtCharts/QChart>
#include <QtWidgets/QVBoxLayout>
#include <QtCharts/QValueAxis>
Marek Rosa
Added audio input demo
r2155 #include "xyseriesiodevice.h"
Titta Heikkala
Qt Charts project file structure change...
r2712 QT_CHARTS_USE_NAMESPACE
Marek Rosa
Added audio input demo
r2155
Widget::Widget(QWidget *parent)
: QWidget(parent),
m_device(0),
m_chart(0),
m_series(0),
m_audioInput(0)
{
m_chart = new QChart;
QChartView *chartView = new QChartView(m_chart);
chartView->setMinimumSize(800, 600);
m_series = new QLineSeries;
m_chart->addSeries(m_series);
QValueAxis *axisX = new QValueAxis;
Marek Rosa
Added axes titles to audio example and decreased the number of samples on chart to 2000
r2214 axisX->setRange(0, 2000);
axisX->setLabelFormat("%g");
Michal Klocek
Refactors internals...
r2273 axisX->setTitleText("Samples");
Marek Rosa
Added audio input demo
r2155 QValueAxis *axisY = new QValueAxis;
Marek Rosa
Added axes titles to audio example and decreased the number of samples on chart to 2000
r2214 axisY->setRange(-1, 1);
Michal Klocek
Refactors internals...
r2273 axisY->setTitleText("Audio level");
m_chart->setAxisX(axisX, m_series);
Marek Rosa
Added audio input demo
r2155 m_chart->setAxisY(axisY, m_series);
Marek Rosa
Audio example now takes every other value from mic input
r2159 m_chart->legend()->hide();
Marek Rosa
Added axes titles to audio example and decreased the number of samples on chart to 2000
r2214 m_chart->setTitle("Data from the microphone");
Marek Rosa
Added audio input demo
r2155
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(chartView);
setLayout(mainLayout);
QAudioFormat formatAudio;
Tero Ahola
Qt5 build fixes
r2239 formatAudio.setSampleRate(8000);
formatAudio.setChannelCount(1);
Marek Rosa
Added audio input demo
r2155 formatAudio.setSampleSize(8);
formatAudio.setCodec("audio/pcm");
formatAudio.setByteOrder(QAudioFormat::LittleEndian);
formatAudio.setSampleType(QAudioFormat::UnSignedInt);
QAudioDeviceInfo inputDevices = QAudioDeviceInfo::defaultInputDevice();
m_audioInput = new QAudioInput(inputDevices,formatAudio, this);
m_device = new XYSeriesIODevice(m_series, this);
m_device->open(QIODevice::WriteOnly);
m_audioInput->start(m_device);
}
Widget::~Widget()
{
m_audioInput->stop();
m_device->close();
}