Commit Graph

212 Commits

Author SHA1 Message Date
Chris Robinson
2e279684d7 Only require MSADPCM block alignment to be a multiple of 2 2014-03-06 21:42:03 -08:00
Chris Robinson
143f786d1a Move the sample conversion routines to a separate file 2014-03-05 16:38:02 -08:00
Chris Robinson
bf4ddfef6d Implement a simplistic MSADPCM encoder
It's not particularly good, but it's better than silence.
2014-03-05 07:27:22 -08:00
Chris Robinson
61569e09ed Allocate enough temp space for the ADPCM decoders and encoders 2014-03-05 06:18:55 -08:00
Chris Robinson
a4126b66d4 Use specialized methods for converting ALshort to IMA4 and MSADPCM
As before, to avoid unnecessary direct copies
2014-03-05 06:13:00 -08:00
Chris Robinson
f82f3f10ab Use specialized methods for converting IMA4 and MSADPCM to ALshort
Since the decoder methods already convert to ALshort, there's no need to use a
temp buffer that's just going to copy directly to the destination.
2014-03-05 04:59:24 -08:00
Chris Robinson
15b68fe694 Use maxi to clamp an int to a lower-bound 2014-03-05 04:37:55 -08:00
Chris Robinson
fb1f9aad6e Expand the sign bit on the initial MSADPCM delta value 2014-03-05 00:30:23 -08:00
Chris Robinson
a1c440bd09 Add an extension to support MSADPCM buffer formats 2014-03-04 22:44:30 -08:00
Chris Robinson
f3a87d72b2 Add an extension to alter the block alignment for buffer unpack/pack ops
This is for unpacking (reading, e.g. alBufferData) and packing (writing, e.g.
alGetBufferSamplesSOFT) operations. The alignments are specified in sample
frames, with 0 meaning the default (65 for IMA4, 1 otherwise). IMA4 alignment
must be a multiple of 8, plus 1 (e.g. alignment = n*8 + 1), otherwise an error
will occur during (un)packing. Chenging the block alignment does not affect
already-loaded sample data, only future unpack/pack operations... so for
example, this is perfectly valid:

