Skip to content

Commit 07f6aea

Browse files
committed
Temporary commented out play tone code to remove dependency from QtMultimedia
1 parent 64aa183 commit 07f6aea

File tree

4 files changed

+39
-43
lines changed

4 files changed

+39
-43
lines changed

trikControl/src/audioSynthDevices.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#include "audioSynthDevices.h"
1616

17-
#include <QtMultimedia/QAudioDeviceInfo>
1817
#include <qmath.h>
1918

2019
AudioSynthDevice::AudioSynthDevice(QObject *parent, int sampleRate, int sampleSize)

trikControl/src/audioSynthDevices.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include <QtCore/QByteArray>
1818
#include <QtCore/QIODevice>
19-
#include <QtMultimedia/QAudioFormat>
2019

2120
/// QIODevice that synthesize sine wave values
2221
class AudioSynthDevice : public QIODevice

trikControl/src/tonePlayer.cpp

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,59 +12,63 @@
1212
* See the License for the specific language governing permissions and
1313
* limitations under the License. */
1414

15-
1615
#include "tonePlayer.h"
1716

17+
using namespace trikControl;
1818

19-
namespace trikControl{
19+
// This file is temporary commented out to remove dependence from QtMumtimedia.
20+
// TODO: Restore is as quickly as possible
2021

2122
TonePlayer::TonePlayer()
23+
: mDevice(nullptr)
2224
{
2325
mTimer.setSingleShot(true);
2426
initializeAudio();
25-
mDevice = new AudioSynthDevice(this, mFormat.sampleRate(), mFormat.sampleSize());
26-
mOutput = new QAudioOutput(mFormat, this);
27+
// mDevice = new AudioSynthDevice(this, mFormat.sampleRate(), mFormat.sampleSize());
28+
// mOutput = new QAudioOutput(mFormat, this);
2729
}
2830

2931
void TonePlayer::initializeAudio()
3032
{
33+
// mFormat.setChannelCount(1);
34+
// mFormat.setSampleRate(16000);
35+
// mFormat.setSampleSize(16);
36+
// mFormat.setSampleType(QAudioFormat::SampleType::SignedInt);
37+
// mFormat.setCodec("audio/pcm");
3138

32-
mFormat.setChannelCount(1);
33-
mFormat.setSampleRate(16000);
34-
mFormat.setSampleSize(16);
35-
mFormat.setSampleType(QAudioFormat::SampleType::SignedInt);
36-
mFormat.setCodec("audio/pcm");
37-
38-
connect(&mTimer, SIGNAL(timeout()), this, SLOT(stop()));
39+
// connect(&mTimer, SIGNAL(timeout()), this, SLOT(stop()));
3940

40-
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
41-
if (!info.isFormatSupported(mFormat)) {
42-
mFormat = info.nearestFormat(mFormat);
43-
}
41+
// QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
42+
// if (!info.isFormatSupported(mFormat)) {
43+
// mFormat = info.nearestFormat(mFormat);
44+
// }
4445
}
4546

47+
#include<QDebug>
4648
void TonePlayer::play(int hzFreq, int msDuration)
4749
{
48-
mDevice->start(hzFreq);
49-
switch (mOutput->state()) {
50-
case QAudio::ActiveState:
51-
mOutput->suspend();
52-
mDevice->reset();
53-
mOutput->resume();
54-
break;
55-
case QAudio::SuspendedState: mOutput->resume(); break;
56-
case QAudio::StoppedState: mOutput->start(mDevice); break;
57-
case QAudio::IdleState: mOutput->start(mDevice); break;
58-
default: break;
59-
}
50+
Q_UNUSED(hzFreq)
51+
Q_UNUSED(msDuration)
52+
qWarning() << "Sorry, brick::playTone is not implemented yet!";
53+
// mDevice->start(hzFreq);
54+
// switch (mOutput->state()) {
55+
// case QAudio::ActiveState:
56+
// mOutput->suspend();
57+
// mDevice->reset();
58+
// mOutput->resume();
59+
// break;
60+
// case QAudio::SuspendedState: mOutput->resume(); break;
61+
// case QAudio::StoppedState: mOutput->start(mDevice); break;
62+
// case QAudio::IdleState: mOutput->start(mDevice); break;
63+
// default: break;
64+
// }
6065

61-
mTimer.setInterval(msDuration);
62-
mTimer.start();
66+
// mTimer.setInterval(msDuration);
67+
// mTimer.start();
6368
}
6469

6570
void TonePlayer::stop()
6671
{
67-
mDevice->stop();
68-
mTimer.stop();
69-
}
72+
// mDevice->stop();
73+
// mTimer.stop();
7074
}

trikControl/src/tonePlayer.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818

1919
#include <QtCore/QObject>
2020
#include <QtCore/QTimer>
21-
#include <QtMultimedia/QAudioOutput>
22-
23-
21+
//#include <QtMultimedia/QAudioOutput>
2422

2523
namespace trikControl {
2624

@@ -30,21 +28,17 @@ class TonePlayer : public QObject
3028
Q_OBJECT
3129

3230
public:
33-
3431
/// Constructor
3532
TonePlayer();
3633

3734
public slots:
38-
3935
/// Play sound
4036
void play(int freqHz, int durationMs);
4137

4238
private:
43-
QAudioFormat mFormat;
44-
39+
// QAudioFormat mFormat;
4540
AudioSynthDevice *mDevice; // Has ownership.
46-
47-
QAudioOutput *mOutput; // Has ownership.
41+
// QAudioOutput *mOutput; // Has ownership.
4842

4943
QTimer mTimer;
5044

0 commit comments

Comments
 (0)