Mercurial > hg > dmlib
annotate minijss/jssmod.c @ 2279:fc58f62f100c
Bump copyright years.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 18 Jun 2019 12:12:58 +0300 |
parents | 40ccc09f09be |
children | 167ec99e57a5 |
rev | line source |
---|---|
0 | 1 /* |
2 * miniJSS - Module structure and handling routines | |
3 * Programmed and designed by Matti 'ccr' Hamalainen | |
2279 | 4 * (C) Copyright 2006-2019 Tecnic Software productions (TNSP) |
0 | 5 */ |
6 #include "jssmod.h" | |
7 | |
8 | |
9 #ifndef JSS_LIGHT | |
948 | 10 |
11 /* Take given data until maxlen reached, make a string. | |
12 * Basically a bit like strndup(), except end marker byte | |
13 * can be specified. | |
0 | 14 */ |
948 | 15 char *jssASCIItoStr(const char * src, const char endByte, const size_t len) |
0 | 16 { |
17 size_t i, k; | |
18 char *res; | |
19 | |
1401
aaed8fa9a11f
Fix jssASCIItoStr() bounds check.
Matti Hamalainen <ccr@tnsp.org>
parents:
1238
diff
changeset
|
20 for (i = 0; src[i] != endByte && i < len; ) |
aaed8fa9a11f
Fix jssASCIItoStr() bounds check.
Matti Hamalainen <ccr@tnsp.org>
parents:
1238
diff
changeset
|
21 i++; |
0 | 22 |
948 | 23 if ((res = dmMalloc(i + 1)) == NULL) |
0 | 24 return NULL; |
25 | |
948 | 26 for (k = 0; src[k] != endByte && k < i; k++) |
27 res[k] = src[k]; | |
0 | 28 |
29 res[k] = 0; | |
30 | |
31 return res; | |
32 } | |
33 | |
34 | |
35 /* Encodes a given 8-bit sample | |
36 */ | |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
37 int jssEncodeSample8(Uint8 * data, const size_t len, const int ops) |
0 | 38 { |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
39 Sint8 value = 0; |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
40 |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
41 for (size_t offs = 0; offs < len; offs++) |
0 | 42 { |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
43 Sint8 t = data[offs]; |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
44 |
0 | 45 if (ops & jsampFlipSign) |
46 t ^= 0x80; | |
47 | |
48 if (ops & jsampDelta) | |
49 { | |
50 int n = t - value; | |
51 value = t; | |
52 t = n; | |
53 } | |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
54 |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
55 data[offs] = t; |
0 | 56 } |
57 | |
1974
f9fd6b4d29f2
Return correct value from jssEncodeSample8().
Matti Hamalainen <ccr@tnsp.org>
parents:
1973
diff
changeset
|
58 return DMERR_OK; |
0 | 59 } |
60 | |
61 | |
62 /* Decodes a given 16-bit sample | |
63 */ | |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
64 int jssEncodeSample16(Uint16 * data, const size_t len, const int ops) |
0 | 65 { |
66 // "Split" the 16-bit samples into 8-bit halves | |
67 if (ops & jsampSplit) | |
68 { | |
69 // Allocate temporary processing buffer | |
70 Uint8 *bp1, *bp2; | |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
71 size_t bufSize = len * sizeof(Sint16); |
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
72 Sint16 *tmpBuf; |
0 | 73 |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
74 if ((tmpBuf = dmMalloc(bufSize)) == NULL) |
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
75 return DMERR_MALLOC; |
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
76 |
43 | 77 bp1 = (Uint8 *) data; |
78 bp2 = bp1 + len; | |
0 | 79 |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
80 for (size_t offs = 0; offs < len; offs++) |
0 | 81 { |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
82 const Sint16 t = tmpBuf[offs]; |
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
83 bp1[offs] = t >> 8; |
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
84 bp2[offs] = t & 0xff; |
0 | 85 } |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
86 |
43 | 87 memcpy(data, tmpBuf, bufSize); |
0 | 88 dmFree(tmpBuf); |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
89 |
43 | 90 return jssEncodeSample8((Uint8 *) data, bufSize, ops); |
0 | 91 } |
92 else | |
93 { | |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
94 Sint16 value = 0, *sdata = (Sint16 *) data; |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
95 |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
96 for (size_t offs = 0; offs < len; offs++) |
0 | 97 { |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
98 Sint16 t; |
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
99 |
0 | 100 if (ops & jsampSwapEndianess) |
101 { | |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
102 const Sint16 p = sdata[offs]; |
0 | 103 t = ((p >> 8) & 0xff) | ((p & 0xff) << 8); |
743 | 104 } |
105 else | |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
106 t = sdata[offs]; |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
107 |
0 | 108 if (ops & jsampDelta) |
109 { | |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
110 const int n = t - value; |
0 | 111 value = t; |
112 t = n; | |
113 } | |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
114 |
0 | 115 if (ops & jsampFlipSign) |
116 t ^= 0x8000; | |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
117 |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
118 sdata[offs] = t; |
0 | 119 } |
120 } | |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
121 |
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
122 return DMERR_OK; |
0 | 123 } |
44
064d1d1d5b0f
Add new functions, jssConvertSampleFromFP() and jssConvertSampleToFP().
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
124 |
0 | 125 #endif |
126 | |
127 | |
128 /* Decodes a given 8-bit sample | |
129 */ | |
1129
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
130 int jssDecodeSample8(Uint8 * data, const size_t len, const int ops) |
0 | 131 { |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
132 Sint8 value = 0; |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
133 |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
134 for (size_t offs = 0; offs < len; offs++) |
0 | 135 { |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
136 Sint8 t = data[offs]; |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
137 |
0 | 138 if (ops & jsampDelta) |
139 t = value = t + value; | |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
140 |
0 | 141 if (ops & jsampFlipSign) |
142 t ^= 0x80; | |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
143 |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
144 data[offs] = t; |
0 | 145 } |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
146 |
1129
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
147 return DMERR_OK; |
0 | 148 } |
149 | |
150 | |
151 /* Decodes a given 16-bit sample | |
152 */ | |
1129
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
153 int jssDecodeSample16(Uint16 * data, const size_t len, const int ops) |
0 | 154 { |
155 if (ops & jsampSplit) | |
156 { | |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
157 size_t bufSize = len * sizeof(Uint16); |
0 | 158 Uint8 *bp1, *bp2; |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
159 Sint16 *tmpBuf; |
1129
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
160 int ret; |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
161 |
1129
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
162 if ((ret = jssDecodeSample8((Uint8 *) data, bufSize, ops)) != DMERR_OK) |
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
163 return ret; |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
164 |
1129
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
165 if ((tmpBuf = dmMalloc(bufSize)) == NULL) |
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
166 return DMERR_MALLOC; |
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
167 |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
168 // Copy original data to temporary buffer |
43 | 169 memcpy(tmpBuf, data, bufSize); |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
170 |
0 | 171 bp1 = (Uint8 *) tmpBuf; |
43 | 172 bp2 = bp1 + len; |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
173 |
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
174 for (size_t offs = 0; offs < len; offs++) |
0 | 175 { |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
176 data[offs] = (bp1[offs] << 8) | (bp2[offs] & 0xff); |
0 | 177 } |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
178 |
0 | 179 dmFree(tmpBuf); |
180 } | |
181 else | |
182 { | |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
183 Sint16 value = 0, *sdata = (Sint16 *) data; |
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
184 |
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
185 for (size_t offs = 0; offs < len; offs++) |
0 | 186 { |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
187 Sint16 t; |
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
188 |
0 | 189 if (ops & jsampSwapEndianess) |
190 { | |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
191 const Sint16 p = sdata[offs]; |
0 | 192 t = ((p >> 8) & 0xff) | ((p & 0xff) << 8); |
743 | 193 } |
194 else | |
1997
2f8506171064
Fix a stupid bug left over from the sample conversion refactor.
Matti Hamalainen <ccr@tnsp.org>
parents:
1974
diff
changeset
|
195 t = sdata[offs]; |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
196 |
0 | 197 if (ops & jsampDelta) |
198 t = value = t + value; | |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
199 |
0 | 200 if (ops & jsampFlipSign) |
201 t ^= 0x8000; | |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
202 |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
203 sdata[offs] = t; |
0 | 204 } |
205 } | |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
206 |
1129
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
207 return DMERR_OK; |
0 | 208 } |
209 | |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
210 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
211 /* Convert sample data from U8 to S16 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
212 */ |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
213 int jssConvertSampleTo16(void **dst, void * src, const size_t len) |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
214 { |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
215 Uint8 *in = (Uint8 *) src; |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
216 Sint16 *out; |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
217 |
1129
e466d10dae6d
Change API of jssDecodeSample{8,16}() functions to return dmlib error codes
Matti Hamalainen <ccr@tnsp.org>
parents:
1127
diff
changeset
|
218 if ((*dst = out = dmMalloc(sizeof(Sint16) * len)) == NULL) |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
219 return DMERR_MALLOC; |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
220 |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
221 for (size_t offs = 0; offs < len; offs++) |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
222 { |
1972
cedb5ca1533b
Clean up the sample conversion code a bit. Improve error handling in xm2jss.
Matti Hamalainen <ccr@tnsp.org>
parents:
1403
diff
changeset
|
223 out[offs] = (in[offs] * 256) - 32768; |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
224 } |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
225 |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
226 return DMERR_OK; |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
227 } |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
228 |
743 | 229 |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
230 /* Converts the given module in preparation for playing it. |
56
8725853609db
Remove the floating point mixing .. it wasn't so good idea after all.
Matti Hamalainen <ccr@tnsp.org>
parents:
51
diff
changeset
|
231 * This involves sample format conversion (8 to 16 bit, etc.) |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
232 * |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
233 * NOTICE! The converted module can only be saved in JSSMOD |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
234 * format, but this is not recommended. |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
235 */ |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
236 int jssConvertModuleForPlaying(JSSModule *module) |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
237 { |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
238 if (module == NULL) |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
239 return DMERR_NULLPTR; |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
240 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
241 // Convert instruments |
1403 | 242 for (int i = 0; i < module->ninstruments; i++) |
49
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
243 { |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
244 JSSInstrument *inst = module->instruments[i]; |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
245 if (inst != NULL && inst->data != NULL) |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
246 { |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
247 int res; |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
248 void *data = NULL; |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
249 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
250 if (inst->flags & jsf16bit) |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
251 continue; |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
252 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
253 if ((res = jssConvertSampleTo16(&data, inst->data, inst->size)) != DMERR_OK) |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
254 return res; |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
255 |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
256 inst->flags |= jsf16bit; |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
257 dmFree(inst->data); |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
258 inst->data = data; |
033c660c25f5
Restructure module playing, removing 8bit sample mixing (output can still be
Matti Hamalainen <ccr@tnsp.org>
parents:
44
diff
changeset
|
259 } |
44
064d1d1d5b0f
Add new functions, jssConvertSampleFromFP() and jssConvertSampleToFP().
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
260 } |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
261 |
44
064d1d1d5b0f
Add new functions, jssConvertSampleFromFP() and jssConvertSampleToFP().
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
262 return DMERR_OK; |
064d1d1d5b0f
Add new functions, jssConvertSampleFromFP() and jssConvertSampleToFP().
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
263 } |
064d1d1d5b0f
Add new functions, jssConvertSampleFromFP() and jssConvertSampleToFP().
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
264 |
064d1d1d5b0f
Add new functions, jssConvertSampleFromFP() and jssConvertSampleToFP().
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
265 |
0 | 266 /* Allocates a new module structure or returns errorvalue if failed. |
267 * Memory is allocated only for the basic structure. Sample- and pattern | |
268 * areas must be allocated separately with appropriate routines. | |
269 */ | |
270 JSSModule *jssAllocateModule(void) | |
271 { | |
272 JSSModule *module; | |
273 | |
274 // Allocate module structure | |
275 module = dmMalloc0(sizeof(JSSModule)); | |
276 if (module == NULL) | |
277 return NULL; | |
278 | |
279 // Initialize structure | |
1403 | 280 for (int i = 0; i < jsetNChannels; i++) |
0 | 281 module->defPanning[i] = jchPanMiddle; |
282 | |
1403 | 283 for (int i = 0; i < jsetMaxOrders; i++) |
0 | 284 module->orderList[i] = jsetOrderEnd; |
285 | |
286 // Allocate mutex | |
287 #ifdef JSS_SUP_THREADS | |
288 module->mutex = dmCreateMutex(); | |
289 #endif | |
290 | |
291 return module; | |
292 } | |
293 | |
294 | |
295 /* Frees a given module structure, freeing all memory areas | |
296 * that were allocated for it (including patterns, samples, etc.) | |
297 */ | |
298 int jssFreeModule(JSSModule * module) | |
299 { | |
300 if (module == NULL) | |
301 return DMERR_NULLPTR; | |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
302 |
0 | 303 // Free strings |
304 #ifndef JSS_LIGHT | |
305 dmFree(module->moduleName); | |
306 dmFree(module->trackerName); | |
307 #endif | |
308 | |
309 // Free patterns | |
1403 | 310 for (int i = 0; i < module->npatterns; i++) |
1227
a4a9ce298cdd
Simplify jssFreeModule() by using jssFree*() functions for freeing parts of
Matti Hamalainen <ccr@tnsp.org>
parents:
1224
diff
changeset
|
311 jssFreePattern(module->patterns[i]); |
0 | 312 |
286
a17e54015bd9
Fix a small memory leak, the special "empty" pattern was not being freed.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
313 // Free the "empty" pattern |
1227
a4a9ce298cdd
Simplify jssFreeModule() by using jssFree*() functions for freeing parts of
Matti Hamalainen <ccr@tnsp.org>
parents:
1224
diff
changeset
|
314 jssFreePattern(module->patterns[jsetMaxPatterns]); |
286
a17e54015bd9
Fix a small memory leak, the special "empty" pattern was not being freed.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
315 |
0 | 316 // Free instruments |
1403 | 317 for (int i = 0; i < module->ninstruments; i++) |
1227
a4a9ce298cdd
Simplify jssFreeModule() by using jssFree*() functions for freeing parts of
Matti Hamalainen <ccr@tnsp.org>
parents:
1224
diff
changeset
|
318 jssFreeInstrument(module->instruments[i]); |
0 | 319 |
320 // Free extended instruments | |
1403 | 321 for (int i = 0; i < module->nextInstruments; i++) |
1227
a4a9ce298cdd
Simplify jssFreeModule() by using jssFree*() functions for freeing parts of
Matti Hamalainen <ccr@tnsp.org>
parents:
1224
diff
changeset
|
322 jssFreeExtInstrument(module->extInstruments[i]); |
0 | 323 |
324 // Free mutex | |
325 #ifdef JSS_SUP_THREADS | |
326 dmDestroyMutex(module->mutex); | |
327 #endif | |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
328 |
0 | 329 // Free the module structure |
1167 | 330 dmMemset(module, 0, sizeof(JSSModule)); |
0 | 331 dmFree(module); |
332 | |
333 return DMERR_OK; | |
334 } | |
335 | |
336 | |
337 /* Allocates and initializes a internal pattern structure. | |
338 */ | |
743 | 339 JSSPattern *jssAllocatePattern(const int nrows, const int nchannels) |
0 | 340 { |
1222 | 341 JSSPattern *pattern; |
0 | 342 JSSNote *pnote; |
343 | |
344 // Check arguments | |
345 if (nrows <= 0 || nchannels <= 0) | |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1997
diff
changeset
|
346 JSSERROR(DMERR_INVALID_ARGS, NULL, "Invalid nrows=%d or nchannels=%d.\n", nrows, nchannels); |
0 | 347 |
348 // Allocate a pattern structure | |
1222 | 349 if ((pattern = dmMalloc0(sizeof(JSSPattern))) == NULL) |
0 | 350 JSSERROR(DMERR_MALLOC, NULL, "Could not allocate pattern structure.\n"); |
351 | |
352 // Allocate notedata | |
1238 | 353 pattern->data = dmMalloc(nrows * nchannels * sizeof(JSSNote)); |
1222 | 354 if (pattern->data == NULL) |
0 | 355 { |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1997
diff
changeset
|
356 jssFreePattern(pattern); |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1997
diff
changeset
|
357 JSSERROR(DMERR_MALLOC, NULL, "Could not allocate pattern data (nrows=%d, nchannels=%d).\n", |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1997
diff
changeset
|
358 nrows, nchannels); |
0 | 359 } |
360 | |
1238 | 361 // Initialize structure |
362 pattern->nrows = nrows; | |
1222 | 363 pattern->nchannels = nchannels; |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1997
diff
changeset
|
364 pattern->nmap = nchannels; |
0 | 365 |
1222 | 366 pnote = pattern->data; |
1403 | 367 for (int row = 0; row < nrows; row++) |
368 for (int chn = 0; chn < nchannels; chn++) | |
0 | 369 { |
1403 | 370 pnote->note = pnote->instrument = pnote->volume = |
371 pnote->effect = pnote->param = jsetNotSet; | |
0 | 372 |
1403 | 373 pnote++; |
0 | 374 } |
375 | |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1997
diff
changeset
|
376 // Initialize pattern channel map |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1997
diff
changeset
|
377 pattern->map = dmMalloc(nchannels * sizeof(pattern->map[0])); |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1997
diff
changeset
|
378 pattern->used = dmMalloc(nchannels * sizeof(pattern->used[0])); |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1997
diff
changeset
|
379 if (pattern->map == NULL || pattern->used == NULL) |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1997
diff
changeset
|
380 { |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1997
diff
changeset
|
381 jssFreePattern(pattern); |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1997
diff
changeset
|
382 JSSERROR(DMERR_MALLOC, NULL, "Could not allocate pattern map (nchannels=%d).\n", |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1997
diff
changeset
|
383 nchannels); |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1997
diff
changeset
|
384 } |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1997
diff
changeset
|
385 |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1997
diff
changeset
|
386 for (int chn = 0; chn < nchannels; chn++) |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1997
diff
changeset
|
387 pattern->map[chn] = chn; |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1997
diff
changeset
|
388 |
1222 | 389 return pattern; |
390 } | |
1224
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
391 |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
392 |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
393 void jssFreePattern(JSSPattern *pattern) |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
394 { |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
395 if (pattern != NULL) |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
396 { |
2278
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1997
diff
changeset
|
397 dmFree(pattern->used); |
40ccc09f09be
Implement empty channel removal in xm2jss and make JSSMOD format support
Matti Hamalainen <ccr@tnsp.org>
parents:
1997
diff
changeset
|
398 dmFree(pattern->map); |
1224
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
399 dmFree(pattern->data); |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
400 dmFree(pattern); |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
401 } |
0 | 402 } |
403 | |
404 | |
405 /* Allocates and initializes internal "normal" instrument structure. | |
406 */ | |
407 JSSInstrument *jssAllocateInstrument(void) | |
408 { | |
1222 | 409 JSSInstrument *inst; |
0 | 410 |
411 // Allocate a instrument structure | |
1222 | 412 if ((inst = dmMalloc0(sizeof(JSSInstrument))) == NULL) |
0 | 413 return NULL; |
414 | |
1222 | 415 return inst; |
0 | 416 } |
417 | |
418 | |
1224
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
419 void jssFreeInstrument(JSSInstrument *inst) |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
420 { |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
421 if (inst != NULL) |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
422 { |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
423 #ifndef JSS_LIGHT |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
424 dmFree(inst->desc); |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
425 #endif |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
426 dmFree(inst->data); |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
427 dmFree(inst); |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
428 } |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
429 } |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
430 |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
431 |
0 | 432 /* Allocates and initializes "extended" instrument structure. |
433 */ | |
434 JSSExtInstrument *jssAllocateExtInstrument(void) | |
435 { | |
1222 | 436 JSSExtInstrument *inst; |
0 | 437 |
438 // Allocate a instrument structure | |
1222 | 439 if ((inst = dmMalloc0(sizeof(JSSExtInstrument))) == NULL) |
0 | 440 return NULL; |
441 | |
1222 | 442 // Initialize the requisite fields |
1403 | 443 for (int i = 0; i < jsetNNotes; i++) |
1222 | 444 inst->sNumForNotes[i] = jsetNotSet; |
1127
e22d4ceb6414
Cosmetics pass, remove excess and trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
948
diff
changeset
|
445 |
1222 | 446 return inst; |
0 | 447 } |
1224
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
448 |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
449 |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
450 void jssFreeExtInstrument(JSSExtInstrument *inst) |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
451 { |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
452 if (inst != NULL) |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
453 { |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
454 #ifndef JSS_LIGHT |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
455 dmFree(inst->desc); |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
456 #endif |
1402
b47109fce375
Make JSSExtInstrument.instConvSamples dynamically allocated and add check
Matti Hamalainen <ccr@tnsp.org>
parents:
1401
diff
changeset
|
457 dmFree(inst->instConvTable); |
1224
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
458 dmFree(inst); |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
459 } |
e667710aee8e
Add functions jssFreeInstrument(), jssFreeExtInstrument() and jssFreePattern().
Matti Hamalainen <ccr@tnsp.org>
parents:
1222
diff
changeset
|
460 } |