Chris@49
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@52
|
4 Sonic Visualiser
|
Chris@52
|
5 An audio file viewer and annotation editor.
|
Chris@52
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@0
|
7
|
Chris@52
|
8 This program is free software; you can redistribute it and/or
|
Chris@52
|
9 modify it under the terms of the GNU General Public License as
|
Chris@52
|
10 published by the Free Software Foundation; either version 2 of the
|
Chris@52
|
11 License, or (at your option) any later version. See the file
|
Chris@52
|
12 COPYING included with this distribution for more information.
|
Chris@0
|
13 */
|
Chris@0
|
14
|
Chris@0
|
15 /*
|
Chris@0
|
16 This is a modified version of a source file from the
|
Chris@0
|
17 Rosegarden MIDI and audio sequencer and notation editor.
|
Chris@17
|
18 This file copyright 2000-2006 Chris Cannam.
|
Chris@0
|
19 */
|
Chris@0
|
20
|
Chris@0
|
21 #ifndef _AUDIO_LEVEL_H_
|
Chris@0
|
22 #define _AUDIO_LEVEL_H_
|
Chris@0
|
23
|
Chris@0
|
24 /**
|
Chris@0
|
25 * AudioLevel converts audio sample levels between various scales:
|
Chris@0
|
26 *
|
Chris@0
|
27 * - dB values (-inf -> 0dB)
|
Chris@0
|
28 * - floating-point values (-1.0 -> 1.0) such as used for a
|
Chris@0
|
29 * multiplier for gain or in floating-point WAV files
|
Chris@0
|
30 * - integer values intended to correspond to pixels on a fader
|
Chris@0
|
31 * or vu level scale.
|
Chris@0
|
32 */
|
Chris@0
|
33
|
Chris@0
|
34 class AudioLevel
|
Chris@0
|
35 {
|
Chris@0
|
36 public:
|
Chris@0
|
37
|
Chris@1038
|
38 static const double DB_FLOOR;
|
Chris@0
|
39
|
Chris@0
|
40 enum FaderType {
|
Chris@0
|
41 ShortFader = 0, // -40 -> +6 dB
|
Chris@0
|
42 LongFader = 1, // -70 -> +10 dB
|
Chris@0
|
43 IEC268Meter = 2, // -70 -> 0 dB
|
Chris@0
|
44 IEC268LongMeter = 3, // -70 -> +10 dB (0dB aligns with LongFader)
|
Chris@0
|
45 PreviewLevel = 4
|
Chris@0
|
46 };
|
Chris@0
|
47
|
Chris@1038
|
48 static double multiplier_to_dB(double multiplier);
|
Chris@1038
|
49 static double dB_to_multiplier(double dB);
|
Chris@0
|
50
|
Chris@1038
|
51 static double fader_to_dB(int level, int maxLevel, FaderType type);
|
Chris@1038
|
52 static int dB_to_fader(double dB, int maxFaderLevel, FaderType type);
|
Chris@0
|
53
|
Chris@1038
|
54 static double fader_to_multiplier(int level, int maxLevel, FaderType type);
|
Chris@1038
|
55 static int multiplier_to_fader(double multiplier, int maxFaderLevel,
|
Chris@0
|
56 FaderType type);
|
Chris@0
|
57
|
Chris@0
|
58 // fast if "levels" doesn't change often -- for audio segment previews
|
Chris@1038
|
59 static int multiplier_to_preview(double multiplier, int levels);
|
Chris@1038
|
60 static double preview_to_multiplier(int level, int levels);
|
Chris@0
|
61 };
|
Chris@0
|
62
|
Chris@0
|
63
|
Chris@0
|
64 #endif
|
Chris@0
|
65
|