annotate playercode/drv_wav.c @ 6:d14fd386d182

Initial entry of mikmod into the CVS tree.
author darius
date Fri, 23 Jan 1998 16:05:09 +0000
parents 5d614bcc4287
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
1
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
2 #include "mikmod.h"
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
3
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
4 #ifdef __GNUC__
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
5 #include <sys/types.h>
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
6 #else
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
7 #include <io.h>
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
8 #endif
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
9 #include <sys/stat.h>
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
10 #include <fcntl.h>
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
11
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
12 #define WAVBUFFERSIZE 65536
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
13
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
14 static FILE *wavout;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
15
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
16 static SBYTE *WAV_DMABUF;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
17 static ULONG dumpsize;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
18
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
19 static BOOL WAV_IsThere(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
20 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
21 return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
22 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
23
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
24
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
25 static BOOL WAV_Init(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
26 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
27 if(NULL == (wavout = fopen("music.wav", "wb"))) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
28 if(NULL == (WAV_DMABUF = _mm_malloc(WAVBUFFERSIZE))) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
29
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
30 md_mode |= DMODE_SOFT_MUSIC | DMODE_SOFT_SNDFX;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
31
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
32 if(VC_Init()) return 1;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
33
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
34 _mm_write_string("RIFF WAVEfmt ",wavout);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
35 _mm_write_I_ULONG(16,wavout); // length of this RIFF block crap
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
36
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
37 _mm_write_I_UWORD(1, wavout); // microsoft format type
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
38 _mm_write_I_UWORD((md_mode & DMODE_STEREO) ? 2 : 1, wavout);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
39 _mm_write_I_ULONG(md_mixfreq, wavout);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
40 _mm_write_I_ULONG(md_mixfreq * ((md_mode & DMODE_STEREO) ? 2 : 1) *
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
41 ((md_mode & DMODE_16BITS) ? 2 : 1), wavout);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
42
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
43 _mm_write_I_UWORD(((md_mode & DMODE_16BITS) ? 2 : 1) *
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
44 ((md_mode & DMODE_STEREO) ? 2 : 1), wavout); // block alignment (8/16 bit)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
45
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
46 _mm_write_I_UWORD((md_mode & DMODE_16BITS) ? 16 : 8,wavout);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
47
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
48 _mm_write_string("data",wavout);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
49
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
50 dumpsize = 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
51
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
52 return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
53 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
54
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
55
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
56 static void WAV_Exit(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
57 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
58 VC_Exit();
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
59
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
60 // write in the actual sizes now
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
61
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
62 if(wavout!=NULL)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
63 { _mm_fseek(wavout,4,SEEK_SET);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
64 _mm_write_I_ULONG(dumpsize + 32, wavout);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
65 _mm_fseek(wavout,40,SEEK_SET);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
66 _mm_write_I_ULONG(dumpsize, wavout);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
67
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
68 fclose(wavout);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
69
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
70 if(WAV_DMABUF != NULL) free(WAV_DMABUF);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
71 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
72 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
73
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
74
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
75 static void WAV_Update(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
76 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
77 VC_WriteBytes(WAV_DMABUF, WAVBUFFERSIZE);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
78 fwrite(WAV_DMABUF, 1, WAVBUFFERSIZE, wavout);
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
79 dumpsize += WAVBUFFERSIZE;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
80 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
81
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
82
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
83 static BOOL WAV_Reset(void)
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
84 {
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
85 return 0;
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
86 }
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
87
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
88
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
89 MDRIVER drv_wav =
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
90 { NULL,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
91 "music.wav file",
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
92 "WAV [music.wav] file output driver v1.0",
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
93 0,255,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
94 WAV_IsThere,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
95 VC_SampleLoad,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
96 VC_SampleUnload,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
97 VC_SampleSpace,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
98 VC_SampleLength,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
99 WAV_Init,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
100 WAV_Exit,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
101 WAV_Reset,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
102 VC_SetNumVoices,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
103 VC_PlayStart,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
104 VC_PlayStop,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
105 WAV_Update,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
106 VC_VoiceSetVolume,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
107 VC_VoiceSetFrequency,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
108 VC_VoiceSetPanning,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
109 VC_VoicePlay,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
110 VC_VoiceStop,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
111 VC_VoiceStopped,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
112 VC_VoiceReleaseSustain,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
113 VC_VoiceGetPosition,
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
114 NULL
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
115 };
5d614bcc4287 Initial entry of mikmod into the CVS tree.
darius
parents:
diff changeset
116