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