CC-4821: Add option to disable ReplayGain

- done
This commit is contained in:
James 2013-01-10 13:49:41 -05:00
parent 4bf9ab60d9
commit 048ee05030
6 changed files with 51 additions and 22 deletions

View file

@ -255,6 +255,7 @@ class PreferenceController extends Zend_Controller_Action
Application_Model_Preference::SetDefaultTransitionFade($values["transition_fade"]); Application_Model_Preference::SetDefaultTransitionFade($values["transition_fade"]);
Application_Model_Preference::SetAutoTransition($values["auto_transition"]); Application_Model_Preference::SetAutoTransition($values["auto_transition"]);
Application_Model_Preference::SetAutoSwitch($values["auto_switch"]); Application_Model_Preference::SetAutoSwitch($values["auto_switch"]);
Application_Model_Preference::SetEnableReplayGain($values["enableReplayGain"]);
Application_Model_Preference::setReplayGainModifier($values["replayGainModifier"]); Application_Model_Preference::setReplayGainModifier($values["replayGainModifier"]);
if (!Application_Model_Preference::GetMasterDjConnectionUrlOverride()) { if (!Application_Model_Preference::GetMasterDjConnectionUrlOverride()) {

View file

@ -65,6 +65,12 @@ class Application_Form_StreamSetting extends Zend_Form
->setDecorators(array('ViewHelper')); ->setDecorators(array('ViewHelper'));
$this->addElement($offAirMeta); $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 = new Zend_Form_Element_Hidden("replayGainModifier");
$replay_gain->setLabel(_("Replay Gain Modifier")) $replay_gain->setLabel(_("Replay Gain Modifier"))
->setValue(Application_Model_Preference::getReplayGainModifier()) ->setValue(Application_Model_Preference::getReplayGainModifier())

View file

@ -1253,6 +1253,14 @@ class Application_Model_Preference
return ($data != "") ? unserialize($data) : null; 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(){ public static function getReplayGainModifier(){
$rg_modifier = self::getValue("replay_gain_modifier"); $rg_modifier = self::getValue("replay_gain_modifier");

View file

@ -679,8 +679,13 @@ SQL;
$same_hour = $start_hour == $end_hour; $same_hour = $start_hour == $end_hour;
$independent_event = !$same_hour; $independent_event = !$same_hour;
$replay_gain = is_null($item["replay_gain"]) ? "0": $item["replay_gain"]; $replay_gain = is_null($item["replay_gain"]) ? "0": $item["replay_gain"];
$replay_gain += Application_Model_Preference::getReplayGainModifier(); $replay_gain += Application_Model_Preference::getReplayGainModifier();
if ( !Application_Model_Preference::GetEnableReplayGain() ) {
$replay_gain = 0;
}
$schedule_item = array( $schedule_item = array(
'id' => $media_id, 'id' => $media_id,
@ -695,7 +700,7 @@ SQL;
'end' => $end, 'end' => $end,
'show_name' => $item["show_name"], 'show_name' => $item["show_name"],
'replay_gain' => $replay_gain, 'replay_gain' => $replay_gain,
'independent_event' => $independent_event, 'independent_event' => $independent_event,
); );
self::appendScheduleItem($data, $start, $schedule_item); self::appendScheduleItem($data, $start, $schedule_item);
} }
@ -839,8 +844,8 @@ SQL;
/* Check if two events are less than or equal to 1 second apart /* Check if two events are less than or equal to 1 second apart
*/ */
public static function areEventsLinked($event1, $event2) { public static function areEventsLinked($event1, $event2) {
$dt1 = DateTime::createFromFormat("Y-m-d-H-i-s", $event1['start']); $dt1 = DateTime::createFromFormat("Y-m-d-H-i-s", $event1['start']);
$dt2 = DateTime::createFromFormat("Y-m-d-H-i-s", $event2['start']); $dt2 = DateTime::createFromFormat("Y-m-d-H-i-s", $event2['start']);
$seconds = $dt2->getTimestamp() - $dt1->getTimestamp(); $seconds = $dt2->getTimestamp() - $dt1->getTimestamp();
return $seconds <= 1; 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 * 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 * 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) private static function foldData(&$data)
{ {

View file

@ -71,25 +71,33 @@
<dd id="offAirMeta-element"> <dd id="offAirMeta-element">
<?php echo $this->form->getElement('offAirMeta') ?> <?php echo $this->form->getElement('offAirMeta') ?>
</dd> </dd>
<dt id="enableReplayGain-label">
<label>
<?php echo $this->form->getElement('enableReplayGain')->getLabel() ?> :
</label>
</dt>
<dd id="enableReplayGain-element">
<?php echo $this->form->getElement('enableReplayGain') ?>
</dd>
<dt id="replayGainModifier-label" class="block-display"> <dt id="replayGainModifier-label" class="block-display">
<label><?php echo $this->form->getElement('replayGainModifier')->getLabel() ?>: <label><?php echo $this->form->getElement('replayGainModifier')->getLabel() ?>:
</label> </label>
<span id="rg_modifier_value" style="border: 0; color: #f6931f; font-weight: bold;"> <span id="rg_modifier_value" style="border: 0; color: #f6931f; font-weight: bold;">
<?php echo $this->form->getElement('replayGainModifier')->getValue() ?> <?php echo $this->form->getElement('replayGainModifier')->getValue() ?>
</span> </span>
dB dB
</dt> </dt>
<dd id="replayGainModifier-element" class="block-display"> <dd id="replayGainModifier-element" class="block-display">
<?php echo $this->form->getElement('replayGainModifier') ?> <?php echo $this->form->getElement('replayGainModifier') ?>
<?php if($this->form->getElement('replayGainModifier')->hasErrors()) : ?> <?php if($this->form->getElement('replayGainModifier')->hasErrors()) : ?>
<ul class='errors'> <ul class='errors'>
<?php foreach($this->form->getElement('replayGainModifier')->getMessages() as $error): ?> <?php foreach($this->form->getElement('replayGainModifier')->getMessages() as $error): ?>
<li><?php echo $error; ?></li> <li><?php echo $error; ?></li>
<?php endforeach; ?> <?php endforeach; ?>
</ul> </ul>
<?php endif; ?> <?php endif; ?>
<div id="slider-range-max" style="width: 99%"></div> <div id="slider-range-max" style="width: 99%"></div>
</dd> </dd>
</dl> </dl>
</fieldset> </fieldset>
<?php echo $this->form->getSubform('live_stream_subform'); ?> <?php echo $this->form->getSubform('live_stream_subform'); ?>

View file

@ -1,6 +1,7 @@
INSERT INTO cc_subjs ("login", "type", "pass") VALUES ('admin', 'A', md5('admin')); INSERT INTO cc_subjs ("login", "type", "pass") VALUES ('admin', 'A', md5('admin'));
-- added in 2.3 -- added in 2.3
INSERT INTO cc_stream_setting ("keyname", "value", "type") VALUES ('off_air_meta', 'Airtime - offline', 'string'); 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 -- end of added in 2.3
-- added in 2.1 -- added in 2.1