Re: [AD] Speed wav loader way up |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: "Coordination of admins/developers of the game programming library Allegro" <alleg-developers@xxxxxxxxxx>
- Subject: Re: [AD] Speed wav loader way up
- From: Matthew Leverton <meffer@xxxxxxxxxx>
- Date: Wed, 14 Apr 2010 00:47:44 -0500
> On 14 April 2010 13:10, Trent Gamblin <trent@xxxxxxxxxx> wrote:
>> On Tue, April 13, 2010 7:12 pm, Peter Wang said:
>>> That looks right. The overhead is from the individual al_fgetc calls,
>>> which have to go through the file stream vtable.
>>>
>>> The optimisation would be to read a whole buffer of 16-bit sample values into
>>> the buffer with a single al_fread call. Then for #ifdef ALLEGRO_BIGENDIAN, make
>>> a pass over the buffer to swap the endianness. PCM data in wave files is little
>>> endian, unless the identifier is "RIFX", which we apparently don't support.[1]
>>
>> How's this?
>
I wrote a patch that cleaned up the entire file (the whole thing was
written while the Allegro I/O routines were in a state of flux). But I
cannot test it since Allegro won't run on OS X 10.4 PPC and I cannot
be bothered to look into it. ;)
But basically, you should be able to unconditionally fread the entire
thing first taking into account the sample size (channels * bitsize /
8). Then within an #ifdef for big endian, check if 16 bits, and then
flip the bytes. No need for two freads.
--
Matthew Leverton