annotate base/AudioLevel.h @ 308:14e0f60435b8

* Make it possible to drop audio files, layer files, session files and images onto SV panes. Need to do a bit more work on where we expect the dropped file to go, particularly in the case of audio files -- at the moment they're always opened in new panes, but it may be better to by default replace whatever is in the target pane.
author Chris Cannam
date Wed, 10 Oct 2007 15:18:02 +0000
parents d397ea0a79f5
children cc27f35aa75c
rev   line source
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@0 38 static const float 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@0 48 static float multiplier_to_dB(float multiplier);
Chris@0 49 static float dB_to_multiplier(float dB);
Chris@0 50
Chris@0 51 static float fader_to_dB(int level, int maxLevel, FaderType type);
Chris@0 52 static int dB_to_fader(float dB, int maxFaderLevel, FaderType type);
Chris@0 53
Chris@0 54 static float fader_to_multiplier(int level, int maxLevel, FaderType type);
Chris@0 55 static int multiplier_to_fader(float 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@0 59 static int multiplier_to_preview(float multiplier, int levels);
Chris@0 60 static float preview_to_multiplier(int level, int levels);
Chris@0 61 };
Chris@0 62
Chris@0 63
Chris@0 64 #endif
Chris@0 65