svcore  1.9
AudioLevel.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     
00008     This program is free software; you can redistribute it and/or
00009     modify it under the terms of the GNU General Public License as
00010     published by the Free Software Foundation; either version 2 of the
00011     License, or (at your option) any later version.  See the file
00012     COPYING included with this distribution for more information.
00013 */
00014 
00015 /*
00016    This is a modified version of a source file from the 
00017    Rosegarden MIDI and audio sequencer and notation editor.
00018    This file copyright 2000-2006 Chris Cannam.
00019 */
00020 
00021 #ifndef _AUDIO_LEVEL_H_
00022 #define _AUDIO_LEVEL_H_
00023 
00034 class AudioLevel
00035 {
00036 public:
00037 
00038     static const float DB_FLOOR;
00039 
00040     enum FaderType {
00041              ShortFader = 0, // -40 -> +6  dB
00042               LongFader = 1, // -70 -> +10 dB
00043             IEC268Meter = 2, // -70 ->  0  dB
00044         IEC268LongMeter = 3, // -70 -> +10 dB (0dB aligns with LongFader)
00045            PreviewLevel = 4
00046     };
00047 
00048     static float multiplier_to_dB(float multiplier);
00049     static float dB_to_multiplier(float dB);
00050 
00051     static float fader_to_dB(int level, int maxLevel, FaderType type);
00052     static int   dB_to_fader(float dB, int maxFaderLevel, FaderType type);
00053 
00054     static float fader_to_multiplier(int level, int maxLevel, FaderType type);
00055     static int   multiplier_to_fader(float multiplier, int maxFaderLevel,
00056                                      FaderType type);
00057 
00058     // fast if "levels" doesn't change often -- for audio segment previews
00059     static int   multiplier_to_preview(float multiplier, int levels);
00060     static float preview_to_multiplier(int level, int levels);
00061 };
00062 
00063 
00064 #endif
00065