2 Copyright © 1995-2005, The AROS Development Team. All rights reserved.
6 /**********************************************************************/
12 #include <exec/types.h>
13 #include <exec/memory.h>
14 #include <dos/dostags.h>
15 #include <intuition/imageclass.h>
16 #include <intuition/icclass.h>
17 #include <intuition/gadgetclass.h>
18 #include <intuition/cghooks.h>
19 #include <datatypes/datatypesclass.h>
20 #include <datatypes/soundclass.h>
22 #include <clib/alib_protos.h>
23 #include <proto/exec.h>
24 #include <proto/dos.h>
25 #include <proto/intuition.h>
26 #include <proto/utility.h>
27 #include <proto/iffparse.h>
28 #include <proto/datatypes.h>
30 #include <aros/symbolsets.h>
38 ADD2LIBS("datatypes/sound.datatype", 0, struct Library
*, SoundBase
);
40 /**************************************************************************************************/
42 struct FileVoiceHeader
44 UBYTE vh_OneShotHiSamples
[4];
45 UBYTE vh_RepeatHiSamples
[4];
46 UBYTE vh_SamplesPerHiCycle
[4];
47 UBYTE vh_SamplesPerSec
[2];
53 /**************************************************************************************************/
55 static LONG propchunks
[] =
60 /**************************************************************************************************/
61 /**************************************************************************************************/
63 BOOL
Read8SVX(Class
*cl
, Object
*o
)
66 struct FileVoiceHeader
*file_vhd
;
67 struct VoiceHeader
*vhd
;
68 struct IFFHandle
*handle
;
69 struct StoredProperty
*vhdr_prop
;
70 struct ContextNode
*cn
;
77 D(bug("8svx.datatype/Read8SVX()\n"));
79 if (GetDTAttrs(o
, DTA_SourceType
, (IPTR
)&sourcetype
,
80 DTA_Handle
, (IPTR
)&handle
,
81 SDTA_VoiceHeader
, (IPTR
)&vhd
,
84 SetIoErr(ERROR_OBJECT_NOT_FOUND
);
88 if ((sourcetype
!= DTST_FILE
) && (sourcetype
!= DTST_CLIPBOARD
))
90 SetIoErr(ERROR_OBJECT_NOT_FOUND
);
96 SetIoErr(ERROR_OBJECT_NOT_FOUND
);
100 if (PropChunks(handle
, propchunks
, 3) != 0)
102 SetIoErr(ERROR_NO_FREE_STORE
);
103 D(bug("8svx.datatype error propchunks\n"));
107 if (StopChunk(handle
, ID_8SVX
, ID_BODY
) != 0)
109 SetIoErr(ERROR_NO_FREE_STORE
);
110 D(bug("8svx.datatype error stopchunks\n"));
114 error
= ParseIFF(handle
, IFFPARSE_SCAN
);
117 SetIoErr(ERROR_OBJECT_WRONG_TYPE
);
118 D(bug("8svx.datatype error parseiff\n"));
122 vhdr_prop
= FindProp(handle
, ID_8SVX
, ID_VHDR
);
124 cn
= CurrentChunk(handle
);
125 if ((cn
->cn_Type
!= ID_8SVX
) ||
126 (cn
->cn_ID
!= ID_BODY
) ||
129 SetIoErr(ERROR_REQUIRED_ARG_MISSING
);
130 D(bug("8svx.datatype error currentchunk\n"));
134 file_vhd
= (struct FileVoiceHeader
*)vhdr_prop
->sp_Data
;
135 vhd
->vh_OneShotHiSamples
= file_vhd
->vh_OneShotHiSamples
[0] * 0x1000000 +
136 file_vhd
->vh_OneShotHiSamples
[1] * 0x10000 +
137 file_vhd
->vh_OneShotHiSamples
[2] * 0x100 +
138 file_vhd
->vh_OneShotHiSamples
[3];
139 vhd
->vh_RepeatHiSamples
= file_vhd
->vh_RepeatHiSamples
[0] * 0x1000000 +
140 file_vhd
->vh_RepeatHiSamples
[1] * 0x10000 +
141 file_vhd
->vh_RepeatHiSamples
[2] * 0x100 +
142 file_vhd
->vh_RepeatHiSamples
[3];
143 vhd
->vh_SamplesPerHiCycle
= file_vhd
->vh_SamplesPerHiCycle
[0] * 0x1000000 +
144 file_vhd
->vh_SamplesPerHiCycle
[1] * 0x10000 +
145 file_vhd
->vh_SamplesPerHiCycle
[2] * 0x100 +
146 file_vhd
->vh_SamplesPerHiCycle
[3];
147 vhd
->vh_SamplesPerSec
= file_vhd
->vh_SamplesPerSec
[0] * 0x100 +
148 file_vhd
->vh_SamplesPerSec
[1];
149 vhd
->vh_Octaves
= file_vhd
->vh_Octaves
;
150 vhd
->vh_Compression
= file_vhd
->vh_Compression
;
151 vhd
->vh_Volume
= file_vhd
->vh_Volume
[0] * 0x1000000 +
152 file_vhd
->vh_Volume
[1] * 0x10000 +
153 file_vhd
->vh_Volume
[2] * 0x100 +
154 file_vhd
->vh_Volume
[3];
156 D(bug("8svx.datatype: OneShotHiSamples : %d\n"
157 " RepeatHiSampoles : %d\n"
158 " SamplesPerHiCycle: %d\n"
159 " SamplesPerSec : %d\n"
161 " Compression : %d\n"
163 vhd
->vh_OneShotHiSamples
,
164 vhd
->vh_RepeatHiSamples
,
165 vhd
->vh_SamplesPerHiCycle
,
166 vhd
->vh_SamplesPerSec
,
171 if (vhd
->vh_Compression
!= 0)
173 SetIoErr(ERROR_NOT_IMPLEMENTED
);
177 D(bug("8svx.datatype: BODY chunk size %d\n", cn
->cn_Size
));
179 samplesize
= vhd
->vh_OneShotHiSamples
+ vhd
->vh_RepeatHiSamples
;
181 if (samplesize
> cn
->cn_Size
)
183 SetIoErr(ERROR_BAD_NUMBER
);
187 sample
= AllocVec(samplesize
, MEMF_PUBLIC
);
190 SetIoErr(ERROR_NO_FREE_STORE
);
194 if (ReadChunkBytes(handle
, sample
, samplesize
) != samplesize
)
197 SetIoErr(ERROR_UNKNOWN
);
201 SetDTAttrs(o
, NULL
, NULL
, DTA_ObjName
, (IPTR
)"Unknown",
202 SDTA_Sample
, (IPTR
)sample
,
203 SDTA_SampleLength
, samplesize
,
204 SDTA_Period
, 709379 * 5 / vhd
->vh_SamplesPerSec
,
212 /**************************************************************************************************/
214 IPTR
EIGHTSVX__OM_NEW(Class
*cl
, Object
*o
, struct opSet
*msg
)
218 retval
= DoSuperMethodA(cl
, o
, (Msg
)msg
);
221 if (!Read8SVX(cl
, (Object
*)retval
))
223 CoerceMethod(cl
, (Object
*)retval
, OM_DISPOSE
);
231 /**************************************************************************************************/