Chris@0
|
1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 A waveform viewer and audio annotation editor.
|
Chris@2
|
5 Chris Cannam, Queen Mary University of London, 2005-2006
|
Chris@0
|
6
|
Chris@0
|
7 This is experimental software. Not for distribution.
|
Chris@0
|
8 */
|
Chris@0
|
9
|
Chris@0
|
10 /*
|
Chris@0
|
11 This is a modified version of a source file from the
|
Chris@0
|
12 Rosegarden MIDI and audio sequencer and notation editor.
|
Chris@17
|
13 This file copyright 2000-2006 Chris Cannam.
|
Chris@0
|
14 */
|
Chris@0
|
15
|
Chris@0
|
16 #ifndef _AUDIO_LEVEL_H_
|
Chris@0
|
17 #define _AUDIO_LEVEL_H_
|
Chris@0
|
18
|
Chris@0
|
19 /**
|
Chris@0
|
20 * AudioLevel converts audio sample levels between various scales:
|
Chris@0
|
21 *
|
Chris@0
|
22 * - dB values (-inf -> 0dB)
|
Chris@0
|
23 * - floating-point values (-1.0 -> 1.0) such as used for a
|
Chris@0
|
24 * multiplier for gain or in floating-point WAV files
|
Chris@0
|
25 * - integer values intended to correspond to pixels on a fader
|
Chris@0
|
26 * or vu level scale.
|
Chris@0
|
27 */
|
Chris@0
|
28
|
Chris@0
|
29 class AudioLevel
|
Chris@0
|
30 {
|
Chris@0
|
31 public:
|
Chris@0
|
32
|
Chris@0
|
33 static const float DB_FLOOR;
|
Chris@0
|
34
|
Chris@0
|
35 enum FaderType {
|
Chris@0
|
36 ShortFader = 0, // -40 -> +6 dB
|
Chris@0
|
37 LongFader = 1, // -70 -> +10 dB
|
Chris@0
|
38 IEC268Meter = 2, // -70 -> 0 dB
|
Chris@0
|
39 IEC268LongMeter = 3, // -70 -> +10 dB (0dB aligns with LongFader)
|
Chris@0
|
40 PreviewLevel = 4
|
Chris@0
|
41 };
|
Chris@0
|
42
|
Chris@0
|
43 static float multiplier_to_dB(float multiplier);
|
Chris@0
|
44 static float dB_to_multiplier(float dB);
|
Chris@0
|
45
|
Chris@0
|
46 static float fader_to_dB(int level, int maxLevel, FaderType type);
|
Chris@0
|
47 static int dB_to_fader(float dB, int maxFaderLevel, FaderType type);
|
Chris@0
|
48
|
Chris@0
|
49 static float fader_to_multiplier(int level, int maxLevel, FaderType type);
|
Chris@0
|
50 static int multiplier_to_fader(float multiplier, int maxFaderLevel,
|
Chris@0
|
51 FaderType type);
|
Chris@0
|
52
|
Chris@0
|
53 // fast if "levels" doesn't change often -- for audio segment previews
|
Chris@0
|
54 static int multiplier_to_preview(float multiplier, int levels);
|
Chris@0
|
55 static float preview_to_multiplier(int level, int levels);
|
Chris@0
|
56 };
|
Chris@0
|
57
|
Chris@0
|
58
|
Chris@0
|
59 #endif
|
Chris@0
|
60
|