Ejemplo n.º 1
0
int ftm_load(xmp_file f)
{
	int i, j, k;
	struct xmp_event *event;
	struct ftm_header fh;
	struct ftm_instrument si;
	uint8 b1, b2, b3;

	LOAD_INIT();

	xmp_fread(&fh.id, 4, 1, f);
	if (memcmp(fh.id, "FTMN", 4))
		return -1;

	fh.ver = read8(f);
	fh.nos = read8(f);
	read16b(f);
	read32b(f);
	read32b(f);
	xmp_fread(&fh.title, 32, 1, f);
	xmp_fread(&fh.author, 32, 1, f);
	read16b(f);

	//mod->len = fh.len;
	//mod->pat = fh.pat;
	mod->ins = fh.nos;
	mod->smp = mod->ins;
	mod->trk = mod->pat * mod->chn;
	for (i = 0; i < mod->len; i++)
		mod->xxo[i] = fh.order[i];

	set_type(m, "Face The Music");
	MODULE_INFO();
	PATTERN_INIT();

	/* Load and convert patterns */
	if (V(0))
		report("Stored patterns: %d ", mod->pat);
	for (i = 0; i < mod->pat; i++) {
		PATTERN_ALLOC(i);
		mod->xxp[i]->rows = 64;
		TRACK_ALLOC(i);
		for (j = 0; j < 4; j++) {
		}

		reportv(ctx, 0, ".");
	}

	INSTRUMENT_INIT();
	reportv(ctx, 0, "\nStored samples : %d ", mod->smp);

	for (i = 0; i < mod->smp; i++) {
		reportv(ctx, 0, ".");
	}

	reportv(ctx, 0, "\n");
	mod->flg |= XXM_FLG_MODRNG;

	return 0;
}
Ejemplo n.º 2
0
static int emod_load(struct module_data *m, xmp_file f, const int start)
{
    iff_handle handle;

    LOAD_INIT();

    read32b(f);		/* FORM */
    read32b(f);
    read32b(f);		/* EMOD */

    handle = iff_new();
    if (handle == NULL)
	return -1;

    /* IFF chunk IDs */
    iff_register(handle, "EMIC", get_emic);
    iff_register(handle, "PATT", get_patt);
    iff_register(handle, "8SMP", get_8smp);

    /* Load IFF chunks */
    while (!xmp_feof(f)) {
	iff_chunk(handle, m, f, NULL);
    }

    iff_release(handle);

    return 0;
}
Ejemplo n.º 3
0
static void get_smpl(struct module_data *m, int size, FILE *f, void *parm)
{
	struct xmp_module *mod = &m->mod;
	int i, flags;

	D_(D_INFO "Stored samples: %d", mod->smp);

	for (i = 0; i < mod->smp; i++) {
		flags = read32b(f);
		mod->xxs[i].len = read32b(f);

		if (flags & 0x02) {
			mod->xxs[i].flg |= XMP_SAMPLE_16BIT;
		}

		if (flags & 0x04) {	/* Skip 32-bit samples */
			mod->xxs[i].len <<= 2;
			fseek(f, mod->xxs[i].len, SEEK_CUR);
			continue;
		}
		
		load_sample(f, SAMPLE_FLAG_BIGEND, &mod->xxs[i], NULL);

		if (mod->xxs[i].len == 0)
			continue;

		D_(D_INFO "[%2X] %08x %05x%c%05x %05x %c",
			i, flags, mod->xxs[i].len,
			mod->xxs[i].flg & XMP_SAMPLE_16BIT ? '+' : ' ',
			mod->xxs[i].lps, mod->xxs[i].lpe,
			mod->xxs[i].flg & XMP_SAMPLE_LOOP ?
			(mod->xxs[i].flg & XMP_SAMPLE_LOOP_BIDIR ? 'B' : 'L') : ' ');

	}
}
static int emod_test(FILE *f, char *t, const int start)
{
    if (read32b(f) != MAGIC_FORM)
	return -1;

    read32b(f);

    if (read32b(f) != MAGIC_EMOD)
	return -1;

    read_title(f, t, 0);

    return 0;
}
Ejemplo n.º 5
0
static int gdm_test(xmp_file f, char *t, const int start)
{
	if (read32b(f) != MAGIC_GDM)
		return -1;

	xmp_fseek(f, start + 0x47, SEEK_SET);
	if (read32b(f) != MAGIC_GMFS)
		return -1;

	xmp_fseek(f, start + 4, SEEK_SET);
	read_title(f, t, 32);

	return 0;
}
Ejemplo n.º 6
0
static int sfx_test(FILE *f, char *t, const int start)
{
    uint32 a, b;

    fseek(f, 4 * 15, SEEK_CUR);
    a = read32b(f);
    fseek(f, 4 * 15, SEEK_CUR);
    b = read32b(f);

    if (a != MAGIC_SONG && b != MAGIC_SONG)
	return -1;

    read_title(f, t, 0);

    return 0;
}
Ejemplo n.º 7
0
static int pt3_test(FILE *f, char *t, const int start)
{
	if (read32b(f) != MAGIC_FORM)
		return -1;

	read32b(f);	/* skip size */

	if (read32b(f) != MAGIC_MODL)
		return -1;

	if (read32b(f) != MAGIC_VERS)
		return -1;

	read32b(f);	/* skip size */

	fseek(f, 10, SEEK_CUR);
	
	if (read32b(f) == MAGIC_INFO) {
		read32b(f);	/* skip size */
		read_title(f, t, 32);
	} else {
		read_title(f, t, 0);
	}

	return 0;
}
Ejemplo n.º 8
0
static int depack_mp(FILE *in, FILE *out)
{
	uint8 c1;
	uint8 ptable[128];
	uint8 max;
	int i;
	int size, ssize = 0;

	memset(ptable, 0, 128);

	pw_write_zero(out, 20);				/* title */

	if (read32b(in) != MAGIC_TRK1)			/* TRK1 */
		fseek(in, -4, SEEK_CUR);

	for (i = 0; i < 31; i++) {
		pw_write_zero(out, 22);			/* sample name */
		write16b(out, size = read16b(in));	/* size */
		ssize += size * 2;
		write8(out, read8(in));			/* finetune */
		write8(out, read8(in));			/* volume */
		write16b(out, read16b(in));		/* loop start */
		write16b(out, read16b(in));		/* loop size */
	}

	write8(out, read8(in));		/* pattern table length */
	write8(out, read8(in));		/* NoiseTracker restart byte */

	for (max = i = 0; i < 128; i++) {
		write8(out, c1 = read8(in));
		if (c1 > max)
			max = c1;
	}
	max++;

	write32b(out, PW_MOD_MAGIC);		/* M.K. */

	if (read32b(in) != 0)			/* bypass unknown empty bytes */
		fseek (in, -4, SEEK_CUR);

	pw_move_data(out, in, 1024 * max);	/* pattern data */
	pw_move_data(out, in, ssize);		/* sample data */

	return 0;
}
static int mgt_test(FILE *f, char *t, const int start)
{
	int sng_ptr;

	if (read24b(f) != MAGIC_MGT)
		return -1;
	read8(f);
	if (read32b(f) != MAGIC_MCS)
		return -1;

	fseek(f, 18, SEEK_CUR);
	sng_ptr = read32b(f);
	fseek(f, start + sng_ptr, SEEK_SET);

	read_title(f, t, 32);
	
	return 0;
}
Ejemplo n.º 10
0
static int far_test(FILE *f, char *t, const int start)
{
    if (read32b(f) != MAGIC_FAR)
	return -1;

    read_title(f, t, 40);

    return 0;
}
Ejemplo n.º 11
0
static int med4_test(xmp_file f, char *t, const int start)
{
	if (read32b(f) !=  MAGIC_MED4)
		return -1;

	read_title(f, t, 0);

	return 0;
}
static int dtt_test(FILE *f, char *t, const int start)
{
	if (read32b(f) != MAGIC_DskT)
		return -1;

	read_title(f, t, 64);

	return 0;
}
Ejemplo n.º 13
0
static int stim_test(FILE *f, char *t, const int start)
{
    if (read32b(f) != MAGIC_STIM)
        return -1;

    read_title(f, t, 0);

    return 0;
}
Ejemplo n.º 14
0
static void get_smpl(struct xmp_context *ctx, int size, FILE *f)
{
	struct xmp_player_context *p = &ctx->p;
	struct xmp_mod_context *m = &p->m;
	int i, flags;

	reportv(ctx, 0, "Stored samples : %d ", m->xxh->smp);

	reportv(ctx, 2, "\n     Flags    Len   LBeg  LEnd  L");

	for (i = 0; i < m->xxh->smp; i++) {
		flags = read32b(f);
		m->xxs[i].len = read32b(f);

		if (flags & 0x02) {
			m->xxs[i].flg |= WAVE_16_BITS;
			m->xxs[i].len <<= 1;
			m->xxs[i].lps <<= 1;
			m->xxs[i].lpe <<= 1;
		}

		if (flags & 0x04) {	/* Skip 32-bit samples */
			m->xxs[i].len <<= 2;
			fseek(f, m->xxs[i].len, SEEK_CUR);
			continue;
		}
		
		xmp_drv_loadpatch(ctx, f, i, m->c4rate, XMP_SMP_BIGEND,
							&m->xxs[i], NULL);

		if (m->xxs[i].len == 0)
			continue;

		reportv(ctx, 2, "\n[%2X] %08x %05x%c%05x %05x %c ",
			i, flags, m->xxs[i].len,
			m->xxs[i].flg & WAVE_16_BITS ? '+' : ' ',
			m->xxs[i].lps, m->xxs[i].lpe,
			m->xxs[i].flg & WAVE_LOOPING ?
			(m->xxs[i].flg & WAVE_BIDIR_LOOP ? 'B' : 'L') : ' ');

		reportv(ctx, 0, ".");
	}
	reportv(ctx, 0, "\n");
}
Ejemplo n.º 15
0
static int mdl_test(FILE *f, char *t, const int start)
{
    uint16 id;

    if (read32b(f) != MAGIC_DMDL)
	return -1;

    read8(f);			/* version */
    id = read16b(f);

    if (id == 0x494e) {		/* IN */
	read32b(f);
	read_title(f, t, 32);
    } else {
	read_title(f, t, 0);
    }

    return 0;
}
Ejemplo n.º 16
0
static void get_inst(struct xmp_context *ctx, int size, FILE *f)
{
	struct xmp_player_context *p = &ctx->p;
	struct xmp_mod_context *m = &p->m;
	int i;
	int c2spd, flags, snum;
	uint8 buffer[50];

	reportv(ctx, 0, "Instruments    : %d ", m->xxh->ins);

	reportv(ctx, 1, "\n     Instrument name                Smp Vol Pan C2Spd");

	for (i = 0; i < m->xxh->ins; i++) {
		m->xxi[i] = calloc(sizeof(struct xxm_instrument), 1);

		m->xxih[i].nsm = 1;
		fread(buffer, 30, 1, f);
		copy_adjust(m->xxih[i].name, buffer, 30);
		snum = read16b(f);
		if (snum == 0 || snum > m->xxh->smp)
			continue;
		m->xxi[i][0].sid = --snum;
		m->xxi[i][0].vol = read16b(f);
		c2spd = read32b(f);
		m->xxs[snum].lps = read32b(f);
		m->xxs[snum].lpe = m->xxs[i].lps + read32b(f);
		m->xxi[i][0].pan = 0x80 + (int16)read16b(f);
		if (m->xxi[i][0].pan > 0xff)
			m->xxi[i][0].pan = 0xff;
		flags = read16b(f);
		m->xxs[snum].flg = flags & 0x03 ? WAVE_LOOPING : 0;
		m->xxs[snum].flg |= flags & 0x02 ? WAVE_BIDIR_LOOP : 0;

		c2spd_to_note(c2spd, &m->xxi[i][0].xpo, &m->xxi[i][0].fin);

		reportv(ctx, 1, "\n[%2X] %-30.30s #%02X V%02x P%02x %5d ",
			i, m->xxih[i].name, snum,
			m->xxi[i][0].vol, m->xxi[i][0].pan, c2spd);

		reportv(ctx, 0, ".");
	}
	reportv(ctx, 0, "\n");
}
Ejemplo n.º 17
0
static int dbm_test(FILE * f, char *t, const int start)
{
	if (read32b(f) != MAGIC_DBM0)
		return -1;

	fseek(f, 12, SEEK_CUR);
	read_title(f, t, 44);

	return 0;
}
Ejemplo n.º 18
0
static int dmf_test(xmp_file f, char *t, const int start)
{
	if (read32b(f) != MAGIC_DDMF)
		return -1;

	xmp_fseek(f, 9, SEEK_CUR);
	read_title(f, t, 30);

	return 0;
}
Ejemplo n.º 19
0
static int s3m_test(xmp_file f, char *t, const int start)
{
    xmp_fseek(f, start + 44, SEEK_SET);
    if (read32b(f) != MAGIC_SCRM)
        return -1;

    xmp_fseek(f, start + 0, SEEK_SET);
    read_title(f, t, 28);

    return 0;
}
Ejemplo n.º 20
0
static int ptm_test(FILE *f, char *t, const int start)
{
    fseek(f, start + 44, SEEK_SET);
    if (read32b(f) != MAGIC_PTMF)
	return -1;

    fseek(f, start + 0, SEEK_SET);
    read_title(f, t, 28);

    return 0;
}
Ejemplo n.º 21
0
Archivo: hio.c Proyecto: eltoder/libxmp
uint32 hio_read32b(HIO_HANDLE *h)
{
	switch (HIO_HANDLE_TYPE(h)) {
	case HIO_HANDLE_TYPE_FILE:
		return read32b(h->handle.file);
	case HIO_HANDLE_TYPE_MEMORY:
		return mread32b(h->handle.mem);
	default:
		return 0;
	}
}
Ejemplo n.º 22
0
static int emod_test(xmp_file f, char *t, const int start)
{
    if (read32b(f) != MAGIC_FORM)
	return -1;

    read32b(f);

    if (read32b(f) != MAGIC_EMOD)
	return -1;

    if (read32b(f) == MAGIC_EMIC) {
        read32b(f);		/* skip size */
        read16b(f);		/* skip version */
        read_title(f, t, 20);
    } else {
        read_title(f, t, 0);
    }

    return 0;
}
Ejemplo n.º 23
0
static int depack_fcm(xmp_file in, xmp_file out)
{
	uint8 c1;
	uint8 ptable[128];
	uint8 pat_pos;
	uint8 pat_max;
	int i;
	int size, ssize = 0;

	memset(ptable, 0, 128);

	read32b(in);				/* bypass "FC-M" ID */
	read16b(in);				/* version number? */
	read32b(in);				/* bypass "NAME" chunk */
	pw_move_data(out, in, 20);		/* read and write title */
	read32b(in);				/* bypass "INST" chunk */

	/* read and write sample descriptions */
	for (i = 0; i < 31; i++) {
		pw_write_zero(out, 22);		/*sample name */
		write16b(out, size = read16b(in));	/* size */
		ssize += size * 2;
		write8(out, read8(in));		/* finetune */
		write8(out, read8(in));		/* volume */
		write16b(out, read16b(in));	/* loop start */
		size = read16b(in);		/* loop size */
		if (size == 0)
			size = 1;
		write16b(out, size);
	}

	read32b(in);				/* bypass "LONG" chunk */
	write8(out, pat_pos = read8(in));	/* pattern table lenght */
	write8(out, read8(in));			/* NoiseTracker byte */
	read32b(in);				/* bypass "PATT" chunk */

	/* read and write pattern list and get highest patt number */
	for (pat_max = i = 0; i < pat_pos; i++) {
		write8(out, c1 = read8(in));
		if (c1 > pat_max)
			pat_max = c1;
	}
	for (; i < 128; i++)
		write8(out, 0);

	write32b(out, PW_MOD_MAGIC);		/* write ptk ID */
	read32b(in);				/* bypass "SONG" chunk */

	for (i = 0; i <= pat_max; i++)		/* pattern data */
		pw_move_data(out, in, 1024);

	read32b(in);				/* bypass "SAMP" chunk */
	pw_move_data(out, in, ssize);		/* sample data */

	return 0;
}
Ejemplo n.º 24
0
static void get_inst(struct module_data *m, int size, FILE *f, void *parm)
{
	struct xmp_module *mod = &m->mod;
	int i;
	int c2spd, flags, snum;
	uint8 buffer[50];

	D_(D_INFO "Instruments: %d", mod->ins);

	for (i = 0; i < mod->ins; i++) {
		mod->xxi[i].sub = calloc(sizeof (struct xmp_subinstrument), 1);

		mod->xxi[i].nsm = 1;
		fread(buffer, 30, 1, f);
		copy_adjust(mod->xxi[i].name, buffer, 30);
		snum = read16b(f);
		if (snum == 0 || snum > mod->smp)
			continue;
		mod->xxi[i].sub[0].sid = --snum;
		mod->xxi[i].sub[0].vol = read16b(f);
		c2spd = read32b(f);
		mod->xxs[snum].lps = read32b(f);
		mod->xxs[snum].lpe = mod->xxs[i].lps + read32b(f);
		mod->xxi[i].sub[0].pan = 0x80 + (int16)read16b(f);
		if (mod->xxi[i].sub[0].pan > 0xff)
			mod->xxi[i].sub[0].pan = 0xff;
		flags = read16b(f);
		mod->xxs[snum].flg = flags & 0x03 ? XMP_SAMPLE_LOOP : 0;
		mod->xxs[snum].flg |= flags & 0x02 ? XMP_SAMPLE_LOOP_BIDIR : 0;

		c2spd_to_note(c2spd, &mod->xxi[i].sub[0].xpo, &mod->xxi[i].sub[0].fin);

		D_(D_INFO "[%2X] %-30.30s #%02X V%02x P%02x %5d",
			i, mod->xxi[i].name, snum,
			mod->xxi[i].sub[0].vol, mod->xxi[i].sub[0].pan, c2spd);
	}
}
Ejemplo n.º 25
0
static int pt3_load(struct module_data *m, FILE *f, const int start)
{
	iff_handle handle;
	char buf[20];

	LOAD_INIT();

	read32b(f);		/* FORM */
	read32b(f);		/* size */
	read32b(f);		/* MODL */

	read32b(f);		/* VERS */
	read32b(f);		/* VERS size */

	fread(buf, 1, 10, f);
	set_type(m, "%-6.6s IFFMODL", buf + 4);

	handle = iff_new();
	if (handle == NULL)
		return -1;

	/* IFF chunk IDs */
	iff_register(handle, "INFO", get_info);
	iff_register(handle, "CMNT", get_cmnt);
	iff_register(handle, "PTDT", get_ptdt);

	iff_set_quirk(handle, IFF_FULL_CHUNK_SIZE);

	/* Load IFF chunks */
	while (!feof(f))
		iff_chunk(handle, m, f, NULL);

	iff_release(handle);

	return 0;
}
Ejemplo n.º 26
0
static int dbm_load(struct module_data *m, FILE *f, const int start)
{
	struct xmp_module *mod = &m->mod;
	iff_handle handle;
	char name[44];
	uint16 version;
	int i;
	struct local_data data;

	LOAD_INIT();

	read32b(f);		/* DBM0 */

	data.have_song = 0;
	version = read16b(f);

	fseek(f, 10, SEEK_CUR);
	fread(name, 1, 44, f);

	handle = iff_new();
	if (handle == NULL)
		return -1;

	/* IFF chunk IDs */
	iff_register(handle, "INFO", get_info);
	iff_register(handle, "SONG", get_song);
	iff_register(handle, "INST", get_inst);
	iff_register(handle, "PATT", get_patt);
	iff_register(handle, "SMPL", get_smpl);
	iff_register(handle, "VENV", get_venv);

	strncpy(mod->name, name, XMP_NAME_SIZE);
	snprintf(mod->type, XMP_NAME_SIZE, "DigiBooster Pro %d.%02x DBM0",
					version >> 8, version & 0xff);
	MODULE_INFO();

	/* Load IFF chunks */
	while (!feof(f)) {
		iff_chunk(handle, m, f, &data);
	}

	iff_release(handle);

	for (i = 0; i < mod->chn; i++)
		mod->xxc[i].pan = 0x80;

	return 0;
}
Ejemplo n.º 27
0
Archivo: hio.c Proyecto: kacmem/zxtune
uint32 hio_read32b(HIO_HANDLE *h)
{
	if (HIO_HANDLE_TYPE(h) == HIO_HANDLE_TYPE_FILE) {
		return read32b(h->f);
	} else {
		ptrdiff_t can_read = CAN_READ(h);
		if (can_read >= 4) {
			uint32 n = readmem32b(h->start + h->pos);
			h->pos += 4;
			return n;
		} else {
			h->pos += can_read;
			return EOF;
		}
	}
}
static void get_emic(struct xmp_context *ctx, int size, FILE *f)
{
    struct xmp_player_context *p = &ctx->p;
    struct xmp_mod_context *m = &p->m;
    int i, ver;

    ver = read16b(f);
    fread(m->name, 1, 20, f);
    fread(m->author, 1, 20, f);
    m->xxh->bpm = read8(f);
    m->xxh->ins = read8(f);
    m->xxh->smp = m->xxh->ins;

    m->xxh->flg |= XXM_FLG_MODRNG;

    snprintf(m->type, XMP_NAMESIZE, "EMOD v%d (Quadra Composer)", ver);
    MODULE_INFO();

    INSTRUMENT_INIT();

    reportv(ctx, 1, "     Instrument name      Len  LBeg LEnd L Vol Fin\n");

    for (i = 0; i < m->xxh->ins; i++) {
	m->xxi[i] = calloc(sizeof (struct xxm_instrument), 1);

	read8(f);		/* num */
	m->xxi[i][0].vol = read8(f);
	m->xxs[i].len = 2 * read16b(f);
	fread(m->xxih[i].name, 1, 20, f);
	m->xxs[i].flg = read8(f) & 1 ? WAVE_LOOPING : 0;
	m->xxi[i][0].fin = read8(f);
	m->xxs[i].lps = 2 * read16b(f);
	m->xxs[i].lpe = m->xxs[i].lps + 2 * read16b(f);
	read32b(f);		/* ptr */

	m->xxih[i].nsm = 1;
	m->xxi[i][0].pan = 0x80;
	m->xxi[i][0].sid = i;

	if (V(1) && (strlen((char *)m->xxih[i].name) || (m->xxs[i].len > 2))) {
	    report ("[%2X] %-20.20s %05x %05x %05x %c V%02x %+d\n",
			i, m->xxih[i].name, m->xxs[i].len, m->xxs[i].lps,
			m->xxs[i].lpe, m->xxs[i].flg & WAVE_LOOPING ? 'L' : ' ',
			m->xxi[i][0].vol, m->xxi[i][0].fin >> 4);
	}
    }
Ejemplo n.º 29
0
static void get_samp(struct module_data *m, int size, xmp_file f, void *parm)
{
    struct xmp_module *mod = &m->mod;
    struct local_data *data = (struct local_data *)parm;
    int i, j;
    int looplen;

    /* Should be always 36 */
    mod->ins = size / 32;  /* sizeof(struct okt_instrument_header); */
    mod->smp = mod->ins;

    INSTRUMENT_INIT();

    for (j = i = 0; i < mod->ins; i++) {
	mod->xxi[i].sub = calloc(sizeof (struct xmp_subinstrument), 1);

	xmp_fread(mod->xxi[i].name, 1, 20, f);
	str_adj((char *)mod->xxi[i].name);

	/* Sample size is always rounded down */
	mod->xxs[i].len = read32b(f) & ~1;
	mod->xxs[i].lps = read16b(f);
	looplen = read16b(f);
	mod->xxs[i].lpe = mod->xxs[i].lps + looplen;
	mod->xxi[i].sub[0].vol = read16b(f);
	data->mode[i] = read16b(f);

	mod->xxi[i].nsm = !!(mod->xxs[i].len);
	mod->xxs[i].flg = looplen > 2 ? XMP_SAMPLE_LOOP : 0;
	mod->xxi[i].sub[0].pan = 0x80;
	mod->xxi[i].sub[0].sid = j;

	data->idx[j] = i;

	D_(D_INFO "[%2X] %-20.20s %05x %05x %05x %c V%02x M%02x\n", i,
		mod->xxi[i].name, mod->xxs[i].len, mod->xxs[i].lps,
		mod->xxs[i].lpe, mod->xxs[i].flg & XMP_SAMPLE_LOOP ? 'L' : ' ',
		mod->xxi[i].sub[0].vol, data->mode[i]);

	if (mod->xxi[i].nsm)
	    j++;
    }
}
static void get_samp(struct xmp_context *ctx, int size, FILE *f)
{
    struct xmp_player_context *p = &ctx->p;
    struct xmp_mod_context *m = &p->m;
    int i, j;
    int looplen;

    /* Should be always 36 */
    m->xxh->ins = size / 32;  /* sizeof(struct okt_instrument_header); */
    m->xxh->smp = m->xxh->ins;

    INSTRUMENT_INIT();

    reportv(ctx, 1, "     Instrument name      Len   Lbeg  Lend  L Vol Mod\n");
    for (j = i = 0; i < m->xxh->ins; i++) {
	m->xxi[i] = calloc(sizeof (struct xxm_instrument), 1);

	fread(m->xxih[i].name, 1, 20, f);
	str_adj((char *)m->xxih[i].name);

	/* Sample size is always rounded down */
	m->xxs[i].len = read32b(f) & ~1;
	m->xxs[i].lps = read16b(f);
	looplen = read16b(f);
	m->xxs[i].lpe = m->xxs[i].lps + looplen;
	m->xxi[i][0].vol = read16b(f);
	mode[i] = read16b(f);

	m->xxih[i].nsm = !!(m->xxs[i].len);
	m->xxs[i].flg = looplen > 2 ? WAVE_LOOPING : 0;
	m->xxi[i][0].pan = 0x80;
	m->xxi[i][0].sid = j;

	idx[j] = i;

	if ((V(1)) && (strlen((char *)m->xxih[i].name) || (m->xxs[i].len > 1)))
	    report ("[%2X] %-20.20s %05x %05x %05x %c V%02x M%02x\n", i,
		m->xxih[i].name, m->xxs[i].len, m->xxs[i].lps, m->xxs[i].lpe, m->xxs[i].flg
		& WAVE_LOOPING ? 'L' : ' ', m->xxi[i][0].vol, mode[i]);
	if (m->xxih[i].nsm)
	    j++;
    }
}