// Load mono IMA4 data with a block alignment of 1024 bytes, or 2041 sample
// frames.
alBufferi(buffer, AL_UNPACK_BLOCK_ALIGNMENT_SOFT, 2041);
alBufferData(buffer, AL_FORMAT_MONO_IMA4, data, data_len, srate);
alBufferi(buffer, AL_UNPACK_BLOCK_ALIGNMENT_SOFT, 0);
2014-03-04 05:53:35 -08:00
Chris Robinson
b0a6b6427c Parameterize the block alignment 2014-03-04 04:29:35 -08:00
Chris Robinson
a6eb38ea7f Use alloca for temp space decoding/encoding IMA4 blocks 2014-03-03 20:02:15 -08:00
Chris Robinson
a2d9133ffc Reduce explicit template declarations and ignore IMA4-to-IMA4 conversions
Since we never store IMA4 data in buffers, we should only ever convert from
(user input) or to (user output) IMA4. Once we allow user-specified pack/unpack
block alignment, this wouldn't be a simple memcpy anyway.
2014-03-03 17:25:46 -08:00
Chris Robinson
c442c93a93 Store the original frame size alignment in the buffer 2014-03-03 17:05:08 -08:00
Chris Robinson
d3c70e63b4 Use C99 inline in more places 2013-11-04 13:44:46 -08:00
Chris Robinson
551f893ae9 Use C99 inline semantics 2013-11-04 12:12:31 -08:00
Chris Robinson
1518895e15 Use an UNUSED macro instead of void-tagging unused parameters 2013-10-07 07:44:09 -07:00
Chris Robinson
e1d5be570e Remove al_try usage from alBuffer.c 2013-10-07 07:06:01 -07:00
Chris Robinson
5d014ba85f Start using a simpler method for error handling
This helps avoid the al_try/al_throwerr/al_endtry stuff.
2013-10-06 18:01:01 -07:00
Chris Robinson
94884ed04b Use a separate value for the maximum buffer channels
Unlike the device, input buffers are accessed based on channel numbers
instead of enums. This means the maximum number of channels they hold
depends on the number of channels any one format can have, rather than
the total number of recognized channels. Currently, this is 8 for 7.1.
2013-07-23 00:13:15 -07:00
Chris Robinson
a371de080b Silence some clang warnings 2013-06-05 01:52:49 -07:00
Chris Robinson
e96cc656e9 Use C99's inline instead of __inline 2013-05-28 22:27:07 -07:00
Chris Robinson
9dae98071f Fix possible overflow when converting float to int
Same as with the mixer, we can only use 25 bits of precision from
floats.
2013-05-20 01:34:14 -07:00
Chris Robinson
43b406ad9b Simplify al_try code 2013-03-24 13:55:41 -07:00
Chris Robinson
40ea4f4b46 Use int instead of long for the IMA4 tables 2012-11-10 03:40:36 -08:00
Chris Robinson
4f624cb734 Load Int and UInt samples as float with alBufferData
This shouldn't really ever happen, as there's no 32-bit (u)int formats
alBufferData can take.
2012-11-10 03:36:37 -08:00
Chris Robinson
0f3a575a09 Don't include alu.h in alMain.h 2012-09-14 02:14:29 -07:00
Chris Robinson
1c096b101d Minor typo fixes 2012-06-28 19:57:23 -07:00
Chris Robinson
583dc8dbca Don't use all caps for enum value names 2012-06-28 18:49:49 -07:00
Chris Robinson
31d124582b Switch alBuffer.c to the new error handling scheme, and get rid of more hungarian notation 2012-04-24 00:17:05 -07:00
Chris Robinson
5418519637 Remove some more hungarian notation 2012-04-19 23:00:58 -07:00
Chris Robinson
08bd5e8b37 Fix comment and rename the buffer's self-id 2012-04-19 22:14:02 -07:00
Chris Robinson
84c1f2bfd0 Avoid shadowing a couple variables 2012-04-16 23:09:36 -07:00
Chris Robinson
4a65747a4b Add a COUNTOF macro to get the number of entries in a static array 2012-02-19 12:07:40 -08:00
Chris Robinson
60785eab8e Move the endian test macro to alMain.h 2012-02-15 21:47:35 -08:00
Chris Robinson
a98e381c8e Ensure ALbyte3 and ALubyte3 are the proper size 2012-02-07 08:05:01 -08:00
Chris Robinson
3fda804217 Pass the uncompressed sample count to LoadData and ConvertData for IMA4 2012-01-26 16:53:21 -08:00
Chris Robinson
b4ba83ec34 Avoid a bit of code duplication 2012-01-25 19:32:10 -08:00
Chris Robinson
29ba8f9f1a Remove the unnecessary AL_MULAW_SOFT, AL_ALAW_SOFT, and AL_IMA4_SOFT defines 2012-01-10 00:59:10 -08:00
Chris Robinson
61af4d715c Append _SOFT to the AL_SOFT_buffer_samples enums 2012-01-10 00:41:05 -08:00
Chris Robinson
11caba9807 Use sample frames when handling the buffer length 2011-10-04 02:08:45 -07:00
Chris Robinson
cf10a8d321 Get rid of some unnecessary casting 2011-10-02 16:54:45 -07:00
Chris Robinson
a05006b06a Rename some parameters 2011-10-02 07:31:26 -07:00
Chris Robinson
eb0b96752a Remove the OriginalAlign buffer field, and calculate it as needed 2011-10-01 19:52:07 -07:00
Chris Robinson
2f453eba35 Fix potential divide-by-0 2011-10-01 08:37:42 -07:00
Chris Robinson
8b2e1fdd9a Add buffer properties to get the internal format, and the length in bytes, samples, and seconds
The provided buffer lengths correspond to the source offsets, in that the byte
length specifies the end of the byte offset (ie, when the buffer is used for a
static source, the offset will range between 0 (inclusive) and the byte length
(exclusive)). Although an application could use the AL_SIZE, AL_CHANNELS,
AL_BITS, and AL_FREQUENCY properties to find the length in samples and seconds,
the byte length cannot be reliably calculated this way.
2011-10-01 06:19:55 -07:00
Chris Robinson
92f95e4d94 Add support for AL_EXT_ALAW 2011-10-01 04:55:03 -07:00
Chris Robinson
e9da6950ee Centralize the Lookup and Remove macros 2011-09-24 18:34:45 -07:00
Chris Robinson
43350f9066 Silence some MSVC precision warnings 2011-09-22 00:35:08 -07:00
Chris Robinson
b615c7d0a2 Use arrays instead of large switches to decompose formats 2011-09-18 19:06:19 -07:00