Mercurial > hg > dmlib
annotate jssmix.h @ 47:1936fc1a6c18
Renamed again, bah.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 01 Oct 2012 01:18:28 +0300 |
parents | f3407a58e01e |
children | 033c660c25f5 |
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 | |
19 | |
20 // A channel data structure | |
21 typedef struct | |
22 { | |
23 DMFixedPoint | |
24 chPos, // Current position in sample, 32:32 fixpoint | |
25 chDeltaO; // Delta in 32:32 UNSIGNED! (chDirection) | |
26 | |
27 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
|
28 Sint32 |
0 | 29 chSize, // Length of sample in UNITS |
30 chLoopS, // Loop start in UNITS | |
31 chLoopE; // Loop end in UNITS | |
32 | |
33 void *chData; // Pointer to data | |
34 | |
35 BOOL chPlaying, // TRUE = playing | |
36 chMute, // TRUE = muted | |
37 chDirection; // TRUE = playing forwards, FALSE = backwards | |
38 | |
39 int chFlags; // Flags | |
40 int chVolume, // Volume | |
41 chPanning; // Panning | |
42 | |
43 Sint32 chPrevR, chPrevL; | |
44 } JSSChannel; | |
45 | |
46 | |
47 // Channel table | |
48 typedef int JSSChannelTable[jsetNChannels]; | |
49 | |
50 typedef Sint32 JSSVolumeTable[256][256]; | |
51 | |
52 | |
53 // Virtual software mixer "device" structure | |
54 typedef struct _JSSMixer JSSMixer; | |
55 | |
56 struct _JSSMixer | |
57 { | |
58 int outFormat, | |
59 outChannels, | |
60 outFreq, | |
61 globalVol; | |
62 JSSChannel channels[jsetNChannels]; | |
63 JSSVolumeTable volTab8; | |
64 | |
65 int addBufSize; | |
66 Sint32 *addBuffer; | |
67 | |
68 // Callback handling | |
69 int cbFreq, cbCounter; | |
70 void *cbData; | |
71 void (*cbFunction)(void *, void *); | |
72 | |
73 // Mixing routine pointers | |
36
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
74 int (*jvmMixChannel_FW)(JSSMixer *, JSSChannel *, Sint32 *, const int, const Sint32); |
f3407a58e01e
Change DMFixedPoint types and appropriate JSS functions back to using signed
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
75 int (*jvmMixChannel_BW)(JSSMixer *, JSSChannel *, Sint32 *, const int, const Sint32); |
0 | 76 void (*jvmPostProcess)(Sint32 *, void *mixBuffer, int); |
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 |