From: <jpi...@us...> - 2011-12-11 15:04:41
|
Revision: 9364 http://octave.svn.sourceforge.net/octave/?rev=9364&view=rev Author: jpicarbajal Date: 2011-12-11 15:04:33 +0000 (Sun, 11 Dec 2011) Log Message: ----------- audio: miscellaneous: moving clip.m from audio to miscellanous. Updating DESCRIPTION of both packages. Creating NEWS file for both packages Modified Paths: -------------- trunk/octave-forge/main/audio/DESCRIPTION trunk/octave-forge/main/miscellaneous/DESCRIPTION trunk/octave-forge/main/miscellaneous/INDEX Added Paths: ----------- trunk/octave-forge/main/audio/NEWS trunk/octave-forge/main/miscellaneous/NEWS trunk/octave-forge/main/miscellaneous/inst/clip.m Removed Paths: ------------- trunk/octave-forge/main/audio/inst/clip.m Modified: trunk/octave-forge/main/audio/DESCRIPTION =================================================================== --- trunk/octave-forge/main/audio/DESCRIPTION 2011-12-11 03:30:40 UTC (rev 9363) +++ trunk/octave-forge/main/audio/DESCRIPTION 2011-12-11 15:04:33 UTC (rev 9364) @@ -1,11 +1,11 @@ Name: Audio Version: 1.1.4 -Date: 2009-05-03 +Date: 2011-12-11 Author: Paul Kienzle <pki...@us...> Maintainer: Paul Kienzle <pki...@us...> Title: Audio Description: Audio recording, processing and playing tools. -Depends: octave (>= 2.9.7) +Depends: octave (>= 2.9.7), miscellaneous (>= ) Autoload: yes License: GPL version 2 or later Url: http://octave.sf.net Added: trunk/octave-forge/main/audio/NEWS =================================================================== --- trunk/octave-forge/main/audio/NEWS (rev 0) +++ trunk/octave-forge/main/audio/NEWS 2011-12-11 15:04:33 UTC (rev 9364) @@ -0,0 +1,8 @@ +Summary of important user-visible changes for releases of the audio package + +=============================================================================== +audio-X.Y.Z Release Date: 2011-YY-XX Release Manager: +=============================================================================== + +* Created this NEWS file. +* Fuction clip was moved to miscellaneous package. Deleted: trunk/octave-forge/main/audio/inst/clip.m =================================================================== --- trunk/octave-forge/main/audio/inst/clip.m 2011-12-11 03:30:40 UTC (rev 9363) +++ trunk/octave-forge/main/audio/inst/clip.m 2011-12-11 15:04:33 UTC (rev 9364) @@ -1,63 +0,0 @@ -## Copyright (C) 1999 Paul Kienzle -## -## This program 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, -## 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, see <http://www.gnu.org/licenses/>. - -## Clip values outside the range to the value at the boundary of the -## range. -## -## X = clip(X) -## Clip to range [0, 1] -## -## X = clip(X, hi) -## Clip to range [0, hi] -## -## X = clip(X, [lo, hi]) -## Clip to range [lo, hi] - -## TODO: more clip modes, such as three level clip(X, [lo, mid, hi]), which -## TODO: sends everything above hi to hi, below lo to lo and between to -## TODO: mid; or infinite peak clipping, which sends everything above mid -## TODO: to hi and below mid to lo. - -function x = clip (x, range) - - if (nargin == 2) - if (length(range) == 1) - range = [0, range]; - end - elseif (nargin == 1) - range = [0, 1]; - else - usage("X = clip(X [, range])"); - end - try wfi = warning("query", "Octave:fortran-indexing").state; - catch wfi = "off"; - end - unwind_protect - x (find (x > range (2))) = range (2); - x (find (x < range (1))) = range (1); - unwind_protect_cleanup - warning(wfi, "Octave:fortran-indexing"); - end_unwind_protect - -endfunction - -%!error clip -%!error clip(1,2,3) -%!assert (clip(pi), 1) -%!assert (clip(-pi), 0) -%!assert (clip([-1.5, 0, 1.5], [-1, 1]), [-1, 0, 1]); -%!assert (clip([-1.5, 0, 1.5]', [-1, 1]'), [-1, 0, 1]'); -%!assert (clip([-1.5, 1; 0, 1.5], [-1, 1]), [-1, 1; 0, 1]); -%!assert (isempty(clip([],1))); Modified: trunk/octave-forge/main/miscellaneous/DESCRIPTION =================================================================== --- trunk/octave-forge/main/miscellaneous/DESCRIPTION 2011-12-11 03:30:40 UTC (rev 9363) +++ trunk/octave-forge/main/miscellaneous/DESCRIPTION 2011-12-11 15:04:33 UTC (rev 9364) @@ -1,6 +1,6 @@ Name: Miscellaneous Version: 1.0.11 -Date: 2011-05-20 +Date: 2011-12-11 Author: Various Authors Maintainer: The Octave Community Title: Miscellaneous functions Modified: trunk/octave-forge/main/miscellaneous/INDEX =================================================================== --- trunk/octave-forge/main/miscellaneous/INDEX 2011-12-11 03:30:40 UTC (rev 9363) +++ trunk/octave-forge/main/miscellaneous/INDEX 2011-12-11 15:04:33 UTC (rev 9364) @@ -21,3 +21,4 @@ csvexplode server publish + clip Added: trunk/octave-forge/main/miscellaneous/NEWS =================================================================== --- trunk/octave-forge/main/miscellaneous/NEWS (rev 0) +++ trunk/octave-forge/main/miscellaneous/NEWS 2011-12-11 15:04:33 UTC (rev 9364) @@ -0,0 +1,8 @@ +Summary of important user-visible changes for releases of the miscellaneous package + +=============================================================================== +miscellaneous-X.Y.Z Release Date: 2011-YY-XX Release Manager: +=============================================================================== + +* This NEWS file was created. +* Function clip imported from audio. Copied: trunk/octave-forge/main/miscellaneous/inst/clip.m (from rev 9363, trunk/octave-forge/main/audio/inst/clip.m) =================================================================== --- trunk/octave-forge/main/miscellaneous/inst/clip.m (rev 0) +++ trunk/octave-forge/main/miscellaneous/inst/clip.m 2011-12-11 15:04:33 UTC (rev 9364) @@ -0,0 +1,63 @@ +## Copyright (C) 1999 Paul Kienzle +## +## This program 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, +## 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, see <http://www.gnu.org/licenses/>. + +## Clip values outside the range to the value at the boundary of the +## range. +## +## X = clip(X) +## Clip to range [0, 1] +## +## X = clip(X, hi) +## Clip to range [0, hi] +## +## X = clip(X, [lo, hi]) +## Clip to range [lo, hi] + +## TODO: more clip modes, such as three level clip(X, [lo, mid, hi]), which +## TODO: sends everything above hi to hi, below lo to lo and between to +## TODO: mid; or infinite peak clipping, which sends everything above mid +## TODO: to hi and below mid to lo. + +function x = clip (x, range) + + if (nargin == 2) + if (length(range) == 1) + range = [0, range]; + end + elseif (nargin == 1) + range = [0, 1]; + else + usage("X = clip(X [, range])"); + end + try wfi = warning("query", "Octave:fortran-indexing").state; + catch wfi = "off"; + end + unwind_protect + x (find (x > range (2))) = range (2); + x (find (x < range (1))) = range (1); + unwind_protect_cleanup + warning(wfi, "Octave:fortran-indexing"); + end_unwind_protect + +endfunction + +%!error clip +%!error clip(1,2,3) +%!assert (clip(pi), 1) +%!assert (clip(-pi), 0) +%!assert (clip([-1.5, 0, 1.5], [-1, 1]), [-1, 0, 1]); +%!assert (clip([-1.5, 0, 1.5]', [-1, 1]'), [-1, 0, 1]'); +%!assert (clip([-1.5, 1; 0, 1.5], [-1, 1]), [-1, 1; 0, 1]); +%!assert (isempty(clip([],1))); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |