annotate playercode/drv_wav_v2.c @ 11:d5cb2cfc8eca

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