Mercurial > ~darius > hgwebdir.cgi > mikmod
comparison playercode/drv_wav_v2.c @ 9:990c9dadb348
Initial revision
author | darius |
---|---|
date | Fri, 23 Jan 1998 16:05:10 +0000 |
parents | |
children | 437e8455d862 |
comparison
equal
deleted
inserted
replaced
8:b30908f9d9f9 | 9:990c9dadb348 |
---|---|
1 | |
2 #include "mikmod.h" | |
3 | |
4 #ifdef __GNUC__ | |
5 #include <sys/types.h> | |
6 #else | |
7 #include <io.h> | |
8 #endif | |
9 #include <sys/stat.h> | |
10 #include <fcntl.h> | |
11 | |
12 #define WAVBUFFERSIZE 65536 | |
13 | |
14 static FILE *wavout; | |
15 | |
16 static SBYTE *WAV_DMABUF; | |
17 static ULONG dumpsize; | |
18 | |
19 static BOOL WAV_IsThere(void) | |
20 { | |
21 return 1; | |
22 } | |
23 | |
24 | |
25 static BOOL WAV_Init(void) | |
26 { | |
27 if(NULL == (wavout = fopen("music.wav", "wb"))) return 1; | |
28 if(NULL == (WAV_DMABUF = _mm_malloc(WAVBUFFERSIZE))) return 1; | |
29 | |
30 md_mode |= DMODE_SOFT_MUSIC | DMODE_SOFT_SNDFX; | |
31 | |
32 if(VC2_Init()) return 1; | |
33 | |
34 _mm_write_string("RIFF WAVEfmt ",wavout); | |
35 _mm_write_I_ULONG(16,wavout); // length of this RIFF block crap | |
36 | |
37 _mm_write_I_UWORD(1, wavout); // microsoft format type | |
38 _mm_write_I_UWORD((md_mode & DMODE_STEREO) ? 2 : 1, wavout); | |
39 _mm_write_I_ULONG(md_mixfreq, wavout); | |
40 _mm_write_I_ULONG(md_mixfreq * ((md_mode & DMODE_STEREO) ? 2 : 1) * | |
41 ((md_mode & DMODE_16BITS) ? 2 : 1), wavout); | |
42 | |
43 _mm_write_I_UWORD(((md_mode & DMODE_16BITS) ? 2 : 1) * | |
44 ((md_mode & DMODE_STEREO) ? 2 : 1), wavout); // block alignment (8/16 bit) | |
45 | |
46 _mm_write_I_UWORD((md_mode & DMODE_16BITS) ? 16 : 8,wavout); | |
47 | |
48 _mm_write_string("data",wavout); | |
49 | |
50 dumpsize = 0; | |
51 | |
52 return 0; | |
53 } | |
54 | |
55 | |
56 static void WAV_Exit(void) | |
57 { | |
58 VC2_Exit(); | |
59 | |
60 // write in the actual sizes now | |
61 | |
62 if(wavout!=NULL) | |
63 { _mm_fseek(wavout,4,SEEK_SET); | |
64 _mm_write_I_ULONG(dumpsize + 32, wavout); | |
65 _mm_fseek(wavout,40,SEEK_SET); | |
66 _mm_write_I_ULONG(dumpsize, wavout); | |
67 | |
68 fclose(wavout); | |
69 | |
70 if(WAV_DMABUF != NULL) free(WAV_DMABUF); | |
71 } | |
72 } | |
73 | |
74 | |
75 static void WAV_Update(void) | |
76 { | |
77 VC2_WriteBytes(WAV_DMABUF, WAVBUFFERSIZE); | |
78 fwrite(WAV_DMABUF, 1, WAVBUFFERSIZE, wavout); | |
79 dumpsize += WAVBUFFERSIZE; | |
80 } | |
81 | |
82 | |
83 static BOOL WAV_Reset(void) | |
84 { | |
85 return 0; | |
86 } | |
87 | |
88 | |
89 MDRIVER drv_wav = | |
90 { NULL, | |
91 "music.wav file", | |
92 "WAV [music.wav] file output driver v1.0", | |
93 0,255, | |
94 WAV_IsThere, | |
95 VC2_SampleLoad, | |
96 VC2_SampleUnload, | |
97 VC2_SampleSpace, | |
98 VC2_SampleLength, | |
99 WAV_Init, | |
100 WAV_Exit, | |
101 WAV_Reset, | |
102 VC2_SetNumVoices, | |
103 VC2_PlayStart, | |
104 VC2_PlayStop, | |
105 WAV_Update, | |
106 VC2_VoiceSetVolume, | |
107 VC2_VoiceSetFrequency, | |
108 VC2_VoiceSetPanning, | |
109 VC2_VoicePlay, | |
110 VC2_VoiceStop, | |
111 VC2_VoiceStopped, | |
112 VC2_VoiceReleaseSustain, | |
113 VC2_VoiceGetPosition, | |
114 NULL | |
115 }; | |
116 |