From f8d2a7905c56324578bf888bdf55b5a626c5b3aa Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Mon, 1 Dec 2014 17:50:54 -0500 Subject: [PATCH] 2014-12-01 Fred Gleason * Fixed a bug in 'utils/rdimport/rdimport.cpp' that failed to apply automatic segues correctly when the audio store was not locally accessible. * Fixed a bug in 'utils/rdimport/rdimport.cpp' that caused the value of the '--segue-level' options to be wrong by a factor of 100. * Refactored the 'RDCut::autoSegue()' method to fetch trim data via 'RDTrimAudio'. * Added language in the rdimport(1) man page to resolve ambiguity regarding how the --segue-level location is dteremined when normalization is specified. --- ChangeLog | 12 ++++++++++++ docs/man/rdimport.1 | 5 +++-- lib/rdcut.cpp | 30 +++++++++++++++++++----------- lib/rdcut.h | 3 ++- utils/rdimport/rdimport.cpp | 11 +++++------ 5 files changed, 41 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 36b2f76c..309ea2ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14676,3 +14676,15 @@ 2014-12-01 Fred Gleason * Adjust value of 'STAGE1BUFSIZE' to '16384' in 'lib/rdaudioconvert.cpp'. +2014-12-01 Fred Gleason + * Fixed a bug in 'utils/rdimport/rdimport.cpp' that failed to + apply automatic segues correctly when the audio store was not + locally accessible. + * Fixed a bug in 'utils/rdimport/rdimport.cpp' that caused the + value of the '--segue-level' options to be wrong by a factor of + 100. + * Refactored the 'RDCut::autoSegue()' method to fetch trim data + via 'RDTrimAudio'. + * Added language in the rdimport(1) man page to resolve ambiguity + regarding how the --segue-level location is dteremined when + normalization is specified. diff --git a/docs/man/rdimport.1 b/docs/man/rdimport.1 index 7bfc4f12..f89790bf 100644 --- a/docs/man/rdimport.1 +++ b/docs/man/rdimport.1 @@ -176,8 +176,9 @@ Length of the added segue in msecs. See \fB--segue-level\fP below. .TP .B --segue-level=<\fIlevel\fP> -Specify the threshold level to use for setting the segue markers, in dBFS. -Default action is not to create segue markers. +Specify the threshold level to use for setting the segue markers, in dBFS, +as measured after any specified normalization has been applied. Default +action is not to create segue markers. .TP .B --set-datetimes=<\fIstart-datetime\fP>,<\fIend-datetime\fP> diff --git a/lib/rdcut.cpp b/lib/rdcut.cpp index d9c29dea..f00a86cc 100644 --- a/lib/rdcut.cpp +++ b/lib/rdcut.cpp @@ -40,6 +40,7 @@ #include #include #include +#include // // Global Classes @@ -1295,11 +1296,12 @@ void RDCut::autoTrim(RDCut::AudioEnd end,int level) } -void RDCut::autoSegue(int level,int length) +void RDCut::autoSegue(int level,int length,RDStation *station,RDUser *user, + RDConfig *config) { #ifndef WIN32 int point; - int start_point; + // int start_point; if(!exists()) { return; @@ -1311,17 +1313,23 @@ void RDCut::autoSegue(int level,int length) return; } if(level<0) { - if((point=wave->endTrim(+REFERENCE_LEVEL-level))>-1) { - start_point=(int)(1000.0*(double)point/(double)wave->getSamplesPerSec()); - setSegueStartPoint(start_point); - if(length>0 && (start_point+length)setCartNumber(cart_number); + trim->setCutNumber(cut_number); + trim->setTrimLevel(level); + if(trim->runTrim(user->name(),user->password())==RDTrimAudio::ErrorOk) { + if((point=trim->endPoint())>=0) { + setSegueStartPoint(trim->endPoint()); + if(length>0 && (trim->endPoint()+length)endPoint()+length); + } + else { + setSegueEndPoint(endPoint()); + } } } + delete trim; + } else { if(length>0) { if((endPoint()-length)>startPoint()){ diff --git a/lib/rdcut.h b/lib/rdcut.h index 95eb23dc..54ce3e1b 100644 --- a/lib/rdcut.h +++ b/lib/rdcut.h @@ -131,7 +131,8 @@ class RDCut bool checkInRecording(const QString &stationname,RDSettings *settings, unsigned msecs) const; void autoTrim(RDCut::AudioEnd end,int level); - void autoSegue(int level,int length); + void autoSegue(int level,int length,RDStation *station,RDUser *user, + RDConfig *config); void reset() const; void connect(QObject *receiver,const char *member) const; void disconnect(QObject *receiver,const char *member) const; diff --git a/utils/rdimport/rdimport.cpp b/utils/rdimport/rdimport.cpp index 02e0d17d..3dac0e57 100644 --- a/utils/rdimport/rdimport.cpp +++ b/utils/rdimport/rdimport.cpp @@ -2,9 +2,7 @@ // // A Batch Importer for Rivendell. // -// (C) Copyright 2002-2008 Fred Gleason -// -// $Id: rdimport.cpp,v 1.34.4.9.2.3 2014/07/15 00:45:16 cvs Exp $ +// (C) Copyright 2002-2014 Fred Gleason // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as @@ -532,8 +530,8 @@ MainObject::MainObject(QObject *parent,const char *name) if(import_cmd->key(i)=="--segue-level") { n=import_cmd->value(i).toInt(&ok); if(ok&&(n<=0)) { - import_segue_level=100*n; - } + import_segue_level=n; + } else { fprintf(stderr,"rdimport: invalid segue level\n"); delete import_cmd; @@ -1172,7 +1170,8 @@ MainObject::Result MainObject::ImportFile(const QString &filename, } cut->setMetadata(wavedata); } - cut->autoSegue(import_segue_level,import_segue_length); + cut->autoSegue(import_segue_level,import_segue_length,import_station, + import_user,import_config); if((wavedata->title().length()==0)|| ((wavedata->title().length()>0)&&(wavedata->title()[0] == '\0'))) { QString title=effective_group->generateTitle(filename);