diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index ad288050c..992d4a37c 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -255,6 +255,7 @@ class PreferenceController extends Zend_Controller_Action Application_Model_Preference::SetDefaultTransitionFade($values["transition_fade"]); Application_Model_Preference::SetAutoTransition($values["auto_transition"]); Application_Model_Preference::SetAutoSwitch($values["auto_switch"]); + Application_Model_Preference::SetEnableReplayGain($values["enableReplayGain"]); Application_Model_Preference::setReplayGainModifier($values["replayGainModifier"]); if (!Application_Model_Preference::GetMasterDjConnectionUrlOverride()) { diff --git a/airtime_mvc/application/forms/StreamSetting.php b/airtime_mvc/application/forms/StreamSetting.php index 080993816..11b474ff5 100644 --- a/airtime_mvc/application/forms/StreamSetting.php +++ b/airtime_mvc/application/forms/StreamSetting.php @@ -65,6 +65,12 @@ class Application_Form_StreamSetting extends Zend_Form ->setDecorators(array('ViewHelper')); $this->addElement($offAirMeta); + $enable_replay_gain = new Zend_Form_Element_Checkbox("enableReplayGain"); + $enable_replay_gain->setLabel(_("Enable Replay Gain")) + ->setValue(Application_Model_Preference::GetEnableReplayGain()) + ->setDecorators(array('ViewHelper')); + $this->addElement($enable_replay_gain); + $replay_gain = new Zend_Form_Element_Hidden("replayGainModifier"); $replay_gain->setLabel(_("Replay Gain Modifier")) ->setValue(Application_Model_Preference::getReplayGainModifier()) diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index b204609f4..000174c4c 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -1253,6 +1253,14 @@ class Application_Model_Preference return ($data != "") ? unserialize($data) : null; } + public static function SetEnableReplayGain($value) { + self::setValue("enable_replay_gain", $value, false); + } + + public static function GetEnableReplayGain() { + return self::getValue("enable_replay_gain", false); + } + public static function getReplayGainModifier(){ $rg_modifier = self::getValue("replay_gain_modifier"); diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index dd6535bd4..81a5db90c 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -679,8 +679,13 @@ SQL; $same_hour = $start_hour == $end_hour; $independent_event = !$same_hour; + $replay_gain = is_null($item["replay_gain"]) ? "0": $item["replay_gain"]; $replay_gain += Application_Model_Preference::getReplayGainModifier(); + + if ( !Application_Model_Preference::GetEnableReplayGain() ) { + $replay_gain = 0; + } $schedule_item = array( 'id' => $media_id, @@ -695,7 +700,7 @@ SQL; 'end' => $end, 'show_name' => $item["show_name"], 'replay_gain' => $replay_gain, - 'independent_event' => $independent_event, + 'independent_event' => $independent_event, ); self::appendScheduleItem($data, $start, $schedule_item); } @@ -839,8 +844,8 @@ SQL; /* Check if two events are less than or equal to 1 second apart */ public static function areEventsLinked($event1, $event2) { - $dt1 = DateTime::createFromFormat("Y-m-d-H-i-s", $event1['start']); - $dt2 = DateTime::createFromFormat("Y-m-d-H-i-s", $event2['start']); + $dt1 = DateTime::createFromFormat("Y-m-d-H-i-s", $event1['start']); + $dt2 = DateTime::createFromFormat("Y-m-d-H-i-s", $event2['start']); $seconds = $dt2->getTimestamp() - $dt1->getTimestamp(); return $seconds <= 1; @@ -860,7 +865,7 @@ SQL; * * There's a special case here is well. When the back-to-back streams are the same, we * can collapse the instructions 1,2,(3,4,1,2),3,4 to 1,2,3,4. We basically cut out the - * middle part. This function handles this. + * middle part. This function handles this. */ private static function foldData(&$data) { diff --git a/airtime_mvc/application/views/scripts/preference/stream-setting.phtml b/airtime_mvc/application/views/scripts/preference/stream-setting.phtml index 5fad625c9..07665c6ec 100644 --- a/airtime_mvc/application/views/scripts/preference/stream-setting.phtml +++ b/airtime_mvc/application/views/scripts/preference/stream-setting.phtml @@ -71,25 +71,33 @@
form->getElement('offAirMeta') ?>
+
+ +
+
+ form->getElement('enableReplayGain') ?> +
- - - form->getElement('replayGainModifier')->getValue() ?> - - dB -
-
- form->getElement('replayGainModifier') ?> - form->getElement('replayGainModifier')->hasErrors()) : ?> - - -
-
+ + + form->getElement('replayGainModifier')->getValue() ?> + + dB + +
+ form->getElement('replayGainModifier') ?> + form->getElement('replayGainModifier')->hasErrors()) : ?> + + +
+
form->getSubform('live_stream_subform'); ?> diff --git a/airtime_mvc/build/sql/defaultdata.sql b/airtime_mvc/build/sql/defaultdata.sql index a5d92eabd..775f548fb 100644 --- a/airtime_mvc/build/sql/defaultdata.sql +++ b/airtime_mvc/build/sql/defaultdata.sql @@ -1,6 +1,7 @@ INSERT INTO cc_subjs ("login", "type", "pass") VALUES ('admin', 'A', md5('admin')); -- added in 2.3 INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('off_air_meta', 'Airtime - offline', 'string'); +INSERT INTO cc_pref("keystr", "valstr") VALUES('enable_replay_gain', 1); -- end of added in 2.3 -- added in 2.1