idnits 2.17.1 draft-ietf-avtext-mixer-to-client-audio-level-04.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (August 27, 2011) is 4626 days in the past. Is this intentional? -- Found something which looks like a code comment -- if you have code sections in the document, please surround them with '' and '' lines. Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) == Unused Reference: 'ITU.P56.1993' is defined on line 511, but no explicit reference was found in the text ** Obsolete normative reference: RFC 5285 (Obsoleted by RFC 8285) == Outdated reference: A later version (-05) exists of draft-ietf-avtcore-srtp-encrypted-header-ext-00 == Outdated reference: A later version (-06) exists of draft-ietf-avtext-client-to-mixer-audio-level-03 Summary: 1 error (**), 0 flaws (~~), 4 warnings (==), 2 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group E. Ivov, Ed. 3 Internet-Draft Jitsi 4 Intended status: Standards Track E. Marocco, Ed. 5 Expires: February 28, 2012 Telecom Italia 6 J. Lennox 7 Vidyo, Inc. 8 August 27, 2011 10 A Real-Time Transport Protocol (RTP) Header Extension for Mixer-to- 11 Client Audio Level Indication 12 draft-ietf-avtext-mixer-to-client-audio-level-04 14 Abstract 16 This document describes a mechanism for RTP-level mixers in audio 17 conferences to deliver information about the audio level of 18 individual participants. Such audio level indicators are transported 19 in the same RTP packets as the audio data they pertain to. 21 Status of this Memo 23 This Internet-Draft is submitted in full conformance with the 24 provisions of BCP 78 and BCP 79. 26 Internet-Drafts are working documents of the Internet Engineering 27 Task Force (IETF). Note that other groups may also distribute 28 working documents as Internet-Drafts. The list of current Internet- 29 Drafts is at http://datatracker.ietf.org/drafts/current/. 31 Internet-Drafts are draft documents valid for a maximum of six months 32 and may be updated, replaced, or obsoleted by other documents at any 33 time. It is inappropriate to use Internet-Drafts as reference 34 material or to cite them other than as "work in progress." 36 This Internet-Draft will expire on February 28, 2012. 38 Copyright Notice 40 Copyright (c) 2011 IETF Trust and the persons identified as the 41 document authors. All rights reserved. 43 This document is subject to BCP 78 and the IETF Trust's Legal 44 Provisions Relating to IETF Documents 45 (http://trustee.ietf.org/license-info) in effect on the date of 46 publication of this document. Please review these documents 47 carefully, as they describe your rights and restrictions with respect 48 to this document. Code Components extracted from this document must 49 include Simplified BSD License text as described in Section 4.e of 50 the Trust Legal Provisions and are provided without warranty as 51 described in the Simplified BSD License. 53 Table of Contents 55 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 56 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 4 57 3. Protocol Operation . . . . . . . . . . . . . . . . . . . . . . 4 58 4. Audio Levels . . . . . . . . . . . . . . . . . . . . . . . . . 5 59 5. Signaling Information . . . . . . . . . . . . . . . . . . . . 7 60 6. Security Considerations . . . . . . . . . . . . . . . . . . . 10 61 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 10 62 8. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 10 63 9. Changes From Earlier Versions . . . . . . . . . . . . . . . . 11 64 9.1. Changes From Draft -03 . . . . . . . . . . . . . . . . . . 11 65 9.2. Changes From Draft -02 . . . . . . . . . . . . . . . . . . 11 66 9.3. Changes From Draft -01 . . . . . . . . . . . . . . . . . . 11 67 9.4. Changes From Draft -00 . . . . . . . . . . . . . . . . . . 11 68 10. References . . . . . . . . . . . . . . . . . . . . . . . . . . 12 69 10.1. Normative References . . . . . . . . . . . . . . . . . . . 12 70 10.2. Informative References . . . . . . . . . . . . . . . . . . 12 71 Appendix A. Reference Implementation . . . . . . . . . . . . . . 13 72 A.1. AudioLevelCalculator.java . . . . . . . . . . . . . . . . 13 73 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 15 75 1. Introduction 77 The Framework for Conferencing with the Session Initiation Protocol 78 (SIP) defined in RFC 4353 [RFC4353] presents an overall architecture 79 for multi-party conferencing. Among others, the framework borrows 80 from RTP [RFC3550] and extends the concept of a mixer entity 81 "responsible for combining the media streams that make up a 82 conference, and generating one or more output streams that are 83 delivered to recipients". Every participant would hence receive, in 84 a flat single stream, media originating from all the others. 86 Using such centralized mixer-based architectures simplifies support 87 for conference calls on the client side since they would hardly 88 differ from one-to-one conversations. However, the method also 89 introduces a few limitations. The flat nature of the streams that a 90 mixer would output and send to participants makes it difficult for 91 users to identify the original source of what they are hearing. 93 Mechanisms that allow the mixer to send to participants cues on 94 current speakers (e.g. the CSRC fields in RTP [RFC3550]) only work 95 for speaking/silent binary indications. There are, however, a number 96 of use cases where one would require more detailed information. 97 Possible examples include the presence of background chat/noise/ 98 music/typing, someone breathing noisily in their microphone, or other 99 cases where identifying the source of the disturbance would make it 100 easy to remove it (e.g. by sending a private IM to the concerned 101 party asking them to mute their microphone). A more advanced 102 scenario could involve an intense discussion between multiple 103 participants that the user does not personally know. Audio level 104 information would help better recognize the speakers by associating 105 with them complex (but still human readable) characteristics like 106 loudness and speed for example. 108 One way of presenting such information in a user friendly manner 109 would be for a conferencing client to attach audio level indicators 110 to the corresponding participant related components in the user 111 interface as displayed in Figure 1. 113 ________________________ 114 | | 115 | 00:42 | Weekly Call | 116 |________________________| 117 | | 118 | | 119 | Alice |====== | (S) | 120 | | 121 | Bob |= | | 122 | | 123 | Carol | | (M) | 124 | | 125 | Dave |=== | | 126 | | 127 |________________________| 129 Figure 1: Displaying detailed speaker information to the user by 130 including audio level for every participant. 132 Implementing a user interface like the above requires analysis of the 133 media sent from other participants. In a conventional audio 134 conference this is only possible for the mixer since all other 135 conference participants are generally receiving a single, flat audio 136 stream and have therefore no immediate way of determining individual 137 audio levels. 139 This document specifies an RTP extension header that allows such 140 mixers to deliver audio level information to conference participants 141 by including it directly in the RTP packets transporting the 142 corresponding audio data. 144 2. Terminology 146 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 147 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 148 document are to be interpreted as described in RFC 2119 [RFC2119]. 150 3. Protocol Operation 152 According to RFC 3550 [RFC3550] a mixer is expected to include in 153 outgoing RTP packets a list of identifiers (CSRC IDs) indicating the 154 sources that contributed to the resulting stream. The presence of 155 such CSRC IDs allows RTP clients to determine, in a binary way, the 156 active speaker(s) in any given moment. RTCP also provides a basic 157 mechanism to map the CSRC IDs to user identities through the CNAME 158 field. More advanced mechanisms can exist depending on the signaling 159 protocol used to establish and control a conference. In the case of 160 the Session Initiation Protocol [RFC3261] for example, the Event 161 Package for Conference State [RFC4575] defines a tag which 162 binds CSRC IDs to media streams and SIP URIs. 164 This document describes an RTP header extension that allows mixers to 165 indicate the audio-level of every contributing conference participant 166 (CSRC) in addition to simply indicating their on/off status. This 167 new header extension uses "General Mechanism for RTP Header 168 Extensions" described in [RFC5285]. 170 Each instance of this header contains a list of one-octet audio 171 levels expressed in -dBov, with values from 0 to 127 representing 0 172 to -127 dBov(see Figure 2 and Figure 3). Appendix A provides a 173 reference implementation indicating one way of obtaining such values 174 from raw audio samples. 176 Every audio level value pertains to the CSRC identifier located at 177 the corresponding position in the CSRC list. In other words, the 178 first value would indicate the audio level of the conference 179 participant represented by the first CSRC identifier in that packet 180 and so forth. The number and order of these values MUST therefore 181 match the number and order of the CSRC IDs present in the same 182 packet. 184 When encoding audio level information, a mixer SHOULD include in a 185 packet information that corresponds to the audio data being 186 transported in that same packet. It is important that these values 187 follow the actual stream as closely as possible. Therefore a mixer 188 SHOULD also calculate the values after the original contributing 189 stream has undergone possible processing such as level normalization, 190 and noise reduction for example. 192 It can sometimes happen that a conference involves more than a single 193 mixer. In such cases each of the mixers MAY choose to relay the CSRC 194 list and audio-level information they receive from peer mixers (as 195 long as the total CSRC count remains below 16). Given that the 196 maximum audio level is not precisely defined by this specification, 197 it is likely that in such situations average audio levels would be 198 perceptibly different for the participants located behind the 199 different mixers. 201 4. Audio Levels 203 The audio level header extension carries the level of the audio in 204 the RTP payload of the packet it is associated with. This 205 information is carried in an RTP header extension element as defined 206 by the "General Mechanism for RTP Header Extensions" [RFC5285]. 208 The payload of the audio level header extension element can be 209 encoded using the one-byte or the two-byte header defined in 210 [RFC5285]. Figure 2 and Figure 3 show sample audio level encodings 211 with each of them. 213 0 1 2 3 214 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 215 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 216 | ID | len=2 |0| level 1 |0| level 2 |0| level 3 | 217 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 219 Sample audio level encoding using the one-byte header format 221 Figure 2 223 0 1 2 3 224 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 225 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 226 | ID | len=3 |0| level 1 |0| level 2 | 227 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 228 |0| level 3 | 0 (pad) | ... 229 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 231 Sample audio level encoding using the two-byte header format 233 Figure 3 235 In the case of the one-byte header format, the 4-bit len field is the 236 number minus one of data bytes (i.e. audio level values) transported 237 in this header extension element following the one-byte header. 238 Therefore, the value zero in this field indicates that one byte of 239 data follows. In the case of the two-byte header format the 8-bit 240 len field contains the exact number of audio levels carried in the 241 extension. RFC 3550 [RFC3550] only allows RTP packets to carry a 242 maximum of 15 CSRC IDs. Given that audio levels directly refer to 243 CSRC IDs, implementations MUST NOT include more than 15 audio level 244 values. The maximum value allowed in the len field is therefore 14 245 for one-byte header format and 15 for two-byte header format. 247 Audio levels in this document are defined in the same manner as is 248 audio noise level in the RTP Payload Comfort Noise specification 249 [RFC3389]. In the comfort noise specification, the overall magnitude 250 of the noise level in comfort noise is encoded into the first byte of 251 the payload, with spectral information about the noise in subsequent 252 bytes. This specification's audio level parameter is defined so as 253 to be identical to the comfort noise payload's noise-level byte. 255 The magnitude of the audio level itself is packed into the seven 256 least significant bits of the single byte of the header extension, 257 shown in Figure 2 and Figure 3. The least significant bit of the 258 audio level magnitude is packed into the least significant bit of the 259 byte. The most significant bit of the byte is unused and always set 260 to 0. 262 The audio level is expressed in -dBov, with values from 0 to 127 263 representing 0 to -127 dBov. dBov is the level, in decibels, relative 264 to the overload point of the system, i.e. the maximum-amplitude 265 signal that can be handled by the system without clipping. (Note: 266 Representation relative to the overload point of a system is 267 particularly useful for digital implementations, since one does not 268 need to know the relative calibration of the analog circuitry.) For 269 example, in the case of u-law (audio/pcmu) audio [ITU.G.711], the 0 270 dBov reference would be a square wave with values +/- 8031. (This 271 translates to 6.18 dBm0, relative to u-law's dBm0 definition in Table 272 6 of G.711.) 274 The audio level for digital silence, for example for a muted audio 275 source, MUST be represented as 127 (-127 dBov), regardless of the 276 dynamic range of the encoded audio format. 278 The audio level header extension only carries the level of the audio 279 in the RTP payload of the packet it is associated with, with no long- 280 term averaging or smoothing applied. That level is measured as a 281 root mean square of all the samples in the measured range. 283 To simplify implementation of the encoding procedures described here, 284 this specification provides a sample Java implementation (Appendix A) 285 of an audio level calculator that helps obtain such values from raw 286 linear PCM audio samples. 288 5. Signaling Information 290 The URI for declaring the audio level header extension in an SDP 291 extmap attribute and mapping it to a local extension header 292 identifier is "urn:ietf:params:rtp-hdrext:csrc-audio-level". There 293 is no additional setup information needed for this extension (i.e. no 294 extensionattributes). 296 An example attribute line in the SDP, for a conference might be: 298 a=extmap:7 urn:ietf:params:rtp-hdrext:csrc-audio-level 300 The above mapping will most often be provided per media stream (in 301 the media-level section(s) of SDP, i.e., after an "m=" line) or 302 globally if there is more than one stream containing audio level 303 indicators in a session. 305 Presence of the above attribute in the SDP description of a media 306 stream indicates that RTP packets in that stream, which contain the 307 level extension defined in this document, will be carrying them with 308 an ID of 7. 310 Conferencing clients that support audio level indicators and have no 311 mixing capabilities would not be able to provide content for this 312 audio level extension and would hence have to always include the 313 direction parameter in the "extmap" attribute with a value of 314 "recvonly". Conference focus entities with mixing capabilities can 315 omit the direction or set it to "sendrecv" in SDP offers. Such 316 entities would need to set it to "sendonly" in SDP answers to offers 317 with a "recvonly" parameter and to "sendrecv" when answering other 318 "sendrecv" offers. 320 This specification only defines use of the audio level extensions in 321 audio streams. They MUST NOT be advertised with other media types 322 such as video or text for example. 324 The following Figure 4 and Figure 5 show two example offer/answer 325 exchanges between a conferencing client and a focus, and between two 326 conference focus entities. 328 v=0 329 o=alice 2890844526 2890844526 IN IP6 host.example.com 330 c=IN IP6 host.example.com 331 t=0 0 332 m=audio 49170 RTP/AVP 0 4 333 a=rtpmap:0 PCMU/8000 334 a=rtpmap:4 G723/8000 335 a=extmap:1/recvonly urn:ietf:params:rtp-hdrext:csrc-audio-level 337 v=0 338 i=A Seminar on the session description protocol 339 o=conf-focus 2890844730 2890844730 IN IP6 focus.example.net 340 c=IN IP6 focus.example.net 341 t=0 0 342 m=audio 52543 RTP/AVP 0 343 a=rtpmap:0 PCMU/8000 344 a=extmap:1/sendonly urn:ietf:params:rtp-hdrext:csrc-audio-level 346 A client-initiated example SDP offer/answer exchange negotiating an 347 audio stream with one-way flow of of audio level information. 349 Figure 4 351 v=0 352 i=Un seminaire sur le protocole de description des sessions 353 o=fr-focus 2890844730 2890844730 IN IP6 focus.fr.example.net 354 c=IN IP6 focus.fr.example.net 355 t=0 0 356 m=audio 49170 RTP/AVP 0 357 a=rtpmap:0 PCMU/8000 358 a=extmap:1/sendrecv urn:ietf:params:rtp-hdrext:csrc-audio-level 360 v=0 361 i=A Seminar on the session description protocol 362 o=us-focus 2890844526 2890844526 IN IP6 focus.us.example.net 363 c=IN IP6 focus.us.example.net 364 t=0 0 365 m=audio 52543 RTP/AVP 0 366 a=rtpmap:0 PCMU/8000 367 a=extmap:1/sendrecv urn:ietf:params:rtp-hdrext:csrc-audio-level 369 An example SDP offer/answer exchange between two conference focus 370 entities with mixing capabilities negotiating an audio stream with 371 bidirectional flow of audio level information. 373 Figure 5 375 6. Security Considerations 377 1. This document defines a means of attributing audio level to a 378 particular participant in a conference. An attacker may try to 379 modify the content of RTP packets in a way that would make audio 380 activity from one participant appear as coming from another. 381 2. Furthermore, the fact that audio level values would not be 382 protected even in an SRTP session might be of concern in some 383 cases where the activity of a particular participant in a 384 conference is confidential. Also, as discussed in 385 [I-D.perkins-avt-srtp-vbr-audio], an attacker might be able to 386 infer information about the conversation, possibly with phoneme- 387 level resolution. 388 3. Both of the above are concerns that stem from the design of the 389 RTP protocol itself and they would probably also apply when using 390 CSRC identifiers the way they were specified in RFC 3550 391 [RFC3550]. It is therefore important that according to the needs 392 of a particular scenario, implementors and deployers consider use 393 of header extension encryption 394 [I-D.ietf-avtcore-srtp-encrypted-header-ext] or a lower level 395 security and authentication mechanism. 397 7. IANA Considerations 399 This document defines a new extension URI that, if approved, would 400 need to be added to the RTP Compact Header Extensions sub-registry of 401 the Real-Time Transport Protocol (RTP) Parameters registry, according 402 to the following data: 404 Extension URI: urn:ietf:params:rtp-hdrext:csrc-audio-level 405 Description: Mixer-to-client audio level indicators 406 Contact: emcho@jitsi.org 407 Reference: RFC XXXX 409 Note to the RFC-Editor: please replace "RFC XXXX" by the number of 410 this RFC. 412 8. Acknowledgments 414 Lyubomir Marinov contributed level measurement and rendering code. 416 Keith Drage, Roni Even, John Elwell, Kevin P. Fleming, Ingemar 417 Johansson, Michael Ramalho, Magnus Westerlund and several others 418 provided helpful feedback over the avt and avtext mailing lists. 420 Jitsi's participation in this specification is funded by the NLnet 421 Foundation. 423 9. Changes From Earlier Versions 425 Note to the RFC-Editor: please remove this section prior to 426 publication as an RFC. 428 9.1. Changes From Draft -03 430 o Addressed editorial comments made on the mailing list. 432 9.2. Changes From Draft -02 434 o Removed the no-data use case that allowed sending levels in RTP 435 packets. Choosing the right RTP payload type for this use case 436 would have incurred complexity without bringing any real value. 437 o Merged the "Header Format" and the "Audio level encoding" sections 438 into a single "Audio Levels" section. 439 o Changed encoding related text so that it would cover both the one- 440 byte and the two-byte header formats. 441 o Clarified use of root mean square for dBov calculation 442 o Added a reference to [I-D.perkins-avt-srtp-vbr-audio] to better 443 explain some "Security Considerations" . 444 o Other minor editorial changes. 446 9.3. Changes From Draft -01 448 o Removed code related the AudioLevelRenderer from "APPENDIX A. 449 Reference Implementation" as it was considered an implementation 450 matter by the working group. 451 o Modified the AudioLevelCalculator in "APPENDIX A. Reference 452 Implementation" to take overload as a parameter. 453 o Clarified non-use of audio levels in video streams 454 o Closed the P.56 open issue. It was agreed on IETF 80 that P.56 is 455 mostly about speech levels and the levels transported by the 456 extension defined here should also be able to serve as an 457 indication for noise. 458 o The Open Issues section has been removed as all issues that were 459 in there are now resolved or clarified. 460 o Editorial changes for consistency with 461 [I-D.ietf-avtext-client-to-mixer-audio-level]. 463 9.4. Changes From Draft -00 465 o Added code for sound pressure calculation and measurement in 466 "APPENDIX A. Reference Implementation". 468 o Changed affiliation for Emil Ivov. 469 o Removed "Appendix: Design choices". 471 10. References 473 10.1. Normative References 475 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 476 Requirement Levels", BCP 14, RFC 2119, March 1997. 478 [RFC3550] Schulzrinne, H., Casner, S., Frederick, R., and V. 479 Jacobson, "RTP: A Transport Protocol for Real-Time 480 Applications", STD 64, RFC 3550, July 2003. 482 [RFC5285] Singer, D. and H. Desineni, "A General Mechanism for RTP 483 Header Extensions", RFC 5285, July 2008. 485 10.2. Informative References 487 [I-D.ietf-avtcore-srtp-encrypted-header-ext] 488 Lennox, J., "Encryption of Header Extensions in the Secure 489 Real-Time Transport Protocol (SRTP)", 490 draft-ietf-avtcore-srtp-encrypted-header-ext-00 (work in 491 progress), June 2011. 493 [I-D.ietf-avtext-client-to-mixer-audio-level] 494 Lennox, J., Ivov, E., and E. Marocco, "A Real-Time 495 Transport Protocol (RTP) Header Extension for Client-to- 496 Mixer Audio Level Indication", 497 draft-ietf-avtext-client-to-mixer-audio-level-03 (work in 498 progress), July 2011. 500 [I-D.perkins-avt-srtp-vbr-audio] 501 Perkins, C. and J. Valin, "Guidelines for the use of 502 Variable Bit Rate Audio with Secure RTP", 503 draft-perkins-avt-srtp-vbr-audio-05 (work in progress), 504 December 2010. 506 [ITU.G.711] 507 International Telecommunications Union, "Pulse Code 508 Modulation (PCM) of Voice Frequencies", ITU- 509 T Recommendation G.711, November 1988. 511 [ITU.P56.1993] 512 International Telecommunications Union, "Objective 513 Measurement of Active Speech Level", ITU-T Recommendation 514 P.56, March 1988. 516 [RFC3261] Rosenberg, J., Schulzrinne, H., Camarillo, G., Johnston, 517 A., Peterson, J., Sparks, R., Handley, M., and E. 518 Schooler, "SIP: Session Initiation Protocol", RFC 3261, 519 June 2002. 521 [RFC3389] Zopf, R., "Real-time Transport Protocol (RTP) Payload for 522 Comfort Noise (CN)", RFC 3389, September 2002. 524 [RFC4353] Rosenberg, J., "A Framework for Conferencing with the 525 Session Initiation Protocol (SIP)", RFC 4353, 526 February 2006. 528 [RFC4575] Rosenberg, J., Schulzrinne, H., and O. Levin, "A Session 529 Initiation Protocol (SIP) Event Package for Conference 530 State", RFC 4575, August 2006. 532 Appendix A. Reference Implementation 534 This appendix contains Java code for a reference implementation of 535 the level calculation and rendering methods.The code is not normative 536 and by no means the only possible implementation. Its purpose is to 537 help implementors add audio level support to mixers and clients. 539 The Java code contains an AudioLevelCalculator class that calculates 540 the sound pressure level of a signal with specific samples. It can 541 be used in mixers to generate values suitable for the level extension 542 headers. 544 The implementation is provided in Java but does not rely on any of 545 the language specific and can be easily ported to another. 547 A.1. AudioLevelCalculator.java 549 /** 550 * Calculates the audio level of specific samples of a signal based on 551 * sound pressure level. 552 */ 553 public class AudioLevelCalculator 554 { 556 /** 557 * Calculates the sound pressure level of a signal with specific 558 * samples. 559 * 560 * @param samples the samples of the signal to calculate the sound 561 * pressure level of. The samples are specified as an int 562 * array starting at offset, extending length 563 * number of elements and each int element in the specified 564 * range representing a sample of the signal to calculate the sound 565 * pressure level of. Though a sample is provided in the form of an 566 * int value, the sample size in bits is determined by the 567 * caller via overload. 568 * 569 * @param offset the offset in samples at which the samples 570 * start 571 * 572 * @param length the length of the signal specified in 573 * samples starting at offset 574 * 575 * @param overload the overload (point) of signal. 576 * For example, overload can be {@link Byte#MAX_VALUE} 577 * for 8-bit signed samples or {@link Short#MAX_VALUE} for 578 * 16-bit signed samples. 579 * 580 * @return the sound pressure level of the specified signal 581 */ 582 public static int calculateSoundPressureLevel( 583 int[] samples, int offset, int length, 584 int overload) 585 { 586 /* 587 * Calcuate the root mean square of the signal i.e. the 588 * effective sound pressure. 589 */ 590 double rms = 0; 592 for (; offset < length; offset++) 593 { 594 double sample = samples[offset]; 596 sample /= overload; 597 rms += sample * sample; 598 } 599 rms = (length == 0) ? 0 : Math.sqrt(rms / length); 601 /* 602 * The sound pressure level is a logarithmic measure of the 603 * effectivesound pressure of a sound relative to a reference 604 * value and is measured in decibels. 605 */ 606 double db; 608 /* 609 * The minimum sound pressure level which matches the maximum 610 * of the sound meter. 611 */ 612 final double MIN_SOUND_PRESSURE_LEVEL = 0; 613 /* 614 * The maximum sound pressure level which matches the maximum 615 * of the sound meter. 616 */ 617 final double MAX_SOUND_PRESSURE_LEVEL 618 = 127 /* HUMAN TINNITUS (RINGING IN THE EARS) BEGINS */; 620 if (rms > 0) 621 { 622 /* 623 * The commonly used "zero" reference sound pressure in air 624 * is 20 uPa RMS, which is usually considered the threshold 625 * of human hearing. 626 */ 627 final double REF_SOUND_PRESSURE = 0.00002; 629 db = 20 * Math.log10(rms / REF_SOUND_PRESSURE); 631 /* 632 * Ensure that the calculated level is within the minimum 633 * and maximum sound pressure level. 634 */ 635 if (db < MIN_SOUND_PRESSURE_LEVEL) 636 db = MIN_SOUND_PRESSURE_LEVEL; 637 else if (db > MAX_SOUND_PRESSURE_LEVEL) 638 db = MAX_SOUND_PRESSURE_LEVEL; 639 } 640 else 641 { 642 db = MIN_SOUND_PRESSURE_LEVEL; 643 } 645 return (int) db; 646 } 647 } 649 AudioLevelCalculator.java 651 Authors' Addresses 653 Emil Ivov (editor) 654 Jitsi 655 Strasbourg 67000 656 France 658 Email: emcho@jitsi.org 660 Enrico Marocco (editor) 661 Telecom Italia 662 Via G. Reiss Romoli, 274 663 Turin 10148 664 Italy 666 Email: enrico.marocco@telecomitalia.it 668 Jonathan Lennox 669 Vidyo, Inc. 670 433 Hackensack Avenue 671 Seventh Floor 672 Hackensack, NJ 07601 673 US 675 Email: jonathan@vidyo.com