Mercurial > SDL_sound_CoreAudio
view decoders/timidity/dls1.h @ 474:c66080364dff
Most decoders now report total sample play time, now. Technically, this
breaks binary compatibility with the 1.0 branch, since it extends the
Sound_Sample struct, but most (all?) programs are just passing pointers
allocated by SDL_sound around, and might be okay.
Source-level compatibility is not broken...yet! :)
--ryan.
-------- Original Message --------
Subject: SDL_sound patch: Finding total length of time of sound file.
Date: Sun, 26 Jan 2003 09:31:17 -0800 (PST)
Hi Ryan,
I am working with Eric Wing and helping him modify
SDL_sound. AS part of our efforts in improving and
enhancing SDL_sound, we like to submit this patch. We
modified the codecs to find the total time of a sound
file. Below is the explanation of the patch. The
patch is appended as an attachment to this email.
* MOTIVATION:
We needed the ability to get the total play time of a
sample (And we noticed that we're not the only ones).
Since SDL_sound blocks direct access to the specific
decoders, there is no way for a user to know this
information short of decoding the whole thing.
Because of this, we believe this will be a useful
addition, even though the accuracy may not be perfect
(subject to each decoder) or the information may not
always be available.
* CONTRIBUTORS:
Wesley Leong (modified the majority of the codecs and
verified the results)
Eric Wing (showed everyone how to do modify codec,
modified mikmod)
Wang Lam (modified a handful of codecs, researched
into specs and int overflow)
Ahilan Anantha (modified a few codecs and helped with
integer math)
* GENERAL ISSUES:
We chose the value to be milliseconds as an Sint32.
Milliseconds because that's what Sound_Seek takes as a
parameter and -1 to allow for instances/codecs where
the value could not be determined. We are
not sure if this is the final convention you want, so
we are willing to work with you on this.
We also expect the total_time field to be set on open
and never again modified by SDL_sound. Users may
access it directly much like the sample buffer and
buffer_size. We thought about recomputing the time
on DecodeAll, but since users may seek or decode small
chunks first, not all the data may be there. So this
is better done by the user. This may be good
information to document.
Currently, all the main codecs are implemented except
for QuickTime.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Sat, 08 May 2004 08:19:50 +0000 |
parents | cbc2a4ffeeec |
children |
line wrap: on
line source
/*==========================================================================; // // dls1.h // // // Description: // // Interface defines and structures for the Instrument Collection Form // RIFF DLS. // // // Written by Sonic Foundry 1996. Released for public use. // //=========================================================================*/ #ifndef _INC_DLS1 #define _INC_DLS1 /*////////////////////////////////////////////////////////////////////////// // // // Layout of an instrument collection: // // // RIFF [] 'DLS ' [dlid,colh,INSTLIST,WAVEPOOL,INFOLIST] // // INSTLIST // LIST [] 'lins' // LIST [] 'ins ' [dlid,insh,RGNLIST,ARTLIST,INFOLIST] // LIST [] 'ins ' [dlid,insh,RGNLIST,ARTLIST,INFOLIST] // LIST [] 'ins ' [dlid,insh,RGNLIST,ARTLIST,INFOLIST] // // RGNLIST // LIST [] 'lrgn' // LIST [] 'rgn ' [rgnh,wsmp,wlnk,ARTLIST] // LIST [] 'rgn ' [rgnh,wsmp,wlnk,ARTLIST] // LIST [] 'rgn ' [rgnh,wsmp,wlnk,ARTLIST] // // ARTLIST // LIST [] 'lart' // 'art1' level 1 Articulation connection graph // 'art2' level 2 Articulation connection graph // '3rd1' Possible 3rd party articulation structure 1 // '3rd2' Possible 3rd party articulation structure 2 .... and so on // // WAVEPOOL // ptbl [] [pool table] // LIST [] 'wvpl' // [path], // [path], // LIST [] 'wave' [dlid,RIFFWAVE] // LIST [] 'wave' [dlid,RIFFWAVE] // LIST [] 'wave' [dlid,RIFFWAVE] // LIST [] 'wave' [dlid,RIFFWAVE] // LIST [] 'wave' [dlid,RIFFWAVE] // // INFOLIST // LIST [] 'INFO' // 'icmt' 'One of those crazy comments.' // 'icop' 'Copyright (C) 1996 Sonic Foundry' // /////////////////////////////////////////////////////////////////////////*/ /*///////////////////////////////////////////////////////////////////////// // FOURCC's used in the DLS file /////////////////////////////////////////////////////////////////////////*/ #define FOURCC_DLS mmioFOURCC('D','L','S',' ') #define FOURCC_DLID mmioFOURCC('d','l','i','d') #define FOURCC_COLH mmioFOURCC('c','o','l','h') #define FOURCC_WVPL mmioFOURCC('w','v','p','l') #define FOURCC_PTBL mmioFOURCC('p','t','b','l') #define FOURCC_PATH mmioFOURCC('p','a','t','h') #define FOURCC_wave mmioFOURCC('w','a','v','e') #define FOURCC_LINS mmioFOURCC('l','i','n','s') #define FOURCC_INS mmioFOURCC('i','n','s',' ') #define FOURCC_INSH mmioFOURCC('i','n','s','h') #define FOURCC_LRGN mmioFOURCC('l','r','g','n') #define FOURCC_RGN mmioFOURCC('r','g','n',' ') #define FOURCC_RGNH mmioFOURCC('r','g','n','h') #define FOURCC_LART mmioFOURCC('l','a','r','t') #define FOURCC_ART1 mmioFOURCC('a','r','t','1') #define FOURCC_WLNK mmioFOURCC('w','l','n','k') #define FOURCC_WSMP mmioFOURCC('w','s','m','p') #define FOURCC_VERS mmioFOURCC('v','e','r','s') /*///////////////////////////////////////////////////////////////////////// // Articulation connection graph definitions /////////////////////////////////////////////////////////////////////////*/ /* Generic Sources */ #define CONN_SRC_NONE 0x0000 #define CONN_SRC_LFO 0x0001 #define CONN_SRC_KEYONVELOCITY 0x0002 #define CONN_SRC_KEYNUMBER 0x0003 #define CONN_SRC_EG1 0x0004 #define CONN_SRC_EG2 0x0005 #define CONN_SRC_PITCHWHEEL 0x0006 /* Midi Controllers 0-127 */ #define CONN_SRC_CC1 0x0081 #define CONN_SRC_CC7 0x0087 #define CONN_SRC_CC10 0x008a #define CONN_SRC_CC11 0x008b /* Generic Destinations */ #define CONN_DST_NONE 0x0000 #define CONN_DST_ATTENUATION 0x0001 #define CONN_DST_PITCH 0x0003 #define CONN_DST_PAN 0x0004 /* LFO Destinations */ #define CONN_DST_LFO_FREQUENCY 0x0104 #define CONN_DST_LFO_STARTDELAY 0x0105 /* EG1 Destinations */ #define CONN_DST_EG1_ATTACKTIME 0x0206 #define CONN_DST_EG1_DECAYTIME 0x0207 #define CONN_DST_EG1_RELEASETIME 0x0209 #define CONN_DST_EG1_SUSTAINLEVEL 0x020a /* EG2 Destinations */ #define CONN_DST_EG2_ATTACKTIME 0x030a #define CONN_DST_EG2_DECAYTIME 0x030b #define CONN_DST_EG2_RELEASETIME 0x030d #define CONN_DST_EG2_SUSTAINLEVEL 0x030e #define CONN_TRN_NONE 0x0000 #define CONN_TRN_CONCAVE 0x0001 typedef struct _DLSID { ULONG ulData1; USHORT usData2; USHORT usData3; BYTE abData4[8]; } DLSID, FAR *LPDLSID; typedef struct _DLSVERSION { DWORD dwVersionMS; DWORD dwVersionLS; } DLSVERSION, FAR *LPDLSVERSION; typedef struct _CONNECTION { USHORT usSource; USHORT usControl; USHORT usDestination; USHORT usTransform; LONG lScale; } CONNECTION, FAR *LPCONNECTION; /* Level 1 Articulation Data */ typedef struct _CONNECTIONLIST { ULONG cbSize; /* size of the connection list structure */ ULONG cConnections; /* count of connections in the list */ } CONNECTIONLIST, FAR *LPCONNECTIONLIST; /*///////////////////////////////////////////////////////////////////////// // Generic type defines for regions and instruments /////////////////////////////////////////////////////////////////////////*/ typedef struct _RGNRANGE { USHORT usLow; USHORT usHigh; } RGNRANGE, FAR * LPRGNRANGE; #define F_INSTRUMENT_DRUMS 0x80000000 typedef struct _MIDILOCALE { ULONG ulBank; ULONG ulInstrument; } MIDILOCALE, FAR *LPMIDILOCALE; /*///////////////////////////////////////////////////////////////////////// // Header structures found in an DLS file for collection, instruments, and // regions. /////////////////////////////////////////////////////////////////////////*/ #define F_RGN_OPTION_SELFNONEXCLUSIVE 0x0001 typedef struct _RGNHEADER { RGNRANGE RangeKey; /* Key range */ RGNRANGE RangeVelocity; /* Velocity Range */ USHORT fusOptions; /* Synthesis options for this range */ USHORT usKeyGroup; /* Key grouping for non simultaneous play */ /* 0 = no group, 1 up is group */ /* for Level 1 only groups 1-15 are allowed */ } RGNHEADER, FAR *LPRGNHEADER; typedef struct _INSTHEADER { ULONG cRegions; /* Count of regions in this instrument */ MIDILOCALE Locale; /* Intended MIDI locale of this instrument */ } INSTHEADER, FAR *LPINSTHEADER; typedef struct _DLSHEADER { ULONG cInstruments; /* Count of instruments in the collection */ } DLSHEADER, FAR *LPDLSHEADER; /*//////////////////////////////////////////////////////////////////////////// // definitions for the Wave link structure ////////////////////////////////////////////////////////////////////////////*/ /* **** For level 1 only WAVELINK_CHANNEL_MONO is valid **** */ /* ulChannel allows for up to 32 channels of audio with each bit position */ /* specifiying a channel of playback */ #define WAVELINK_CHANNEL_LEFT 0x0001l #define WAVELINK_CHANNEL_RIGHT 0x0002l #define F_WAVELINK_PHASE_MASTER 0x0001 typedef struct _WAVELINK { /* any paths or links are stored right after struct */ USHORT fusOptions; /* options flags for this wave */ USHORT usPhaseGroup; /* Phase grouping for locking channels */ ULONG ulChannel; /* channel placement */ ULONG ulTableIndex; /* index into the wave pool table, 0 based */ } WAVELINK, FAR *LPWAVELINK; #define POOL_CUE_NULL 0xffffffffl typedef struct _POOLCUE { ULONG ulOffset; /* Offset to the entry in the list */ } POOLCUE, FAR *LPPOOLCUE; typedef struct _POOLTABLE { ULONG cbSize; /* size of the pool table structure */ ULONG cCues; /* count of cues in the list */ } POOLTABLE, FAR *LPPOOLTABLE; /*//////////////////////////////////////////////////////////////////////////// // Structures for the "wsmp" chunk ////////////////////////////////////////////////////////////////////////////*/ #define F_WSMP_NO_TRUNCATION 0x0001l #define F_WSMP_NO_COMPRESSION 0x0002l typedef struct _rwsmp { ULONG cbSize; USHORT usUnityNote; /* MIDI Unity Playback Note */ SHORT sFineTune; /* Fine Tune in log tuning */ LONG lAttenuation; /* Overall Attenuation to be applied to data */ ULONG fulOptions; /* Flag options */ ULONG cSampleLoops; /* Count of Sample loops, 0 loops is one shot */ } WSMPL, FAR *LPWSMPL; /* This loop type is a normal forward playing loop which is continually */ /* played until the envelope reaches an off threshold in the release */ /* portion of the volume envelope */ #define WLOOP_TYPE_FORWARD 0 typedef struct _rloop { ULONG cbSize; ULONG ulType; /* Loop Type */ ULONG ulStart; /* Start of loop in samples */ ULONG ulLength; /* Length of loop in samples */ } WLOOP, FAR *LPWLOOP; #endif /*_INC_DLS1 */