From 583695f98c028377dee19a17e2ab389b6233f0b2 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Sun, 15 Jul 2012 22:13:04 -0400 Subject: [PATCH] CC-430: Audio normalization (Replaygain Support) -values are now written through to database --- airtime_mvc/application/controllers/ApiController.php | 8 +++++++- airtime_mvc/application/models/Schedule.php | 2 +- airtime_mvc/application/models/StoredFile.php | 3 ++- .../views/scripts/api/get-files-without-replay-gain.phtml | 3 --- airtime_mvc/build/schema.xml | 2 +- install_minimal/upgrades/airtime-2.2.0/TODO | 2 +- .../media-monitor2/media/update/replaygainupdater.py | 5 +---- 7 files changed, 13 insertions(+), 12 deletions(-) delete mode 100644 airtime_mvc/application/views/scripts/api/get-files-without-replay-gain.phtml diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 1670c345f..6ef4f963a 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -949,10 +949,14 @@ class ApiController extends Zend_Controller_Action { // disable the view and the layout $this->view->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(true); + $dir_id = $this->_getParam('dir_id'); //connect to db and get get sql - $this->view->rows = Application_Model_StoredFile::listAllFiles2($dir_id, 100); + $rows = Application_Model_StoredFile::listAllFiles2($dir_id, 100); + + echo json_encode($rows); } public function updateReplayGainValueAction() @@ -961,6 +965,8 @@ class ApiController extends Zend_Controller_Action // disable layout $this->view->layout()->disableLayout(); + $this->_helper->viewRenderer->setNoRender(true); + $request = $this->getRequest(); $data = json_decode($request->getParam('data')); diff --git a/airtime_mvc/application/models/Schedule.php b/airtime_mvc/application/models/Schedule.php index 51985d9e3..91676bd09 100644 --- a/airtime_mvc/application/models/Schedule.php +++ b/airtime_mvc/application/models/Schedule.php @@ -615,7 +615,7 @@ class Application_Model_Schedule 'start' => $start, 'end' => Application_Model_Schedule::AirtimeTimeToPypoTime($item["end"]), 'show_name' => $showName, - 'replay_gain' => $item["replay_gain"] + 'replay_gain' => is_null($item["replay_gain"]) ? "0": $item["replay_gain"] ); } diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 0e39759e7..abc6bb9b6 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -974,7 +974,8 @@ Logging::log("getting media! - 2"); $sql = "SELECT id, filepath as fp" ." FROM CC_FILES" ." WHERE directory = $dir_id" - ." AND file_exists = 'TRUE'"; + ." AND file_exists = 'TRUE'" + ." AND replay_gain is NULL"; if (!is_null($limit) && is_int($limit)) { $sql .= " LIMIT $limit"; } diff --git a/airtime_mvc/application/views/scripts/api/get-files-without-replay-gain.phtml b/airtime_mvc/application/views/scripts/api/get-files-without-replay-gain.phtml deleted file mode 100644 index 7681cf29c..000000000 --- a/airtime_mvc/application/views/scripts/api/get-files-without-replay-gain.phtml +++ /dev/null @@ -1,3 +0,0 @@ -rows); diff --git a/airtime_mvc/build/schema.xml b/airtime_mvc/build/schema.xml index 1850a6aff..dbc13cf27 100644 --- a/airtime_mvc/build/schema.xml +++ b/airtime_mvc/build/schema.xml @@ -98,7 +98,7 @@ - + diff --git a/install_minimal/upgrades/airtime-2.2.0/TODO b/install_minimal/upgrades/airtime-2.2.0/TODO index 7f40b6bb1..037b6cd5f 100644 --- a/install_minimal/upgrades/airtime-2.2.0/TODO +++ b/install_minimal/upgrades/airtime-2.2.0/TODO @@ -6,4 +6,4 @@ flac vorbis-tools -calculate Replay Gain dB on upgrade. +calculate Replay Gain dB on upgrade: the default value should be NULL. diff --git a/python_apps/media-monitor2/media/update/replaygainupdater.py b/python_apps/media-monitor2/media/update/replaygainupdater.py index b009e2d99..de8a63e20 100644 --- a/python_apps/media-monitor2/media/update/replaygainupdater.py +++ b/python_apps/media-monitor2/media/update/replaygainupdater.py @@ -5,9 +5,6 @@ import os import logging import json -import sys -sys.path.append('/home/martin/workspace/airtime/python_apps/media-monitor2/') - from api_clients import api_client from media.update import replaygain @@ -16,7 +13,7 @@ class ReplayGainUpdater(Thread): """ The purpose of the class is to query the server for a list of files which do not have a ReplayGain value calculated. This class will iterate over the list calculate the values, update the server and - repeat the process until the the server reports there are no files left. + repeat the process until the server reports there are no files left. This class will see heavy activity right after a 2.1->2.2 upgrade since 2.2 introduces ReplayGain normalization. A fresh install of Airtime 2.2 will see this class not used at all since a file