X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fcinema_sound_processor.cc;h=1a3ba5a0f0af61fcd9b9d412a4b6111e4ffc82ca;hp=6a79051145e81e33ff998cacf1f4f7e21cb6c7d7;hb=386e25f3b9d3fa59cbdeed458d9b3e0d21e338b8;hpb=1c13441a19aa387ddd8ac0c972207ccbbe3114d8 diff --git a/src/lib/cinema_sound_processor.cc b/src/lib/cinema_sound_processor.cc index 6a7905114..1a3ba5a0f 100644 --- a/src/lib/cinema_sound_processor.cc +++ b/src/lib/cinema_sound_processor.cc @@ -1,19 +1,20 @@ /* Copyright (C) 2012-2014 Carl Hetherington - This program is free software; you can redistribute it and/or modify + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + DCP-o-matic is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with DCP-o-matic. If not, see . */ @@ -21,10 +22,13 @@ * @brief CinemaSoundProcessor class. */ -#include -#include #include "cinema_sound_processor.h" #include "dolby_cp750.h" +#include "usl.h" +#include "datasat_ap2x.h" +#include "dcpomatic_assert.h" +#include +#include using namespace std; @@ -33,9 +37,12 @@ vector CinemaSoundProcessor::_cinema_sound_process /** @param i Our id. * @param n User-visible name. */ -CinemaSoundProcessor::CinemaSoundProcessor (string i, string n) +CinemaSoundProcessor::CinemaSoundProcessor (string i, string n, float knee, float below, float above) : _id (i) , _name (n) + , _knee (knee) + , _below (below) + , _above (above) { } @@ -54,6 +61,8 @@ void CinemaSoundProcessor::setup_cinema_sound_processors () { _cinema_sound_processors.push_back (new DolbyCP750); + _cinema_sound_processors.push_back (new USL); + _cinema_sound_processors.push_back (new DatasatAP2x); } /** @param id One of our ids. @@ -98,6 +107,36 @@ CinemaSoundProcessor::as_index (CinemaSoundProcessor const * s) CinemaSoundProcessor const * CinemaSoundProcessor::from_index (int i) { - assert (i <= int(_cinema_sound_processors.size ())); + DCPOMATIC_ASSERT (i <= int(_cinema_sound_processors.size ())); return _cinema_sound_processors[i]; } + +float +CinemaSoundProcessor::db_for_fader_change (float from, float to) const +{ + float db = 0; + + if (from < to) { + if (from <= _knee) { + float const t = min (to, _knee); + db += (t - from) * _below; + } + + if (to > 4) { + float const t = max (from, _knee); + db += (to - t) * _above; + } + } else { + if (from >= _knee) { + float const t = max (to, _knee); + db -= (from - t) * _above; + } + + if (to < _knee) { + float const t = min (from, _knee); + db -= (t - to) * _below; + } + } + + return db; +}