Mercurial > hg > dmlib
annotate jssmix.h @ 51:36e2f910219c
A non-working implementation of floating point audio mixing.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 01 Oct 2012 03:48:21 +0300 |
parents | 033c660c25f5 |
children | 8725853609db |
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 | |
51
36e2f910219c
A non-working implementation of floating point audio mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
14 #ifdef JSS_MIX_FP |
36e2f910219c
A non-working implementation of floating point audio mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
15 #define JMIXER_ADDBUF_TYPE double |
36e2f910219c
A non-working implementation of floating point audio mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
16 #else |
36e2f910219c
A non-working implementation of floating point audio mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
17 #define JMIXER_ADDBUF_TYPE Sint32 |
36e2f910219c
A non-working implementation of floating point audio mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
18 #endif |
36e2f910219c
A non-working implementation of floating point audio mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
19 |
36e2f910219c
A non-working implementation of floating point audio mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
20 |
0 | 21 // Mixing limits |
22 #define JVM_LIMIT_16_POS (32767) | |
23 #define JVM_LIMIT_16_NEG (-32767) | |
24 #define JVM_ADD_16 (32768) | |
25 | |
26 | |
27 // A channel data structure | |
28 typedef struct | |
29 { | |
30 DMFixedPoint | |
31 chPos, // Current position in sample, 32:32 fixpoint | |
32 chDeltaO; // Delta in 32:32 UNSIGNED! (chDirection) | |
33 | |
34 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
|
35 Sint32 |
0 | 36 chSize, // Length of sample in UNITS |
37 chLoopS, // Loop start in UNITS | |
38 chLoopE; // Loop end in UNITS | |
39 | |
40 void *chData; // Pointer to data | |
41 | |
42 BOOL chPlaying, // TRUE = playing | |
43 chMute, // TRUE = muted | |
44 chDirection; // TRUE = playing forwards, FALSE = backwards | |
45 | |
46 int chFlags; // Flags | |
47 int chVolume, // Volume | |
48 chPanning; // Panning | |
49 | |
51
36e2f910219c
A non-working implementation of floating point audio mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
50 JMIXER_ADDBUF_TYPE chPrevR, chPrevL; |
0 | 51 } JSSChannel; |
52 | |
53 | |
54 // Channel table | |
55 typedef int JSSChannelTable[jsetNChannels]; | |
56 | |
57 | |
58 // Virtual software mixer "device" structure | |
59 typedef struct _JSSMixer JSSMixer; | |
60 | |
61 struct _JSSMixer | |
62 { | |
63 int outFormat, | |
64 outChannels, | |
65 outFreq, | |
66 globalVol; | |
67 JSSChannel channels[jsetNChannels]; | |
68 | |
69 int addBufSize; | |
51
36e2f910219c
A non-working implementation of floating point audio mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
70 JMIXER_ADDBUF_TYPE *addBuffer; |
0 | 71 |
72 // Callback handling | |
73 int cbFreq, cbCounter; | |
74 void *cbData; | |
75 void (*cbFunction)(void *, void *); | |
76 | |
77 // Mixing routine pointers | |
51
36e2f910219c
A non-working implementation of floating point audio mixing.
Matti Hamalainen <ccr@tnsp.org>
parents:
49
diff
changeset
|
78 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
|
79 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
|
80 void (*jvmPostProcess)(JMIXER_ADDBUF_TYPE *, void *, const int); |
0 | 81 |
82 // Device locking | |
83 #ifdef JSS_SUP_THREADS | |
84 DMMutex *mutex; | |
85 #endif | |
86 }; | |
87 | |
88 | |
89 /* Enums | |
90 */ | |
91 enum { | |
92 JMIX_AUTO = 0, | |
93 JMIX_C, | |
94 JMIX_MMX, | |
95 JMIX_SSE | |
96 }; | |
97 | |
98 | |
99 /* Main routines | |
100 */ | |
101 JSSMixer * jvmInit(const int outFormat, const int nChannels, const int outFreq, const int mixerID); | |
102 int jvmClose(JSSMixer *mixer); | |
103 | |
104 int jvmSetCallback(JSSMixer *mixer, void (*cbFunction)(void *, void *), void *cbData); | |
105 void jvmRemoveCallback(JSSMixer *mixer); | |
106 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
|
107 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
|
108 Sint32 jvmGetNextCBBufPos(JSSMixer *mixer, const int cbHandle); |
0 | 109 |
110 int jvmGetSampleSize(JSSMixer *mixer); | |
111 int jvmGetSampleRes(JSSMixer *mixer); | |
112 | |
113 void jvmRenderAudio(JSSMixer *mixer, void *mixBuffer, const int mixLength); | |
114 | |
115 | |
116 /* | |
117 int jvmAddCallback(JSSMixer *mixer, void (*cbFunction)(JSSMixer *, void *)); | |
118 int jvmRemoveCallback(JSSMixer *mixer, int cbHandle); | |
119 int jvmSetCallbackFreq(JSSMixer *mixer, int cbHandle, int cbFreq); | |
120 | |
121 int jvmAllocChannels(JSSMixer *mixer, int nChannels); | |
122 int jvmFreeChannels(JSSMixer *mixer, int iHandle); | |
123 int jvmGetChannelTable(JSSMixer *mixer, int iHandle, JSSChannelTable *pTable); | |
124 */ | |
125 | |
126 | |
127 /* Channel manipulation routines | |
128 */ | |
129 void jvmPlay(JSSMixer *mixer, const int channel); | |
130 void jvmStop(JSSMixer *mixer, const int channel); | |
131 | |
132 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
|
133 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
|
134 const Sint32 loopE, const int flags); |
0 | 135 |
136 void jvmSetFreq(JSSMixer *mixer, const int channel, const int freq); | |
137 int jvmGetFreq(JSSMixer *mixer, const int channel); | |
138 void jvmSetVolume(JSSMixer *mixer, const int channel, const int volume); | |
139 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
|
140 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
|
141 Sint32 jvmGetPos(JSSMixer *mixer, const int channel); |
0 | 142 |
143 void jvmSetPan(JSSMixer *mixer, const int channel, const int panning); | |
144 int jvmGetPan(JSSMixer *mixer, const int channel); | |
145 | |
146 void jvmMute(JSSMixer *mixer, const int channel, const BOOL mute); | |
147 | |
148 void jvmClear(JSSMixer *mixer, const int channel); | |
149 void jvmClearChannels(JSSMixer *mixer); | |
150 | |
151 void jvmSetGlobalVol(JSSMixer *mixer, const int volume); | |
152 int jvmGetGlobalVol(JSSMixer *mixer); | |
153 | |
154 | |
155 #endif // JSSMIX_H |