Mercurial > hg > dmlib
annotate jssmix.h @ 60:f28cd66356f6
Initial work for bitmapped fonts and text drawing. Also moved TTF header
stuff to dmtext.h.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 01 Oct 2012 09:46:56 +0300 |
parents | 2edda27f951c |
children | 1ba202b448e0 |
rev | line source |
---|---|
0 | 1 /* |
2 * miniJSS - Mixing device and channel handling | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
4 * (C) Copyright 2006-2012 Tecnic Software productions (TNSP) | |
5 */ | |
6 #ifndef JSSMIX_H | |
7 #define JSSMIX_H | |
8 #include "jss.h" | |
9 | |
10 //#define DBG(...) do { fprintf(stderr, __VA_ARGS__); } while (0) | |
11 #define DBG(...) do { /* stub */ } while (0) | |
12 | |
13 | |
14 // Mixing limits | |
15 #define JVM_LIMIT_16_POS (32767) | |
16 #define JVM_LIMIT_16_NEG (-32767) | |
17 #define JVM_ADD_16 (32768) | |
18 | |
57
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
19 |
56
8725853609db
Remove the floating point mixing .. it wasn't so good idea after all.
Matti Hamalainen <ccr@tnsp.org>
parents:
51
diff
changeset
|
20 #define JMIXER_ADDBUF_TYPE Sint32 |
8725853609db
Remove the floating point mixing .. it wasn't so good idea after all.
Matti Hamalainen <ccr@tnsp.org>
parents:
51
diff
changeset
|
21 |
0 | 22 |
23 // A channel data structure | |
24 typedef struct | |
25 { | |
26 DMFixedPoint | |
27 chPos, // Current position in sample, 32:32 fixpoint | |
28 chDeltaO; // Delta in 32:32 UNSIGNED! (chDirection) | |
29 | |
30 int chFreq; // Frequency of sampel in Hz | |
36
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
31 Sint32 |
0 | 32 chSize, // Length of sample in UNITS |
33 chLoopS, // Loop start in UNITS | |
34 chLoopE; // Loop end in UNITS | |
35 | |
36 void *chData; // Pointer to data | |
37 | |
38 BOOL chPlaying, // TRUE = playing | |
39 chMute, // TRUE = muted | |
40 chDirection; // TRUE = playing forwards, FALSE = backwards | |
41 | |
42 int chFlags; // Flags | |
43 int chVolume, // Volume | |
44 chPanning; // Panning | |
45 | |
57
2edda27f951c
Silly interpolation in mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
46 JMIXER_ADDBUF_TYPE chPrevR[5], chPrevL[5]; |
0 | 47 } JSSChannel; |
48 | |
49 | |
50 // Channel table | |
51 typedef int JSSChannelTable[jsetNChannels]; | |
52 | |
53 | |
54 // Virtual software mixer "device" structure | |
55 typedef struct _JSSMixer JSSMixer; | |
56 | |
57 struct _JSSMixer | |
58 { | |
59 int outFormat, | |
60 outChannels, | |
61 outFreq, | |
62 globalVol; | |
63 JSSChannel channels[jsetNChannels]; | |
64 | |
65 int addBufSize; | |
51
36e2f910219c
A non-working implementation of floating point audio mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
66 JMIXER_ADDBUF_TYPE *addBuffer; |
0 | 67 |
68 // Callback handling | |
69 int cbFreq, cbCounter; | |
70 void *cbData; | |
71 void (*cbFunction)(void *, void *); | |
72 | |
73 // Mixing routine pointers | |
51
36e2f910219c
A non-working implementation of floating point audio mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
74 int (*jvmMixChannel_FW)(JSSMixer *, JSSChannel *, JMIXER_ADDBUF_TYPE *, const int, const Sint32); |
36e2f910219c
A non-working implementation of floating point audio mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
75 int (*jvmMixChannel_BW)(JSSMixer *, JSSChannel *, JMIXER_ADDBUF_TYPE *, const int, const Sint32); |
36e2f910219c
A non-working implementation of floating point audio mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
76 void (*jvmPostProcess)(JMIXER_ADDBUF_TYPE *, void *, const int); |
0 | 77 |
78 // Device locking | |
79 #ifdef JSS_SUP_THREADS | |
80 DMMutex *mutex; | |
81 #endif | |
82 }; | |
83 | |
84 | |
85 /* Enums | |
86 */ | |
87 enum { | |
88 JMIX_AUTO = 0, | |
89 JMIX_C, | |
90 JMIX_MMX, | |
91 JMIX_SSE | |
92 }; | |
93 | |
94 | |
95 /* Main routines | |
96 */ | |
97 JSSMixer * jvmInit(const int outFormat, const int nChannels, const int outFreq, const int mixerID); | |
98 int jvmClose(JSSMixer *mixer); | |
99 | |
100 int jvmSetCallback(JSSMixer *mixer, void (*cbFunction)(void *, void *), void *cbData); | |
101 void jvmRemoveCallback(JSSMixer *mixer); | |
102 int jvmSetCallbackFreq(JSSMixer *mixer, const int cbFreq); | |
36
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
103 Sint32 jvmGetLastCBBufPos(JSSMixer *mixer, const int cbHandle); |
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
104 Sint32 jvmGetNextCBBufPos(JSSMixer *mixer, const int cbHandle); |
0 | 105 |
106 int jvmGetSampleSize(JSSMixer *mixer); | |
107 int jvmGetSampleRes(JSSMixer *mixer); | |
108 | |
109 void jvmRenderAudio(JSSMixer *mixer, void *mixBuffer, const int mixLength); | |
110 | |
111 | |
112 /* | |
113 int jvmAddCallback(JSSMixer *mixer, void (*cbFunction)(JSSMixer *, void *)); | |
114 int jvmRemoveCallback(JSSMixer *mixer, int cbHandle); | |
115 int jvmSetCallbackFreq(JSSMixer *mixer, int cbHandle, int cbFreq); | |
116 | |
117 int jvmAllocChannels(JSSMixer *mixer, int nChannels); | |
118 int jvmFreeChannels(JSSMixer *mixer, int iHandle); | |
119 int jvmGetChannelTable(JSSMixer *mixer, int iHandle, JSSChannelTable *pTable); | |
120 */ | |
121 | |
122 | |
123 /* Channel manipulation routines | |
124 */ | |
125 void jvmPlay(JSSMixer *mixer, const int channel); | |
126 void jvmStop(JSSMixer *mixer, const int channel); | |
127 | |
128 void jvmSetSample(JSSMixer *mixer, const int channel, | |
36
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
129 void *data, const Sint32 size, const Sint32 loopS, |
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
130 const Sint32 loopE, const int flags); |
0 | 131 |
132 void jvmSetFreq(JSSMixer *mixer, const int channel, const int freq); | |
133 int jvmGetFreq(JSSMixer *mixer, const int channel); | |
134 void jvmSetVolume(JSSMixer *mixer, const int channel, const int volume); | |
135 int jvmGetVolume(JSSMixer *mixer, const int channel); | |
36
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
136 void jvmSetPos(JSSMixer *mixer, const int channel, const Sint32 pos); |
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
137 Sint32 jvmGetPos(JSSMixer *mixer, const int channel); |
0 | 138 |
139 void jvmSetPan(JSSMixer *mixer, const int channel, const int panning); | |
140 int jvmGetPan(JSSMixer *mixer, const int channel); | |
141 | |
142 void jvmMute(JSSMixer *mixer, const int channel, const BOOL mute); | |
143 | |
144 void jvmClear(JSSMixer *mixer, const int channel); | |
145 void jvmClearChannels(JSSMixer *mixer); | |
146 | |
147 void jvmSetGlobalVol(JSSMixer *mixer, const int volume); | |
148 int jvmGetGlobalVol(JSSMixer *mixer); | |
149 | |
150 | |
151 #endif // JSSMIX_H |