diff options
author | 2010-05-27 22:51:35 +0200 | |
---|---|---|
committer | 2010-05-27 22:51:35 +0200 | |
commit | 4810f9a0af507bb405e6a3c58decfa9c9980b2ff (patch) | |
tree | 75ac9c06345b23528e6771bb1bae697ff5c29c1c /plugins/dumb/dumb-kode54/src/helpers/sampbuf.c | |
parent | ad71971955594ada4a0b14d176a192d050c9ee36 (diff) |
merged parts of DUMB-0.9.3
Diffstat (limited to 'plugins/dumb/dumb-kode54/src/helpers/sampbuf.c')
-rw-r--r-- | plugins/dumb/dumb-kode54/src/helpers/sampbuf.c | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/plugins/dumb/dumb-kode54/src/helpers/sampbuf.c b/plugins/dumb/dumb-kode54/src/helpers/sampbuf.c index 488db449..6a80f1fa 100644 --- a/plugins/dumb/dumb-kode54/src/helpers/sampbuf.c +++ b/plugins/dumb/dumb-kode54/src/helpers/sampbuf.c @@ -1,64 +1,64 @@ -/* _______ ____ __ ___ ___
- * \ _ \ \ / \ / \ \ / / ' ' '
- * | | \ \ | | || | \/ | . .
- * | | | | | | || ||\ /| |
- * | | | | | | || || \/ | | ' ' '
- * | | | | | | || || | | . .
- * | |_/ / \ \__// || | |
- * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque
- * / \
- * / . \
- * sampbuf.c - Helper for allocating sample / / \ \
- * buffers. | < / \_
- * | \/ /\ /
- * By entheh. \_ / > /
- * | \ / /
- * | ' /
- * \__/
- */
-
-#include <stdlib.h>
-#include "dumb.h"
-
-
-
-/* DEPRECATED */
-sample_t **create_sample_buffer(int n_channels, long length)
-{
- int i;
- sample_t **samples = malloc(n_channels * sizeof(*samples));
- if (!samples) return NULL;
- samples[0] = malloc(n_channels * length * sizeof(*samples[0]));
- if (!samples[0]) {
- free(samples);
- return NULL;
- }
- for (i = 1; i < n_channels; i++) samples[i] = samples[i-1] + length;
- return samples;
-}
-
-
-
-sample_t **allocate_sample_buffer(int n_channels, long length)
-{
- int i;
- sample_t **samples = malloc(((n_channels + 1) >> 1) * sizeof(*samples));
- if (!samples) return NULL;
- samples[0] = malloc(n_channels * length * sizeof(*samples[0]));
- if (!samples[0]) {
- free(samples);
- return NULL;
- }
- for (i = 1; i < (n_channels + 1) >> 1; i++) samples[i] = samples[i-1] + length*2;
- return samples;
-}
-
-
-
-void destroy_sample_buffer(sample_t **samples)
-{
- if (samples) {
- free(samples[0]);
- free(samples);
- }
-}
+/* _______ ____ __ ___ ___ + * \ _ \ \ / \ / \ \ / / ' ' ' + * | | \ \ | | || | \/ | . . + * | | | | | | || ||\ /| | + * | | | | | | || || \/ | | ' ' ' + * | | | | | | || || | | . . + * | |_/ / \ \__// || | | + * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque + * / \ + * / . \ + * sampbuf.c - Helper for allocating sample / / \ \ + * buffers. | < / \_ + * | \/ /\ / + * By entheh. \_ / > / + * | \ / / + * | ' / + * \__/ + */ + +#include <stdlib.h> +#include "dumb.h" + + + +/* DEPRECATED */ +sample_t **create_sample_buffer(int n_channels, long length) +{ + int i; + sample_t **samples = malloc(n_channels * sizeof(*samples)); + if (!samples) return NULL; + samples[0] = malloc(n_channels * length * sizeof(*samples[0])); + if (!samples[0]) { + free(samples); + return NULL; + } + for (i = 1; i < n_channels; i++) samples[i] = samples[i-1] + length; + return samples; +} + + + +sample_t **allocate_sample_buffer(int n_channels, long length) +{ + int i; + sample_t **samples = malloc(((n_channels + 1) >> 1) * sizeof(*samples)); + if (!samples) return NULL; + samples[0] = malloc(n_channels * length * sizeof(*samples[0])); + if (!samples[0]) { + free(samples); + return NULL; + } + for (i = 1; i < (n_channels + 1) >> 1; i++) samples[i] = samples[i-1] + length*2; + return samples; +} + + + +void destroy_sample_buffer(sample_t **samples) +{ + if (samples) { + free(samples[0]); + free(samples); + } +} |