idnits 2.17.1 draft-ietf-avtext-mixer-to-client-audio-level-03.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 (July 5, 2011) is 4669 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 504, but no explicit reference was found in the text ** Obsolete normative reference: RFC 5285 (Obsoleted by RFC 8285) == Outdated reference: A later version (-06) exists of draft-ietf-avtext-client-to-mixer-audio-level-02 Summary: 1 error (**), 0 flaws (~~), 3 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: January 6, 2012 Telecom Italia 6 J. Lennox 7 Vidyo, Inc. 8 July 5, 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-03 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 January 6, 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 -02 . . . . . . . . . . . . . . . . . . 11 65 9.2. Changes From Draft -01 . . . . . . . . . . . . . . . . . . 11 66 9.3. Changes From Draft -00 . . . . . . . . . . . . . . . . . . 11 67 10. References . . . . . . . . . . . . . . . . . . . . . . . . . . 12 68 10.1. Normative References . . . . . . . . . . . . . . . . . . . 12 69 10.2. Informative References . . . . . . . . . . . . . . . . . . 12 70 Appendix A. Reference Implementation . . . . . . . . . . . . . . 13 71 A.1. AudioLevelCalculator.java . . . . . . . . . . . . . . . . 13 72 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 15 74 1. Introduction 76 The Framework for Conferencing with the Session Initiation Protocol 77 (SIP) defined in RFC 4353 [RFC4353] presents an overall architecture 78 for multi-party conferencing. Among others, the framework borrows 79 from RTP [RFC3550] and extends the concept of a mixer entity 80 "responsible for combining the media streams that make up a 81 conference, and generating one or more output streams that are 82 delivered to recipients". Every participant would hence receive, in 83 a flat single stream, media originating from all the others. 85 Using such centralized mixer-based architectures simplifies support 86 for conference calls on the client side since they would hardly 87 differ from one-to-one conversations. However, the method also 88 introduces a few limitations. The flat nature of the streams that a 89 mixer would output and send to participants makes it difficult for 90 users to identify the original source of what they are hearing. 92 Mechanisms that allow the mixer to send to participants cues on 93 current speakers (e.g. the CSRC fields in RTP [RFC3550]) only work 94 for speaking/silent binary indications. There are, however, a number 95 of use cases where one would require more detailed information. 96 Possible examples include the presence of background chat/noise/ 97 music/typing, someone breathing noisily in their microphone, or other 98 cases where identifying the source of the disturbance would make it 99 easy to remove it (e.g. by sending a private IM to the concerned 100 party asking them to mute their microphone). A more advanced 101 scenario could involve an intense discussion between multiple 102 participants that the user does not personally know. Audio level 103 information would help better recognize the speakers by associating 104 with them complex (but still human readable) characteristics like 105 loudness and speed for example. 107 One way of presenting such information in a user friendly manner 108 would be for a conferencing client to attach audio level indicators 109 to the corresponding participant related components in the user 110 interface as displayed in Figure 1. 112 ________________________ 113 | | 114 | 00:42 | Weekly Call | 115 |________________________| 116 | | 117 | | 118 | Alice |====== | (S) | 119 | | 120 | Bob |= | | 121 | | 122 | Carol | | (M) | 123 | | 124 | Dave |=== | | 125 | | 126 |________________________| 128 Figure 1: Displaying detailed speaker information to the user by 129 including audio level for every participant. 131 Implementing a user interface like the above requires analysis of the 132 media sent from other participants. In a conventional audio 133 conference this is only possible for the mixer since all other 134 conference participants are generally receiving a single, flat audio 135 stream and have therefore no immediate way of determining individual 136 audio levels. 138 This document specifies an RTP extension header that allows such 139 mixers to deliver audio level information to conference participants 140 by including it directly in the RTP packets transporting the 141 corresponding audio data. 143 2. Terminology 145 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 146 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 147 document are to be interpreted as described in RFC 2119 [RFC2119]. 149 3. Protocol Operation 151 According to RFC 3550 [RFC3550] a mixer is expected to include in 152 outgoing RTP packets a list of identifiers (CSRC IDs) indicating the 153 sources that contributed to the resulting stream. The presence of 154 such CSRC IDs allows RTP clients to determine, in a binary way, the 155 active speaker(s) in any given moment. RTCP also provides a basic 156 mechanism to map the CSRC IDs to user identities through the CNAME 157 field. More advanced mechanisms, may exist depending on the 158 signaling protocol used to establish and control a conference. In 159 the case of the Session Initiation Protocol [RFC3261] for example, 160 the Event Package for Conference State [RFC4575] defines a 161 tag which binds CSRC IDs to media streams and SIP URIs. 163 This document describes an RTP header extension that allows mixers to 164 indicate the audio-level of every conference participant (CSRC) in 165 addition to simply indicating their on/off status. This new header 166 extension uses "General Mechanism for RTP Header Extensions" 167 described in [RFC5285]. 169 Each instance of this header contains a list of one-octet audio 170 levels expressed in -dBov, with values from 0 to 127 representing 0 171 to -127 dBov(see Figure 2 and Figure 3). Appendix A provides a 172 reference implementation indicating one way of obtaining such values 173 from raw audio samples. 175 Every audio level value pertains to the CSRC identifier located at 176 the corresponding position in the CSRC list. In other words, the 177 first value would indicate the audio level of the conference 178 participant represented by the first CSRC identifier in that packet 179 and so forth. The number and order of these values MUST therefore 180 match the number and order of the CSRC IDs present in the same 181 packet. 183 When encoding audio level information, a mixer SHOULD include in a 184 packet information that corresponds to the audio data being 185 transported in that same packet. It is important that these values 186 follow the actual stream as closely as possible. Therefore a mixer 187 SHOULD also calculate the values after the original contributing 188 stream has undergone possible processing such as level normalization, 189 and noise reduction for example. 191 It may sometimes happen that a conference involves more than a single 192 mixer. In such cases each of the mixers MAY choose to relay the CSRC 193 list and audio-level information they receive from peer mixers (as 194 long as the total CSRC count remains below 16). Given that the 195 maximum audio level is not precisely defined by this specification, 196 it is likely that in such situations average audio levels would be 197 perceptibly different for the participants located behind the 198 different mixers. 200 4. Audio Levels 202 The audio level header extension carries the level of the audio in 203 the RTP payload of the packet it is associated with. This 204 information is carried in an RTP header extension element as defined 205 by the "General Mechanism for RTP Header Extensions" [RFC5285]. 207 The payload of the audio level header extension element can be 208 encoded using the one or the two-byte header defined in [RFC5285]. 209 Figure 2 and Figure 3 show sample audio level encodings with each of 210 them. 212 0 1 2 3 213 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 214 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 215 | ID | len=2 |0| level 1 |0| level 2 |0| level 3 | 216 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 218 Sample audio level encoding using the one-byte header format 220 Figure 2 222 0 1 2 3 223 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 224 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 225 | ID | len=3 |0| level 1 |0| level 2 | 226 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 227 |0| level 3 | 0 (pad) | ... 228 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 230 Sample audio level encoding using the two-byte header format 232 Figure 3 234 In the case of the one-byte header format, the 4-bit len field is the 235 number minus one of data bytes (i.e. audio level values) transported 236 in this header extension element following the one-byte header. 237 Therefore, the value zero in this field indicates that one byte of 238 data follows. In the case of the two-byte header format the 8-bit 239 len field contains the exact number of audio levels carried in the 240 extension. RFC 3550 [RFC3550] only allows RTP packets to carry a 241 maximum of 15 CSRC IDs. Given that audio levels directly refer to 242 CSRC IDs, implementations MUST NOT include more than 15 audio level 243 values. The maximum value allowed in the len field is therefore 14 244 for one-byte header format adn 15 for two-byte header format. 246 Audio levels in this document are defined in the same manner as is 247 audio noise level in the RTP Payload Comfort Noise specification 248 [RFC3389]. In the comfort noice specification, the overall magnitude 249 of the noise level in comfort noise is encoded into the first byte of 250 the payload, with spectral information about the noise in subsequent 251 bytes. This specification's audio level parameter is defined so as 252 to be identical to the comfort noise payload's noise-level byte. 254 The magnitude of the audio level itself is packed into the seven 255 least significant bits of the single byte of the header extension, 256 shown in Figure 2 and Figure 3. The least significant bit of the 257 audio level magnitude is packed into the least significant bit of the 258 byte. The most significant bit of the byte is unused and always set 259 to 0. 261 The audio level is expressed in -dBov, with values from 0 to 127 262 representing 0 to -127 dBov. dBov is the level, in decibels, relative 263 to the overload point of the system, i.e. the maximum-amplitude 264 signal that can be handled by the system without clipping. (Note: 265 Representation relative to the overload point of a system is 266 particularly useful for digital implementations, since one does not 267 need to know the relative calibration of the analog circuitry.) For 268 example, in the case of u-law (audio/pcmu) audio [ITU.G.711], the 0 269 dBov reference would be a square wave with values +/- 8031. (This 270 translates to 6.18 dBm0, relative to u-law's dBm0 definition in Table 271 6 of G.711.) 273 The audio level for digital silence, for example for a muted audio 274 source, MUST be represented as 127 (-127 dBov), regardless of the 275 dynamic range of the encoded audio format. 277 The audio level header extension only carries the level of the audio 278 in the RTP payload of the packet it is associated with, with no long- 279 term averaging or smoothing applied. That level is measured as a 280 root mean square of all the samples in the measured range. 282 To simplify implementation of the encoding procedures described here, 283 this specification provides a sample Java implementation (Appendix A) 284 of an audio level calculator that helps obtain such values from raw 285 linear PCM audio samples. 287 5. Signaling Information 289 The URI for declaring the audio level header extension in an SDP 290 extmap attribute and mapping it to a local extension header 291 identifier is "urn:ietf:params:rtp-hdrext:csrc-audio-level". There 292 is no additional setup information needed for this extension (i.e. no 293 extensionattributes). 295 An example attribute line in the SDP, for a conference might be: 297 a=extmap:7 urn:ietf:params:rtp-hdrext:csrc-audio-level 299 The above mapping will most often be provided per media stream (in 300 the media-level section(s) of SDP, i.e., after an "m=" line) or 301 globally if there is more than one stream containing audio level 302 indicators in a session. 304 Presence of the above attribute in the SDP description of a media 305 stream indicates that RTP packets in that stream, which contain the 306 level extension defined in this document, will be carrying them with 307 an ID of 7. 309 Conferencing clients that support audio level indicators and have no 310 mixing capabilities would not be able to content for this audio level 311 extension and would hence have to always include the direction 312 parameter in the "extmap" attribute with a value of "recvonly". 313 Conference focus entities with mixing capabilities can omit the 314 direction or set it to "sendrecv" in SDP offers. Such entities would 315 need to set it to "sendonly" in SDP answers to offers with a 316 "recvonly" parameter and to "sendrecv" when answering other 317 "sendrecv" offers. 319 This specification only defines use of the audio level extensions in 320 audio streams. They MUST NOT be advertised with other media types 321 such as video or text for example. 323 The following Figure 4 and Figure 5 show two example offer/answer 324 exchanges between a conferencing client and a focus, and between two 325 conference focus entities. 327 v=0 328 o=alice 2890844526 2890844526 IN IP6 host.example.com 329 c=IN IP6 host.example.com 330 t=0 0 331 m=audio 49170 RTP/AVP 0 4 332 a=rtpmap:0 PCMU/8000 333 a=rtpmap:4 G723/8000 334 a=extmap:1/recvonly urn:ietf:params:rtp-hdrext:csrc-audio-level 336 v=0 337 i=A Seminar on the session description protocol 338 o=conf-focus 2890844730 2890844730 IN IP6 focus.example.net 339 c=IN IP6 focus.example.net 340 t=0 0 341 m=audio 52543 RTP/AVP 0 342 a=rtpmap:0 PCMU/8000 343 a=extmap:1/sendonly urn:ietf:params:rtp-hdrext:csrc-audio-level 345 A client-initiated example SDP offer/answer exchange negotiating an 346 audio stream with one-way flow of of audio level information. 348 Figure 4 350 v=0 351 i=Un seminaire sur le protocole de description des sessions 352 o=fr-focus 2890844730 2890844730 IN IP6 focus.fr.example.net 353 c=IN IP6 focus.fr.example.net 354 t=0 0 355 m=audio 49170 RTP/AVP 0 356 a=rtpmap:0 PCMU/8000 357 a=extmap:1/sendrecv urn:ietf:params:rtp-hdrext:csrc-audio-level 359 v=0 360 i=A Seminar on the session description protocol 361 o=us-focus 2890844526 2890844526 IN IP6 focus.us.example.net 362 c=IN IP6 focus.us.example.net 363 t=0 0 364 m=audio 52543 RTP/AVP 0 365 a=rtpmap:0 PCMU/8000 366 a=extmap:1/sendrecv urn:ietf:params:rtp-hdrext:csrc-audio-level 368 An example SDP offer/answer exchange between two conference focus 369 entities with mixing capabilities negotiating an audio stream with 370 bidirectional flow of audio level information. 372 Figure 5 374 6. Security Considerations 376 1. This document defines a means of attributing audio level to a 377 particular participant in a conference. An attacker may try to 378 modify the content of RTP packets in a way that would make audio 379 activity from one participant appear as coming from another. 380 2. Furthermore, the fact that audio level values would not be 381 protected even in an SRTP session might be of concern in some 382 cases where the activity of a particular participant in a 383 conference is confidential. Also, as discussed in 384 [I-D.perkins-avt-srtp-vbr-audio], an attacker might be able to 385 infer information about the conversation, possibly with phoneme- 386 level resolution. 387 3. Both of the above are concerns that stem from the design of the 388 RTP protocol itself and they would probably also apply when using 389 CSRC identifiers the way they were specified in RFC 3550 390 [RFC3550]. It is therefore important that according to the needs 391 of a particular scenario, implementors and deployers consider use 392 of header extension encryption 393 [I-D.lennox-avtcore-srtp-encrypted-header-ext] or a lower level 394 security and authentication mechanism. 396 7. IANA Considerations 398 This document defines a new extension URI that, if approved, would 399 need to be added to the RTP Compact Header Extensions sub-registry of 400 the Real-Time Transport Protocol (RTP) Parameters registry, according 401 to the following data: 403 Extension URI: urn:ietf:params:rtp-hdrext:csrc-audio-level 404 Description: Mixer-to-client audio level indicators 405 Contact: emcho@jitsi.org 406 Reference: RFC XXXX 408 Note to the RFC-Editor: please replace "RFC XXXX" by the number of 409 this RFC. 411 8. Acknowledgments 413 Lyubomir Marinov contributed level measurement and rendering code. 415 Keith Drage, Roni Even, Ingemar Johansson, Michael Ramalho, Magnus 416 Westerlund and several others provided helpful feedback over the 417 dispatch mailing list. 419 Jitsi's participation in this specification is funded by the NLnet 420 Foundation. 422 9. Changes From Earlier Versions 424 Note to the RFC-Editor: please remove this section prior to 425 publication as an RFC. 427 9.1. Changes From Draft -02 429 o Removed the no-data use case that allowed sending levels in RTP 430 packets. Choosing the right RTP payload type for this use case 431 would have incurred complexity without bringing any real value. 432 o Merged the "Header Format" and the "Audio level encoding" sections 433 into a single "Audio Levels" section. 434 o Changed encoding related text so that it would cover both the one- 435 byte and the two-byte header formats. 436 o Clarified use of root mean square for dBov calculation 437 o Added a reference to [I-D.perkins-avt-srtp-vbr-audio] to better 438 explain some "Security Considerations" . 439 o Other minor editorial changes. 441 9.2. Changes From Draft -01 443 o Removed code related the AudioLevelRenderer from "APPENDIX A. 444 Reference Implementation" as it was considered an implementation 445 matter by the working group. 446 o Modified the AudioLevelCalculator in "APPENDIX A. Reference 447 Implementation" to take overload as a parameter. 448 o Clarified non-use of audio levels in video streams 449 o Closed the P.56 open issue. It was agreed on IETF 80 that P.56 is 450 mostly about speech levels and the levels transported by the 451 extension defined here should also be able to serve as an 452 indication for noise. 453 o The Open Issues section has been removed as all issues that were 454 in there are now resolved or clarified. 455 o Editorial changes for consistency with 456 [I-D.ietf-avtext-client-to-mixer-audio-level]. 458 9.3. Changes From Draft -00 460 o Added code for sound pressure calculation and measurement in 461 "APPENDIX A. Reference Implementation". 462 o Changed affiliation for Emil Ivov. 463 o Removed "Appendix: Design choices". 465 10. References 466 10.1. Normative References 468 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 469 Requirement Levels", BCP 14, RFC 2119, March 1997. 471 [RFC3550] Schulzrinne, H., Casner, S., Frederick, R., and V. 472 Jacobson, "RTP: A Transport Protocol for Real-Time 473 Applications", STD 64, RFC 3550, July 2003. 475 [RFC5285] Singer, D. and H. Desineni, "A General Mechanism for RTP 476 Header Extensions", RFC 5285, July 2008. 478 10.2. Informative References 480 [I-D.ietf-avtext-client-to-mixer-audio-level] 481 Lennox, J., Ivov, E., and E. Marocco, "A Real-Time 482 Transport Protocol (RTP) Header Extension for Client-to- 483 Mixer Audio Level Indication", 484 draft-ietf-avtext-client-to-mixer-audio-level-02 (work in 485 progress), June 2011. 487 [I-D.lennox-avtcore-srtp-encrypted-header-ext] 488 Lennox, J., "Encryption of Header Extensions in the Secure 489 Real-Time Transport Protocol (SRTP)", 490 draft-lennox-avtcore-srtp-encrypted-header-ext-00 (work in 491 progress), March 2011. 493 [I-D.perkins-avt-srtp-vbr-audio] 494 Perkins, C. and J. Valin, "Guidelines for the use of 495 Variable Bit Rate Audio with Secure RTP", 496 draft-perkins-avt-srtp-vbr-audio-05 (work in progress), 497 December 2010. 499 [ITU.G.711] 500 International Telecommunications Union, "Pulse Code 501 Modulation (PCM) of Voice Frequencies", ITU- 502 T Recommendation G.711, November 1988. 504 [ITU.P56.1993] 505 International Telecommunications Union, "Objective 506 Measurement of Active Speech Level", ITU-T Recommendation 507 P.56, March 1988. 509 [RFC3261] Rosenberg, J., Schulzrinne, H., Camarillo, G., Johnston, 510 A., Peterson, J., Sparks, R., Handley, M., and E. 511 Schooler, "SIP: Session Initiation Protocol", RFC 3261, 512 June 2002. 514 [RFC3389] Zopf, R., "Real-time Transport Protocol (RTP) Payload for 515 Comfort Noise (CN)", RFC 3389, September 2002. 517 [RFC4353] Rosenberg, J., "A Framework for Conferencing with the 518 Session Initiation Protocol (SIP)", RFC 4353, 519 February 2006. 521 [RFC4575] Rosenberg, J., Schulzrinne, H., and O. Levin, "A Session 522 Initiation Protocol (SIP) Event Package for Conference 523 State", RFC 4575, August 2006. 525 Appendix A. Reference Implementation 527 This appendix contains Java code for a reference implementation of 528 the level calculation and rendering methods.The code is not normative 529 and by no means the only possible implementation. Its purpose is to 530 help implementors add audio level support to mixers and clients. 532 The Java code contains an AudioLevelCalculator class that calculates 533 the sound pressure level of a signal with specific samples. It can 534 be used in mixers to generate values suitable for the level extension 535 headers. 537 The implementation is provided in Java but does not rely on any of 538 the language specific and can be easily ported to another. 540 A.1. AudioLevelCalculator.java 542 /** 543 * Calculates the audio level of specific samples of a singal based on 544 * sound pressure level. 545 */ 546 public class AudioLevelCalculator 547 { 549 /** 550 * Calculates the sound pressure level of a signal with specific 551 * samples. 552 * 553 * @param samples the samples of the signal to calculate the sound 554 * pressure level of. The samples are specified as an int 555 * array starting at offset, extending length 556 * number of elements and each int element in the specified 557 * range representing a sample of the signal to calculate the sound 558 * pressure level of. Though a sample is provided in the form of an 559 * int value, the sample size in bits is determined by the 560 * caller via overload. 561 * 562 * @param offset the offset in samples at which the samples 563 * start 564 * 565 * @param length the length of the signal specified in 566 * samples starting at offset 567 * 568 * @param overload the overload (point) of signal. 569 * For example, overload may be {@link Byte#MAX_VALUE} 570 * for 8-bit signed samples or {@link Short#MAX_VALUE} for 571 * 16-bit signed samples. 572 * 573 * @return the sound pressure level of the specified signal 574 */ 575 public static int calculateSoundPressureLevel( 576 int[] samples, int offset, int length, 577 int overload) 578 { 579 /* 580 * Calcuate the root mean square of the signal i.e. the 581 * effective sound pressure. 582 */ 583 double rms = 0; 585 for (; offset < length; offset++) 586 { 587 double sample = samples[offset]; 589 sample /= overload; 590 rms += sample * sample; 591 } 592 rms = (length == 0) ? 0 : Math.sqrt(rms / length); 594 /* 595 * The sound pressure level is a logarithmic measure of the 596 * effectivesound pressure of a sound relative to a reference 597 * value and is measured in decibels. 598 */ 599 double db; 601 /* 602 * The minimum sound pressure level which matches the maximum 603 * of the sound meter. 604 */ 605 final double MIN_SOUND_PRESSURE_LEVEL = 0; 606 /* 607 * The maximum sound pressure level which matches the maximum 608 * of the sound meter. 609 */ 610 final double MAX_SOUND_PRESSURE_LEVEL 611 = 127 /* HUMAN TINNITUS (RINGING IN THE EARS) BEGINS */; 613 if (rms > 0) 614 { 615 /* 616 * The commonly used "zero" reference sound pressure in air 617 * is 20 uPa RMS, which is usually considered the threshold 618 * of human hearing. 619 */ 620 final double REF_SOUND_PRESSURE = 0.00002; 622 db = 20 * Math.log10(rms / REF_SOUND_PRESSURE); 624 /* 625 * Ensure that the calculated level is within the minimum 626 * and maximum sound pressure level. 627 */ 628 if (db < MIN_SOUND_PRESSURE_LEVEL) 629 db = MIN_SOUND_PRESSURE_LEVEL; 630 else if (db > MAX_SOUND_PRESSURE_LEVEL) 631 db = MAX_SOUND_PRESSURE_LEVEL; 632 } 633 else 634 { 635 db = MIN_SOUND_PRESSURE_LEVEL; 636 } 638 return (int) db; 639 } 640 } 642 AudioLevelCalculator.java 644 Authors' Addresses 646 Emil Ivov (editor) 647 Jitsi 648 Strasbourg 67000 649 France 651 Email: emcho@jitsi.org 652 Enrico Marocco (editor) 653 Telecom Italia 654 Via G. Reiss Romoli, 274 655 Turin 10148 656 Italy 658 Email: enrico.marocco@telecomitalia.it 660 Jonathan Lennox 661 Vidyo, Inc. 662 433 Hackensack Avenue 663 Seventh Floor 664 Hackensack, NJ 07601 665 US 667 Email: jonathan@vidyo.com