* *
****************************************************************************/
-typedef void snd_instr_iwffff_t;
+/* Simple Wave support */
+
+typedef void snd_instr_simple_t;
#ifdef __cplusplus
extern "C" {
#endif
+int snd_instr_simple_convert_to_stream(snd_instr_simple_t *simple, const char *name, snd_seq_instr_put_t **put, long *size);
+int snd_instr_simple_convert_from_stream(snd_seq_instr_get_t *data, long size, snd_instr_simple_t **simple);
+int snd_instr_simple_free(snd_instr_simple_t *simple);
+
+#ifdef __cplusplus
+}
+#endif
+
/* InterWave FFFF support */
-int snd_instr_iwffff_open(void **handle, const char *name_fff, const char *name_dta);
-int snd_instr_iwffff_open_rom(void **handle, int card, int bank, int file);
-int snd_instr_iwffff_open_rom_file(void **handle, const char *name, int bank, int file);
-int snd_instr_iwffff_close(void *handle);
-int snd_instr_iwffff_load(void *handle, int bank, int prg, snd_instr_iwffff_t **iwffff);
-int snd_instr_iwffff_convert_to_stream(snd_instr_iwffff_t *iwffff, const char *name, snd_seq_instr_data_t **data, int *size);
-int snd_instr_iwffff_convert_from_stream(snd_seq_instr_data_t *data, int size, snd_instr_iwffff_t **iwffff);
+
+typedef void snd_instr_iwffff_t;
+typedef struct snd_iwffff_handle snd_iwffff_handle_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int snd_instr_iwffff_open(snd_iwffff_handle_t **handle, const char *name_fff, const char *name_dta);
+int snd_instr_iwffff_open_rom(snd_iwffff_handle_t **handle, int card, int bank, int file);
+int snd_instr_iwffff_open_rom_file(snd_iwffff_handle_t **handle, const char *name, int bank, int file);
+int snd_instr_iwffff_close(snd_iwffff_handle_t *handle);
+int snd_instr_iwffff_load(snd_iwffff_handle_t *handle, int bank, int prg, snd_instr_iwffff_t **iwffff);
+int snd_instr_iwffff_convert_to_stream(snd_instr_iwffff_t *iwffff, const char *name, snd_seq_instr_put_t **data, long *size);
+int snd_instr_iwffff_convert_from_stream(snd_seq_instr_get_t *data, long size, snd_instr_iwffff_t **iwffff);
int snd_instr_iwffff_free(snd_instr_iwffff_t *iwffff);
#ifdef __cplusplus
EXTRA_LTLIBRARIES=libinstr.la
-libinstr_la_SOURCES = iwffff.c
+libinstr_la_SOURCES = simple.c iwffff.c
all: libinstr.la
#define copyright_header IW_ID_VALUE('C', 'P', 'R', 'T')
#endif
-typedef struct {
+struct snd_iwffff_handle {
int rom;
unsigned char *fff_data;
unsigned int fff_size;
unsigned int share_id1;
unsigned int share_id2;
unsigned int share_id3;
-} iwffff_t;
+};
/*
* local functions
return fd;
}
-int snd_instr_iwffff_open(void **handle, const char *name_fff, const char *name_dat)
+int snd_instr_iwffff_open(snd_iwffff_handle_t **handle, const char *name_fff, const char *name_dat)
{
- iwffff_t *iwf;
+ snd_iwffff_handle_t *iwf;
struct stat info;
struct header ffff;
int fd;
return 0;
}
-int snd_instr_iwffff_open_rom(void **handle, int card, int bank, int file)
+int snd_instr_iwffff_open_rom(snd_iwffff_handle_t **handle, int card, int bank, int file)
{
unsigned int next_ffff;
struct header ffff;
- iwffff_t *iwf;
+ snd_iwffff_handle_t *iwf;
iwffff_rom_header_t header;
int fd, index;
return -ENOENT;
}
-int snd_instr_iwffff_close(void *handle)
+int snd_instr_iwffff_close(snd_iwffff_handle_t *iwf)
{
- iwffff_t *iwf;
-
- if (handle == NULL)
- return -ENOENT;
- iwf = (iwffff_t *)handle;
+ if (iwf == NULL)
+ return -EINVAL;
if (iwf->dat_filename)
free(iwf->dat_filename);
if (iwf->fff_filename)
return 0;
}
-static char *look_for_id(iwffff_t *iwf, unsigned char *start,
+static char *look_for_id(snd_iwffff_handle_t *iwf, unsigned char *start,
unsigned char *end, ID id)
{
if (!start)
glfo->delay = buffer[7];
}
-static int copy_envelope(iwffff_t *iwf, iwffff_env_t *genv, ID eid)
+static int copy_envelope(snd_iwffff_handle_t *iwf, iwffff_env_t *genv, ID eid)
{
int idx, idx1;
unsigned char *ptr, *end;
}
}
-static int load_iw_wave(iwffff_t *file,
+static int load_iw_wave(snd_iwffff_handle_t *file,
unsigned int start,
unsigned int size,
unsigned char **result)
return 0;
}
-static int load_iw_patch(iwffff_t *iwf, iwffff_instrument_t *instr,
+static int load_iw_patch(snd_iwffff_handle_t *iwf, iwffff_instrument_t *instr,
unsigned char *patch)
{
unsigned char *layer, *wave;
return 0;
}
-int snd_instr_iwffff_load(void *handle, int bank, int prg, snd_instr_iwffff_t **__iwffff)
+int snd_instr_iwffff_load(snd_iwffff_handle_t *iwf, int bank, int prg, snd_instr_iwffff_t **__iwffff)
{
- iwffff_t *iwf;
unsigned char *ptr, *end;
unsigned char *program, *patch;
struct header *header;
iwffff_instrument_t *iwffff;
int result;
- if (handle == NULL || __iwffff == NULL)
+ if (iwf == NULL || __iwffff == NULL)
return -EINVAL;
__iwffff = NULL;
if (bank < 0 || bank > 255 || prg < 0 || prg > 255)
return -EINVAL;
iwffff = (iwffff_instrument_t *)__iwffff;
- iwf = (iwffff_t *)handle;
ptr = iwf->fff_data;
end = iwf->fff_data + iwf->fff_size;
while (1) {
}
int snd_instr_iwffff_conv_to_stream(snd_instr_iwffff_t *iwffff,
- const char *name,
- snd_seq_instr_data_t **__data,
- int *__size)
+ const char *name,
+ snd_seq_instr_put_t **__data,
+ long *__size)
{
+ snd_seq_instr_put_t *put;
snd_seq_instr_data_t *data;
int size;
char *ptr;
*__data = NULL;
*__size = 0;
size = sizeof(*data) + iwffff_size(iwffff);
- data = (snd_seq_instr_data_t *)malloc(sizeof(*data) + size);
- if (data == NULL)
+ put = (snd_seq_instr_put_t *)malloc(sizeof(*put) + size);
+ if (put == NULL)
return -ENOMEM;
/* build header */
- bzero(data, sizeof(*data));
+ bzero(put, sizeof(*put));
+ data = &put->data;
if (name)
strncpy(data->name, name, sizeof(data->name)-1);
data->type = SND_SEQ_INSTR_ATYPE_DATA;
xwave->low_note = wave->low_note;
xwave->high_note = wave->high_note;
if (!(xwave->format & IWFFFF_WAVE_ROM)) {
- memcpy(ptr, wave->address.ptr, xwave->size);
- ptr += xwave->size;
+ memcpy(ptr, wave->address.ptr, wave->size);
+ ptr += wave->size;
} else {
xwave->offset = snd_htoi_32(wave->address.memory);
}
}
}
/* write result */
- *__data = data;
+ *__data = put;
*__size = size;
return 0;
}
-int snd_instr_iwffff_convert_from_stream(snd_seq_instr_data_t *data,
- int size,
+int snd_instr_iwffff_convert_from_stream(snd_seq_instr_get_t *data,
+ long size,
snd_instr_iwffff_t **iwffff)
{
/* TODO */
--- /dev/null
+/*
+ * Simple Wave Format Support
+ * Copyright (c) 1999 by Jaroslav Kysela <perex@suse.cz>
+ *
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library 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 Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include "asoundlib.h"
+#include <linux/ainstr_simple.h>
+
+static long simple_size(simple_instrument_t *instr)
+{
+ return sizeof(simple_xinstrument_t) + instr->size;
+}
+
+int snd_instr_simple_convert_to_stream(snd_instr_simple_t *simple,
+ const char *name,
+ snd_seq_instr_put_t **__data,
+ long *__size)
+{
+ snd_seq_instr_put_t *put;
+ snd_seq_instr_data_t *data;
+ int size;
+ char *ptr;
+ simple_instrument_t *instr;
+ simple_xinstrument_t *xinstr;
+
+ if (simple == NULL || __data == NULL)
+ return -EINVAL;
+ instr = (simple_instrument_t *)simple;
+ *__data = NULL;
+ *__size = 0;
+ size = sizeof(*put) + simple_size(simple);
+ put = (snd_seq_instr_put_t *)malloc(sizeof(*put) + size);
+ if (put == NULL)
+ return -ENOMEM;
+ /* build header */
+ bzero(put, sizeof(*put));
+ data = &put->data;
+ if (name)
+ strncpy(data->name, name, sizeof(data->name)-1);
+ data->type = SND_SEQ_INSTR_ATYPE_DATA;
+ strcpy(data->data.format, SND_SEQ_INSTR_ID_SIMPLE);
+ /* build data section */
+ xinstr = (simple_xinstrument_t *)(data + 1);
+ xinstr->stype = SIMPLE_STRU_INSTR;
+ xinstr->share_id[0] = snd_htoi_32(instr->share_id[0]);
+ xinstr->share_id[1] = snd_htoi_32(instr->share_id[1]);
+ xinstr->share_id[2] = snd_htoi_32(instr->share_id[2]);
+ xinstr->share_id[3] = snd_htoi_32(instr->share_id[3]);
+ xinstr->size = snd_htoi_32(instr->size);
+ xinstr->start = snd_htoi_32(instr->start);
+ xinstr->loop_start = snd_htoi_32(instr->loop_start);
+ xinstr->loop_end = snd_htoi_32(instr->loop_end);
+ xinstr->loop_repeat = snd_htoi_16(instr->loop_repeat);
+ xinstr->effect1 = instr->effect1;
+ xinstr->effect1_depth = instr->effect1_depth;
+ xinstr->effect2 = instr->effect2;
+ xinstr->effect2_depth = instr->effect2_depth;
+ ptr = (char *)(xinstr + 1);
+ memcpy(ptr, instr->address.ptr, instr->size);
+ /* write result */
+ *__data = put;
+ *__size = size;
+ return 0;
+}
+
+int snd_instr_simple_convert_from_stream(snd_seq_instr_get_t *__data,
+ long size,
+ snd_instr_simple_t **simple)
+{
+ /* TODO */
+ return -ENXIO;
+}