This file is indexed.

/usr/share/qt5/doc/qtmultimedia/qtmultimedia-spectrum-app-engine-h.html is in qtmultimedia5-doc-html 5.2.1-0ubuntu5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>engine.h Example File (spectrum/app/engine.h) | QtMultimedia 5.2</title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
    <div class="main">
    <div class="main-rounded">
        <div class="navigationbar">
        <ul>
<li>Qt 5.2</li>
<li><a href="qtmultimedia-index.html">Qt Multimedia</a></li>
<li>engine.h Example File (spectrum/app/engine.h)</li>
<li id="buildversion">
Qt 5.2.1 Reference Documentation</li>
    </ul>
    </div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<h1 class="title">engine.h Example File</h1>
<span class="small-subtitle">spectrum/app/engine.h</span>
<!-- $$$spectrum/app/engine.h-description -->
<div class="descr"> <a name="details"></a>
<pre class="cpp"><span class="comment">/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the examples of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** &quot;Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
**   * Redistributions of source code must retain the above copyright
**     notice, this list of conditions and the following disclaimer.
**   * Redistributions in binary form must reproduce the above copyright
**     notice, this list of conditions and the following disclaimer in
**     the documentation and/or other materials provided with the
**     distribution.
**   * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
**     of its contributors may be used to endorse or promote products derived
**     from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&quot;
**
** $QT_END_LICENSE$
**
****************************************************************************/</span>

<span class="preprocessor">#ifndef ENGINE_H</span>
<span class="preprocessor">#define ENGINE_H</span>

<span class="preprocessor">#include &quot;spectrum.h&quot;</span>
<span class="preprocessor">#include &quot;spectrumanalyser.h&quot;</span>
<span class="preprocessor">#include &quot;wavfile.h&quot;</span>

<span class="preprocessor">#include &lt;QAudioDeviceInfo&gt;</span>
<span class="preprocessor">#include &lt;QAudioFormat&gt;</span>
<span class="preprocessor">#include &lt;QBuffer&gt;</span>
<span class="preprocessor">#include &lt;QByteArray&gt;</span>
<span class="preprocessor">#include &lt;QDir&gt;</span>
<span class="preprocessor">#include &lt;QObject&gt;</span>
<span class="preprocessor">#include &lt;QVector&gt;</span>

<span class="preprocessor">#ifdef DUMP_CAPTURED_AUDIO</span>
<span class="preprocessor">#define DUMP_DATA</span>
<span class="preprocessor">#endif</span>

<span class="preprocessor">#ifdef DUMP_SPECTRUM</span>
<span class="preprocessor">#define DUMP_DATA</span>
<span class="preprocessor">#endif</span>

<span class="keyword">class</span> FrequencySpectrum;
<span class="keyword">class</span> <span class="type"><a href="qaudioinput.html">QAudioInput</a></span>;
<span class="keyword">class</span> <span class="type"><a href="qaudiooutput.html">QAudioOutput</a></span>;

<span class="comment">/**
 * This class interfaces with the Qt Multimedia audio classes, and also with
 * the SpectrumAnalyser class.  Its role is to manage the capture and playback
 * of audio data, meanwhile performing real-time analysis of the audio level
 * and frequency spectrum.
 */</span>
