~ubuntu-branches/ubuntu/precise/pyalsaaudio/precise

« back to all changes in this revision

Viewing changes to doc/node7.html

  • Committer: Bazaar Package Importer
  • Author(s): Paul Brossier
  • Date: 2006-08-13 17:08:01 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060813170801-j4x8km6jtrg9d0dl
Tags: 0.2-1
* New upstream release
* Add a watch file
* Use debian/examples and debian/docs
* Merge changelog with ubuntu
* Add myself to uploaders field
* Upload to debian (closes: #382796)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 
2
<html>
 
3
<head>
 
4
<link rel="STYLESHEET" href="pyalsaaudio.css" type='text/css' />
 
5
<link rel="first" href="pyalsaaudio.html" title='PyAlsaAudio' />
 
6
<link rel='contents' href='contents.html' title="Contents" />
 
7
<link rel='last' href='about.html' title='About this document...' />
 
8
<link rel='help' href='about.html' title='About this document...' />
 
9
<link rel="next" href="pcm-objects.html" />
 
10
<link rel="prev" href="module-alsaaudio.html" />
 
11
<link rel="parent" href="module-alsaaudio.html" />
 
12
<link rel="next" href="pcm-objects.html" />
 
13
<meta name='aesop' content='information' />
 
14
<title>4.1 PCM Terminology and Concepts</title>
 
15
</head>
 
16
<body>
 
17
<DIV CLASS="navigation">
 
18
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
 
19
<table align="center" width="100%" cellpadding="0" cellspacing="2">
 
20
<tr>
 
21
<td class='online-navigation'><a rel="prev" title="4 alsaaudio"
 
22
  href="module-alsaaudio.html"><img src='previous.png'
 
23
  border='0' height='32'  alt='Previous Page' width='32' /></A></td>
 
24
<td class='online-navigation'><a rel="parent" title="4 alsaaudio"
 
25
  href="module-alsaaudio.html"><img src='up.png'
 
26
  border='0' height='32'  alt='Up One Level' width='32' /></A></td>
 
27
<td class='online-navigation'><a rel="next" title="4.2 PCM Objects"
 
28
  href="pcm-objects.html"><img src='next.png'
 
29
  border='0' height='32'  alt='Next Page' width='32' /></A></td>
 
30
<td align="center" width="100%">PyAlsaAudio</td>
 
31
<td class='online-navigation'><a rel="contents" title="Table of Contents"
 
32
  href="contents.html"><img src='contents.png'
 
33
  border='0' height='32'  alt='Contents' width='32' /></A></td>
 
34
<td class='online-navigation'><img src='blank.png'
 
35
  border='0' height='32'  alt='' width='32' /></td>
 
36
<td class='online-navigation'><img src='blank.png'
 
37
  border='0' height='32'  alt='' width='32' /></td>
 
38
</tr></table>
 
39
<div class='online-navigation'>
 
40
<b class="navlabel">Previous:</b>
 
41
<a class="sectref" rel="prev" href="module-alsaaudio.html">4 alsaaudio</A>
 
42
<b class="navlabel">Up:</b>
 
43
<a class="sectref" rel="parent" href="module-alsaaudio.html">4 alsaaudio</A>
 
44
<b class="navlabel">Next:</b>
 
45
<a class="sectref" rel="next" href="pcm-objects.html">4.2 PCM Objects</A>
 
46
</div>
 
47
<hr /></div>
 
48
</DIV>
 
49
<!--End of Navigation Panel-->
 
50
 
 
51
<H2><A NAME="SECTION002410000000000000000">
 
52
4.1 PCM Terminology and Concepts</A>
 
53
</H2>
 
54
 
 
55
<P>
 
56
In order to use PCM devices it is useful to be familiar with some concepts and
 
57
terminology.
 
58
 
 
59
<P>
 
60
<DL>
 
61
<DT><STRONG>Sample</STRONG></DT>
 
62
<DD>PCM audio, whether it is input or output, consists at the lowest level
 
63
of a number of single samples. A sample represents the sound in a single channel in
 
64
a brief interval. If more than one channel is in use, more than one sample is required
 
65
for each interval to describe the sound. Samples can be of many different sizes, ranging
 
66
from 8 bit to 64 bit presition. The specific format of each sample can also vary - they 
 
67
can be big endian byte order, little endian byte order, or even floats.
 
68
 
 
69
<P>
 
70
</DD>
 
71
<DT><STRONG>Frame</STRONG></DT>
 
72
<DD>A frame consists of exactly one sample per channel. If there is only one
 
73
channel (Mono sound) a frame is simply a single sample. If the sound is stereo, each frame
 
74
consists of two samples, etc.
 
75
 
 
76
<P>
 
77
</DD>
 
78
<DT><STRONG>Frame size</STRONG></DT>
 
79
<DD>This is the size in bytes of each frame. This can vary a lot: if each sample is
 
80
8 bits, and we're handling mono sound, the frame size is one byte. Similarly in 6 channel audio with
 
81
64 bit floating point samples, the frame size is 48 bytes
 
82
 
 
83
<P>
 
84
</DD>
 
85
<DT><STRONG>Rate</STRONG></DT>
 
86
<DD>PCM sound consists of a flow of sound frames. The sound rate controls how often
 
87
the current frame is replaced. For example, a rate of 8000 Hz means that a new frame is played 
 
88
or captured 8000 times per second.
 
89
 
 
90
<P>
 
91
</DD>
 
92
<DT><STRONG>Data rate</STRONG></DT>
 
93
<DD>This is the number of bytes, which must be recorded or provided per second
 
94
at a certain frame size and rate. 
 
95
 
 
96
<P>
 
97
8000 Hz mono sound with 8 bit (1 byte) samples has a data rate of 8000 * 1 * 1 = 8 kb/s
 
98
 
 
99
<P>
 
100
At the other end of the scale, 96000 Hz, 6 channel sound with 64 bit (8 bytes) samples
 
101
has a data rate of 96000 * 6 * 8 = 4608 kb/s (almost 5 Mb sound data per second)
 
102
 
 
103
<P>
 
104
</DD>
 
105
<DT><STRONG>Period</STRONG></DT>
 
106
<DD>When the hardware processes data this is done in chunks of frames. The time interval
 
107
between each processing (A/D or D/A conversion) is known as the period. The size of the period has
 
108
direct implication on the latency of the sound input or output. For low-latency the period size should
 
109
be very small, while low CPU resource usage would usually demand larger period sizes. With ALSA, the
 
110
CPU utilization is not impacted much by the period size, since the kernel layer buffers multiple
 
111
periods internally, so each period generates an interrupt and a memory copy, but userspace can be
 
112
slower and read or write multiple periods at the same time.
 
113
 
 
114
<P>
 
115
</DD>
 
116
<DT><STRONG>Period size</STRONG></DT>
 
117
<DD>This is the size of each period in Hz. <em>Not bytes, but Hz!.</em> In <tt class="module">alsaaudio</tt>
 
118
the period size is set directly, and it is therefore important to understand the significance of this 
 
119
number. If the period size is configured to for example 32, each write should contain exactly 32 frames
 
120
of sound data, and each read will return either 32 frames of data or nothing at all.
 
121
 
 
122
<P>
 
123
</DD>
 
124
</DL>
 
125
 
 
126
<P>
 
127
Once you understand these concepts, you will be ready to actually utilize PCM API. Read on.
 
128
 
 
129
<P>
 
130
 
 
131
<DIV CLASS="navigation">
 
132
<div class='online-navigation'>
 
133
<p></p><hr />
 
134
<table align="center" width="100%" cellpadding="0" cellspacing="2">
 
135
<tr>
 
136
<td class='online-navigation'><a rel="prev" title="4 alsaaudio"
 
137
  href="module-alsaaudio.html"><img src='previous.png'
 
138
  border='0' height='32'  alt='Previous Page' width='32' /></A></td>
 
139
<td class='online-navigation'><a rel="parent" title="4 alsaaudio"
 
140
  href="module-alsaaudio.html"><img src='up.png'
 
141
  border='0' height='32'  alt='Up One Level' width='32' /></A></td>
 
142
<td class='online-navigation'><a rel="next" title="4.2 PCM Objects"
 
143
  href="pcm-objects.html"><img src='next.png'
 
144
  border='0' height='32'  alt='Next Page' width='32' /></A></td>
 
145
<td align="center" width="100%">PyAlsaAudio</td>
 
146
<td class='online-navigation'><a rel="contents" title="Table of Contents"
 
147
  href="contents.html"><img src='contents.png'
 
148
  border='0' height='32'  alt='Contents' width='32' /></A></td>
 
149
<td class='online-navigation'><img src='blank.png'
 
150
  border='0' height='32'  alt='' width='32' /></td>
 
151
<td class='online-navigation'><img src='blank.png'
 
152
  border='0' height='32'  alt='' width='32' /></td>
 
153
</tr></table>
 
154
<div class='online-navigation'>
 
155
<b class="navlabel">Previous:</b>
 
156
<a class="sectref" rel="prev" href="module-alsaaudio.html">4 alsaaudio</A>
 
157
<b class="navlabel">Up:</b>
 
158
<a class="sectref" rel="parent" href="module-alsaaudio.html">4 alsaaudio</A>
 
159
<b class="navlabel">Next:</b>
 
160
<a class="sectref" rel="next" href="pcm-objects.html">4.2 PCM Objects</A>
 
161
</div>
 
162
</div>
 
163
<hr />
 
164
<span class="release-info">Release 0.2.</span>
 
165
</DIV>
 
166
<!--End of Navigation Panel-->
 
167
 
 
168
</BODY>
 
169
</HTML>