- Main Page
- Namespaces
- Files

- File List
- File Members

# C:/Musimathics_local/Musimat/MusimatTutorial/B0204.cpp File Reference

`#include "MusimatTutorial.h"`

Go to the source code of this file.

## Functions
| MusimatTutorialSection (B0204)
Real | dB (Real y)
Static Void | para1 ()

## Function Documentation

Real dB | ( | Real | y | ) |

Definition at line 39 of file B0204.cpp.

Referenced by para1().

    00039                {
    00040         Return(Pow(10.0, y/20.0));
    00041 }

MusimatTutorialSection | ( | B0204 |  | ) |

Definition at line 2 of file B0204.cpp.

References para1().

    00002                               {
    00003 Print("*** B.2.4 Loudness ***");
    00004 /*****************************************************************************
    00005
    00006 B.2.4 Loudness
    00007
    00008 Loudness is expressed in common music notation using performance indications such as fortis-
    00009 simo or piano (see section 2.7). But the performed intensity depends upon the acoustical power of
    00010 the instrument and the interpretation of the performer. A better approach for the purpose here
    00011 would be to define loudness in objective terms using decibels (see section 5.5.1).
    00012
    00013 Since microphones and loudspeakers measure and reproduce pressure waves, it is common to
    00014 use dB SPL in audio work (see equation 5.32). It is also conventional in audio to take the loudest
    00015 value that can be reproduced without distortion as a reference intensity of 0 dB (see section 4.24.2).
    00016 Since measured intensities will be less intense than the reference, then by the definition of the deci-
    00017 bel they will be expressed as negative decibel levels. We can write, for example, –6 dB to indicate
    00018 an amplitude that is (very close to) one half of the amplitude of the 0 dB reference.
    00019
    00020 Restating (5.32), the equation for dB SPL, as
    00021
    00022  y dB = 20 Log10(A'/A)
    00023
    00024 and simplifying by letting x=A'/A, we have y dB = 20 Log10(x). Solving for x, we have
    00025
    00026 x = 10^(y/20).  (B.1)
    00027
    00028 For example, setting y = -6 dB, we have x = 10^(-6/20) = 0.501. The value of x is the coefficient by
    00029 which a signal must be multiplied to lower its amplitude by 6 dB. For another example, setting
    00030 y = 0 dB, we have x = 10^(0/20) = 1. So multplying by 0 dB does not affect amplitude. Setting
    00031 y = -120 dB, we have x = 10^(-120/20) = 0.000001, so multiplying a signal by –120 dB renders it vir-
    00032 tually inaudible. Finally, if we wish to amplify a soft sound, scaling it by +6 dB makes it twice as
    00033 loud. Thus, scaling sounds with decibel coefficients allows us to achieve arbitrary loudness levels
    00034 for waveforms. So we define
    00035 *****************************************************************************/
    00036         para1();  // Step into this function to continue the tutorial
    00037 }

Static Void para1 | ( |  | ) |

Definition at line 43 of file B0204.cpp.

References dB().

    00043                     {
    00044 /*****************************************************************************
    00045 For example, Print(dB(–6)) prints 0.501187, Print(dB(0)) prints 1.0, and
    00046 Print(dB(–120)) prints 0.000001.
    00047
    00048 Suppose we have the following audio samples for a sound:
    00049 *****************************************************************************/
    00050
    00051 RealList mySound(0, 0.16, 0.192, -0.37, -0.45, -0.245, -0.43, 0.09);
    00052
    00053 /*****************************************************************************
    00054 We wish to halve the sound’s amplitude. Then
    00055 *****************************************************************************/
    00056
    00057 RealList scaledSound = mySound * dB(-6);
    00058 Print(scaledSound);
    00059
    00060 /*****************************************************************************
    00061 prints {0.02, 0.08, 0.10, -0.19, -0.23, -0.12, -0.22, 0.05, . . .}.
    00062
    00063 See volume 2, chapter 1, for more about sampled signals.
    00064
    00065 Musimat provides built-in definitions for standard music dynamics levels based on figure 4.7.
    00066 *****************************************************************************/
    00067
    00068 Real ffff = dB(0), fff = dB(-10),  ff = dB(-18),  f = dB(-24),
    00069   mf = dB(-32),  mp = dB(-40),  p = dB(-48),  pp = dB(-56),
    00070   ppp = dB(-64);
    00071
    00072 /*****************************************************************************
    00073 Thus ffff does not change the amplitude of the signal, but all others attenuate it to varying
    00074 degrees.
    00075
    00076 *****************************************************************************/
    00077 }}