1 /*  _______         ____    __         ___    ___
2  * \    _  \       \    /  \  /       \   \  /   /       '   '  '
3  *  |  | \  \       |  |    ||         |   \/   |         .      .
4  *  |  |  |  |      |  |    ||         ||\  /|  |
5  *  |  |  |  |      |  |    ||         || \/ |  |         '  '  '
6  *  |  |  |  |      |  |    ||         ||    |  |         .      .
7  *  |  |_/  /        \  \__//          ||    |  |
8  * /_______/ynamic    \____/niversal  /__\  /____\usic   /|  .  . ibliotheque
9  *                                                      /  \
10  *                                                     / .  \
11  * readriff.c - Code to read a RIFF module file       / / \  \
12  *              from memory.                         | <  /   \_
13  *                                                   |  \/ /\   /
14  *                                                    \_  /  > /
15  * By Chris Moeller.                                    | \ / /
16  *                                                      |  ' /
17  *                                                       \__/
18  */
19 
20 #include "dumb.h"
21 #include "internal/it.h"
22 #include "internal/riff.h"
23 
24 
25 DUH *dumb_read_riff_amff( DUMBFILE * f, struct riff * stream );
26 DUH *dumb_read_riff_am( DUMBFILE * f, struct riff * stream );
psm_sample_compare(const void * e1,const void * e2)27 DUH *dumb_read_riff_dsmf( DUMBFILE * f, struct riff * stream );
28 
29 /* dumb_read_riff_quick(): reads a RIFF file into a DUH struct, returning a
30  * pointer to the DUH struct. When you have finished with it, you must pass
31  * the pointer to unload_duh() so that the memory can be freed.
32  */
33 DUH *DUMBEXPORT dumb_read_riff_quick( DUMBFILE * f )
34 {
35 	DUH * duh;
it_old_psm_read_samples(IT_SAMPLE ** sample,DUMBFILE * f,int * num)36 	struct riff * stream;
37     long size;
38 
39     size = dumbfile_get_size(f);
40 
41     stream = riff_parse( f, 0, size, 1 );
42     if ( ! stream ) stream = riff_parse( f, 0, size, 0 );
43 
44 	if ( ! stream ) return 0;
45 
46 	if ( stream->type == DUMB_ID( 'A', 'M', ' ', ' ' ) )
47         duh = dumb_read_riff_am( f, stream );
48 	else if ( stream->type == DUMB_ID( 'A', 'M', 'F', 'F' ) )
49         duh = dumb_read_riff_amff( f, stream );
50 	else if ( stream->type == DUMB_ID( 'D', 'S', 'M', 'F' ) )
51         duh = dumb_read_riff_dsmf( f, stream );
52 	else duh = 0;
53 
54 	riff_free( stream );
55 
56 	return duh;
57 }
58