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