<span class="keyword">class</span> Engine : <span class="keyword">public</span> <span class="type">QObject</span>
{
    Q_OBJECT

<span class="keyword">public</span>:
    <span class="keyword">explicit</span> Engine(<span class="type">QObject</span> <span class="operator">*</span>parent <span class="operator">=</span> <span class="number">0</span>);
    <span class="operator">~</span>Engine();

    <span class="keyword">const</span> <span class="type">QList</span><span class="operator">&lt;</span><span class="type"><a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a></span><span class="operator">&gt;</span> <span class="operator">&amp;</span>availableAudioInputDevices() <span class="keyword">const</span>
                                    { <span class="keyword">return</span> m_availableAudioInputDevices; }

    <span class="keyword">const</span> <span class="type">QList</span><span class="operator">&lt;</span><span class="type"><a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a></span><span class="operator">&gt;</span> <span class="operator">&amp;</span>availableAudioOutputDevices() <span class="keyword">const</span>
                                    { <span class="keyword">return</span> m_availableAudioOutputDevices; }

    <span class="type"><a href="qaudio.html">QAudio</a></span><span class="operator">::</span>Mode mode() <span class="keyword">const</span> { <span class="keyword">return</span> m_mode; }
    <span class="type"><a href="qaudio.html">QAudio</a></span><span class="operator">::</span>State state() <span class="keyword">const</span> { <span class="keyword">return</span> m_state; }

    <span class="comment">/**
     * \return Current audio format
     * \note May be QAudioFormat() if engine is not initialized
     */</span>
    <span class="keyword">const</span> <span class="type"><a href="qaudioformat.html">QAudioFormat</a></span><span class="operator">&amp;</span> format() <span class="keyword">const</span> { <span class="keyword">return</span> m_format; }

    <span class="comment">/**
     * Stop any ongoing recording or playback, and reset to ground state.
     */</span>
    <span class="type">void</span> reset();

    <span class="comment">/**
     * Load data from WAV file
     */</span>
    bool loadFile(<span class="keyword">const</span> <span class="type">QString</span> <span class="operator">&amp;</span>fileName);

    <span class="comment">/**
     * Generate tone
     */</span>
    bool generateTone(<span class="keyword">const</span> Tone <span class="operator">&amp;</span>tone);

    <span class="comment">/**
     * Generate tone
     */</span>
    bool generateSweptTone(<span class="type">qreal</span> amplitude);

    <span class="comment">/**
     * Initialize for recording
     */</span>
    bool initializeRecord();

    <span class="comment">/**
     * Position of the audio input device.
     * \return Position in bytes.
     */</span>
    <span class="type">qint64</span> recordPosition() <span class="keyword">const</span> { <span class="keyword">return</span> m_recordPosition; }

    <span class="comment">/**
     * RMS level of the most recently processed set of audio samples.
     * \return Level in range (0.0, 1.0)
     */</span>
    <span class="type">qreal</span> rmsLevel() <span class="keyword">const</span> { <span class="keyword">return</span> m_rmsLevel; }

    <span class="comment">/**
     * Peak level of the most recently processed set of audio samples.
     * \return Level in range (0.0, 1.0)
     */</span>
    <span class="type">qreal</span> peakLevel() <span class="keyword">const</span> { <span class="keyword">return</span> m_peakLevel; }

    <span class="comment">/**
     * Position of the audio output device.
     * \return Position in bytes.
     */</span>
    <span class="type">qint64</span> playPosition() <span class="keyword">const</span> { <span class="keyword">return</span> m_playPosition; }

    <span class="comment">/**
     * Length of the internal engine buffer.
     * \return Buffer length in bytes.
     */</span>
    <span class="type">qint64</span> bufferLength() <span class="keyword">const</span>;

    <span class="comment">/**
     * Amount of data held in the buffer.
     * \return Data length in bytes.
     */</span>
    <span class="type">qint64</span> dataLength() <span class="keyword">const</span> { <span class="keyword">return</span> m_dataLength; }

    <span class="comment">/**
     * Set window function applied to audio data before spectral analysis.
     */</span>
    <span class="type">void</span> setWindowFunction(WindowFunction type);

<span class="keyword">public</span> <span class="keyword">slots</span>:
    <span class="type">void</span> startRecording();
    <span class="type">void</span> startPlayback();
    <span class="type">void</span> suspend();
    <span class="type">void</span> setAudioInputDevice(<span class="keyword">const</span> <span class="type"><a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a></span> <span class="operator">&amp;</span>device);
    <span class="type">void</span> setAudioOutputDevice(<span class="keyword">const</span> <span class="type"><a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a></span> <span class="operator">&amp;</span>device);

<span class="keyword">signals</span>:
    <span class="type">void</span> stateChanged(<span class="type"><a href="qaudio.html">QAudio</a></span><span class="operator">::</span>Mode mode<span class="operator">,</span> <span class="type"><a href="qaudio.html">QAudio</a></span><span class="operator">::</span>State state);

    <span class="comment">/**
     * Informational message for non-modal display
     */</span>
    <span class="type">void</span> infoMessage(<span class="keyword">const</span> <span class="type">QString</span> <span class="operator">&amp;</span>message<span class="operator">,</span> <span class="type">int</span> durationMs);

    <span class="comment">/**
     * Error message for modal display
     */</span>
    <span class="type">void</span> errorMessage(<span class="keyword">const</span> <span class="type">QString</span> <span class="operator">&amp;</span>heading<span class="operator">,</span> <span class="keyword">const</span> <span class="type">QString</span> <span class="operator">&amp;</span>detail);

    <span class="comment">/**
     * Format of audio data has changed
     */</span>
    <span class="type">void</span> formatChanged(<span class="keyword">const</span> <span class="type"><a href="qaudioformat.html">QAudioFormat</a></span> <span class="operator">&amp;</span>format);

    <span class="comment">/**
     * Length of buffer has changed.
     * \param duration Duration in microseconds
     */</span>
    <span class="type">void</span> bufferLengthChanged(<span class="type">qint64</span> duration);

    <span class="comment">/**
     * Amount of data in buffer has changed.
     * \param Length of data in bytes
     */</span>
    <span class="type">void</span> dataLengthChanged(<span class="type">qint64</span> duration);

    <span class="comment">/**
     * Position of the audio input device has changed.
     * \param position Position in bytes
     */</span>
    <span class="type">void</span> recordPositionChanged(<span class="type">qint64</span> position);

    <span class="comment">/**
     * Position of the audio output device has changed.
     * \param position Position in bytes
     */</span>
    <span class="type">void</span> playPositionChanged(<span class="type">qint64</span> position);

    <span class="comment">/**
     * Level changed
     * \param rmsLevel RMS level in range 0.0 - 1.0
     * \param peakLevel Peak level in range 0.0 - 1.0
     * \param numSamples Number of audio samples analyzed
     */</span>
    <span class="type">void</span> levelChanged(<span class="type">qreal</span> rmsLevel<span class="operator">,</span> <span class="type">qreal</span> peakLevel<span class="operator">,</span> <span class="type">int</span> numSamples);

    <span class="comment">/**
     * Spectrum has changed.
     * \param position Position of start of window in bytes
     * \param length   Length of window in bytes
     * \param spectrum Resulting frequency spectrum
     */</span>
    <span class="type">void</span> spectrumChanged(<span class="type">qint64</span> position<span class="operator">,</span> <span class="type">qint64</span> length<span class="operator">,</span> <span class="keyword">const</span> FrequencySpectrum <span class="operator">&amp;</span>spectrum);

    <span class="comment">/**
     * Buffer containing audio data has changed.
     * \param position Position of start of buffer in bytes
     * \param buffer   Buffer
     */</span>
    <span class="type">void</span> bufferChanged(<span class="type">qint64</span> position<span class="operator">,</span> <span class="type">qint64</span> length<span class="operator">,</span> <span class="keyword">const</span> <span class="type">QByteArray</span> <span class="operator">&amp;</span>buffer);

<span class="keyword">private</span> <span class="keyword">slots</span>:
    <span class="type">void</span> audioNotify();
    <span class="type">void</span> audioStateChanged(<span class="type"><a href="qaudio.html">QAudio</a></span><span class="operator">::</span>State state);
    <span class="type">void</span> audioDataReady();
    <span class="type">void</span> spectrumChanged(<span class="keyword">const</span> FrequencySpectrum <span class="operator">&amp;</span>spectrum);

<span class="keyword">private</span>:
    <span class="type">void</span> resetAudioDevices();
    bool initialize();
    bool selectFormat();
    <span class="type">void</span> stopRecording();
    <span class="type">void</span> stopPlayback();
    <span class="type">void</span> setState(<span class="type"><a href="qaudio.html">QAudio</a></span><span class="operator">::</span>State state);
    <span class="type">void</span> setState(<span class="type"><a href="qaudio.html">QAudio</a></span><span class="operator">::</span>Mode mode<span class="operator">,</span> <span class="type"><a href="qaudio.html">QAudio</a></span><span class="operator">::</span>State state);
    <span class="type">void</span> setFormat(<span class="keyword">const</span> <span class="type"><a href="qaudioformat.html">QAudioFormat</a></span> <span class="operator">&amp;</span>format);
    <span class="type">void</span> setRecordPosition(<span class="type">qint64</span> position<span class="operator">,</span> bool forceEmit <span class="operator">=</span> <span class="keyword">false</span>);
    <span class="type">void</span> setPlayPosition(<span class="type">qint64</span> position<span class="operator">,</span> bool forceEmit <span class="operator">=</span> <span class="keyword">false</span>);
    <span class="type">void</span> calculateLevel(<span class="type">qint64</span> position<span class="operator">,</span> <span class="type">qint64</span> length);
    <span class="type">void</span> calculateSpectrum(<span class="type">qint64</span> position);
    <span class="type">void</span> setLevel(<span class="type">qreal</span> rmsLevel<span class="operator">,</span> <span class="type">qreal</span> peakLevel<span class="operator">,</span> <span class="type">int</span> numSamples);

<span class="preprocessor">#ifdef DUMP_DATA</span>
    <span class="type">void</span> createOutputDir();
    <span class="type">QString</span> outputPath() <span class="keyword">const</span> { <span class="keyword">return</span> m_outputDir<span class="operator">.</span>path(); }
<span class="preprocessor">#endif</span>

<span class="preprocessor">#ifdef DUMP_CAPTURED_AUDIO</span>
    <span class="type">void</span> dumpData();
<span class="preprocessor">#endif</span>

<span class="keyword">private</span>:
    <span class="type"><a href="qaudio.html">QAudio</a></span><span class="operator">::</span>Mode        m_mode;
    <span class="type"><a href="qaudio.html">QAudio</a></span><span class="operator">::</span>State       m_state;

    bool                m_generateTone;
    SweptTone           m_tone;

    WavFile<span class="operator">*</span>            m_file;
    <span class="comment">// We need a second file handle via which to read data into m_buffer</span>
    <span class="comment">// for analysis</span>
    WavFile<span class="operator">*</span>            m_analysisFile;

    <span class="type"><a href="qaudioformat.html">QAudioFormat</a></span>        m_format;

    <span class="keyword">const</span> <span class="type">QList</span><span class="operator">&lt;</span><span class="type"><a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a></span><span class="operator">&gt;</span> m_availableAudioInputDevices;
    <span class="type"><a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a></span>    m_audioInputDevice;
    <span class="type"><a href="qaudioinput.html">QAudioInput</a></span><span class="operator">*</span>        m_audioInput;
    <span class="type">QIODevice</span><span class="operator">*</span>          m_audioInputIODevice;
    <span class="type">qint64</span>              m_recordPosition;

    <span class="keyword">const</span> <span class="type">QList</span><span class="operator">&lt;</span><span class="type"><a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a></span><span class="operator">&gt;</span> m_availableAudioOutputDevices;
    <span class="type"><a href="qaudiodeviceinfo.html">QAudioDeviceInfo</a></span>    m_audioOutputDevice;
    <span class="type"><a href="qaudiooutput.html">QAudioOutput</a></span><span class="operator">*</span>       m_audioOutput;
    <span class="type">qint64</span>              m_playPosition;
    <span class="type">QBuffer</span>             m_audioOutputIODevice;

    <span class="type">QByteArray</span>          m_buffer;
    <span class="type">qint64</span>              m_bufferPosition;
    <span class="type">qint64</span>              m_bufferLength;
    <span class="type">qint64</span>              m_dataLength;

    <span class="type">int</span>                 m_levelBufferLength;
    <span class="type">qreal</span>               m_rmsLevel;
    <span class="type">qreal</span>               m_peakLevel;

    <span class="type">int</span>                 m_spectrumBufferLength;
    <span class="type">QByteArray</span>          m_spectrumBuffer;
    SpectrumAnalyser    m_spectrumAnalyser;
    <span class="type">qint64</span>              m_spectrumPosition;

    <span class="type">int</span>                 m_count;

<span class="preprocessor">#ifdef DUMP_DATA</span>
    <span class="type">QDir</span>                m_outputDir;
<span class="preprocessor">#endif</span>

};

<span class="preprocessor">#endif // ENGINE_H</span></pre>
</div>
<!-- @@@spectrum/app/engine.h -->
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2013 Digia Plc and/or its
   subsidiaries. Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    Digia, Qt and their respective logos are trademarks of Digia Plc     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>