summaryrefslogtreecommitdiffstats
path: root/doc/src/audiooverview.qdoc
blob: c47aed95305bf9d330e083da71b76616b0c221ed (plain)
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
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** GNU Free Documentation License
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms
** and conditions contained in a signed written agreement between you
** and Nokia.
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
\page audiooverview.html
\title Audio Overview
\brief Audio playback and recording

\section1 Audio Features

Qt Multimedia offers a range of audio classes, covering both low and
high level approaches to audio input and output.

\section1 Audio Implementation Details

\section2 Low level audio playback and recording
Qt Multimedia offers classes for raw access to audio input and output
facilities, allowing applications to receive raw data from devices like
microphones, and to write raw data to speakers or other devices.  Generally
these classes do not do any audio decoding, or other processing, but they
can support different types of raw audio data.

The QAudioOutput class offers raw audio data output, while QAudioInput
offers raw audio data input.  Both classes have adjustable buffers and
latency, so they are suitable for both low latency usecases (like games
or VOIP) and high latency (like music playback).  The available hardware
determines what audio outputs and inputs are available.

\section3 Push and Pull
[TBD] - description of push vs. pull mode.

\section2 Low latency sound effects

In addition to the raw access to sound devices described above, the QSoundEffect class (and
\l {SoundEffect} QML element) offers a slightly higher level way to play
sounds.  These classes allow you to specify a WAV format file which can
then be played with low latency when necessary.  Both QSoundEffect and the
SoundEffect element have essentially the same API.

You can adjust the number of \l {QSoundEffect::setLoops()}{loops} a sound effect is played, as well as
the \l {QSoundEffect::setVolume()}{volume} (or \l {QSoundEffect::setMuted()}{muting}) of the effect.

For older, Qt 4.x based applications \l QSound is also available.  Applications
are recommended to use QSoundEffect where possible.

\section2 Playing compressed audio
For playing media or audio files that are not simple, raw audio, you can
use the \l QMediaPlayer C++ class, or the \l {Audio} and \l {MediaPlayer} QML elements.
The QMediaPlayer class (and MediaPlayer element) is also capable of playing
\l{multimedia-playing-video}{video}, if required.  The compressed audio formats supported does depend
on the operating system environment, and also what media plugins the user
may have installed.

Here is how you play a local file using C++:

    \snippet doc/src/snippets/multimedia-snippets/media.cpp Local playback

You can also put files (even remote URLs) into a playlist:
    \snippet doc/src/snippets/multimedia-snippets/media.cpp Audio playlist

\section2 Recording audio to a file
For recording audio to a file, the \l {QAudioRecorder} class allows you
to compress audio data from an input device and record it.

    \snippet doc/src/snippets/multimedia-snippets/media.cpp Audio recorder

\section1 Examples

There are both C++ and QML examples available.

C++ Examples:

\section2 Record a Sound Source

\l{audiorecorder}{AudioRecorder} is a demonstration of the discovery of
the supported devices and codecs and the use of recording functions in the
QAudioRecorder class.

\list
    \o \l audiodevices
    \o \l audioinput
    \o \l audiooutput
    \o \l audiorecorder
    \o \l spectrum
\endlist

QML Examples:
[TBD]

\section1 Reference Documentation

\section2 Audio Classes

\annotatedlist multimedia_audio

\section2 QML Elements

\list
    \o \l Audio
    \o \l MediaPlayer
\endlist

*/