ref: 8d7ab5777e9da74ed8fad43b8ea416354a8d69cc
parent: 709570b2f9deb1fb83e50403d22e093dede4f780
author: rrt <rrt>
date: Wed Dec 13 11:58:32 EST 2006
Improve the skeleton format and effect.
--- a/src/skel.c
+++ b/src/skel.c
@@ -1,6 +1,10 @@
/*
* Sound Tools skeleton file format driver.
*
+ * Written by Chris Bagwell (cbagwell@sprynet.com) - March 16, 1999
+ *
+ * Copyright 1999 Chris Bagwell And Sundry Contributors
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
@@ -15,7 +19,6 @@
* License along with this library. If not, write to the Free Software
* Foundation, Fifth Floor, 51 Franklin Street, Boston, MA 02111-1301,
* USA. */
- */
#include "st_i.h"
--- a/src/skeleff.c
+++ b/src/skeleff.c
@@ -4,13 +4,22 @@
* Written by Chris Bagwell (cbagwell@sprynet.com) - March 16, 1999
*
* Copyright 1999 Chris Bagwell And Sundry Contributors
- * This source code is freely redistributable and may be used for
- * any purpose. This copyright notice must be maintained.
- * Chris Bagwell And Sundry Contributors are not responsible for
- * the consequences of using this software.
- */
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, write to the Free Software
+ * Foundation, Fifth Floor, 51 Franklin Street, Boston, MA 02111-1301,
+ * USA. */
-
#include "st_i.h"
/* Private data for effect */
@@ -27,33 +36,31 @@
* Don't do initialization now.
* The 'info' fields are not yet filled in.
*/
-int st_skeleff_getopts(eff_t effp, int n, char **argv)
+static int st_skeleff_getopts(eff_t effp, int n, char **argv)
{
skeleff_t skeleff = (skeleff_t) effp->priv;
- if (n)
- {
- if (n != 1)
- {
- st_fail("Usage: skeleff [option]");
- return (ST_EOF);
- }
+ if (n && n != 1) {
+ st_fail("Usage: skeleff [option]");
+ return ST_EOF;
}
- return (ST_SUCCESS);
+
+ return ST_SUCCESS;
}
/*
* Prepare processing.
* Do all initializations.
+ * If there's nothing to do, use st_effect_nothing instead.
*/
-int st_skeleff_start(eff_t effp)
+static int st_skeleff_start(eff_t effp)
{
- if (effp->outinfo.channels == 1)
- {
+ if (effp->outinfo.channels == 1) {
st_fail("Can't run skeleff on mono data.");
- return (ST_EOF);
+ return ST_EOF;
}
- return (ST_SUCCESS);
+
+ return ST_SUCCESS;
}
/*
@@ -60,14 +67,13 @@
* Processed signed long samples from ibuf to obuf.
* Return number of samples processed.
*/
-int st_skeleff_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
+static int st_skeleff_flow(eff_t effp, const st_sample_t *ibuf, st_sample_t *obuf,
st_size_t *isamp, st_size_t *osamp)
{
skeleff_t skeleff = (skeleff_t) effp->priv;
int len, done;
- switch (effp->outinfo.channels)
- {
+ switch (effp->outinfo.channels) {
case 2:
/* Length to process will be buffer length / 2 since we
* work with two samples at a time.
@@ -86,16 +92,16 @@
*osamp = len * 2;
break;
-
}
- return (ST_SUCCESS);
+
+ return ST_SUCCESS;
}
/*
* Drain out remaining samples if the effect generates any.
+ * If there's nothing to do, use st_effect_nothing_drain instead.
*/
-
-int st_skeleff_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+static int st_skeleff_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
*osamp = 0;
/* Help out application and return ST_EOF when drain
@@ -102,15 +108,41 @@
* will not return any mre information. *osamp == 0
* also indicates that.
*/
- return (ST_EOF);
+ return ST_EOF;
}
/*
* Do anything required when you stop reading samples.
* (free allocated memory, etc.)
+ * If there's nothing to do, use st_effect_nothing instead.
*/
-int st_skeleff_stop(eff_t effp)
+static int st_skeleff_stop(eff_t effp)
{
- /* nothing to do */
- return (ST_SUCCESS);
+ return ST_SUCCESS;
+}
+
+
+/*
+ * Effect descriptor.
+ * If one of the methods does nothing, use the relevant
+ * st_effect_nothing* method.
+ */
+static st_effect_t st_skel_effect = {
+ "skel",
+ "Usage: skel -x",
+ ST_EFF_MCHAN,
+ st_skel_getopts,
+ st_skel_start,
+ st_skel_flow,
+ st_skel_drain,
+ st_skel_stop
+};
+
+/*
+ * Function returning effect descriptor. This should be the only
+ * externally visible object.
+ */
+const st_effect_t *st_skel_effect_fn(void)
+{
+ return &st_skel_effect;
}