This is example.c in view mode; [Download] [Up]
/*
* FILE: example.c
* BY: Christopher Lee Fraley
* DESC: This is an example function which takes a sound and a
* double as input, and returns a double.
*
* 1.0 ( 3-JUN-89) - created. (clf)
*/
#include <math.h>
#include "xlisp.h"
#include "sound.h"
double ave(sound, d)
SoundPtr sound;
double d;
{
int len, i;
double val;
/* Need to call s_flatten(sound) before accessing the samples in sound! */
(void)s_flatten(sound);
len = sound->ptr.sample->length;
for (i=0; i<len; i++)
{
/* Each sample may be referenced by sound->ptr.sample->data[i] */
/* Some calculation involving sound, and d gets put here, for example: */
val += log(sound->ptr.sample->data[i] / d);
}
return (val / len);
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.