mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-26 03:30:46 +00:00
audiolib: initialization is better than assignment
git-svn-id: https://svn.eduke32.com/eduke32@5813 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
065db7d5e8
commit
1305d32e84
2 changed files with 11 additions and 32 deletions
|
@ -47,15 +47,9 @@ static int32_t PITCH_Installed = 0;
|
|||
|
||||
void PITCH_Init(void)
|
||||
{
|
||||
int32_t note;
|
||||
int32_t detune;
|
||||
|
||||
if (PITCH_Installed)
|
||||
return;
|
||||
|
||||
for (note = 0; note < 12; note++)
|
||||
for (int note = 0; note < 12; note++)
|
||||
{
|
||||
for (detune = 0; detune < MAXDETUNE; detune++)
|
||||
for (int detune = 0; detune < MAXDETUNE; detune++)
|
||||
{
|
||||
PitchTable[note][detune] = (uint32_t) (65536.f * powf(2.f, (note * MAXDETUNE + detune) / (12.f * MAXDETUNE)));
|
||||
}
|
||||
|
@ -73,25 +67,20 @@ void PITCH_Init(void)
|
|||
|
||||
uint32_t PITCH_GetScale(int32_t pitchoffset)
|
||||
{
|
||||
uint32_t scale;
|
||||
int32_t octaveshift;
|
||||
int32_t noteshift;
|
||||
int32_t note;
|
||||
int32_t detune;
|
||||
|
||||
if ( !PITCH_Installed )
|
||||
if (!PITCH_Installed)
|
||||
PITCH_Init();
|
||||
|
||||
if (pitchoffset == 0)
|
||||
return PitchTable[ 0 ][ 0 ];
|
||||
return PitchTable[0][0];
|
||||
|
||||
int noteshift = pitchoffset % 1200;
|
||||
|
||||
noteshift = pitchoffset % 1200;
|
||||
if (noteshift < 0)
|
||||
noteshift += 1200;
|
||||
|
||||
note = noteshift / 100;
|
||||
detune = (noteshift % 100) / (100 / MAXDETUNE);
|
||||
octaveshift = (pitchoffset - noteshift) / 1200;
|
||||
int note = noteshift / 100;
|
||||
int detune = (noteshift % 100) / (100 / MAXDETUNE);
|
||||
int octaveshift = (pitchoffset - noteshift) / 1200;
|
||||
|
||||
if (detune < 0)
|
||||
{
|
||||
|
@ -104,7 +93,7 @@ uint32_t PITCH_GetScale(int32_t pitchoffset)
|
|||
}
|
||||
}
|
||||
|
||||
scale = PitchTable[ note ][ detune ];
|
||||
uint32_t scale = PitchTable[note][detune];
|
||||
|
||||
return (octaveshift < 0) ? (scale >> -octaveshift) : (scale <<= octaveshift);
|
||||
}
|
||||
|
|
|
@ -33,15 +33,5 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
#include "inttypes.h"
|
||||
|
||||
enum PITCH_ERRORS
|
||||
{
|
||||
PITCH_Warning = -2,
|
||||
PITCH_Error = -1,
|
||||
PITCH_Ok = 0,
|
||||
};
|
||||
|
||||
//void PITCH_Init( void );
|
||||
uint32_t PITCH_GetScale( int32_t pitchoffset );
|
||||
void PITCH_UnlockMemory( void );
|
||||
int32_t PITCH_LockMemory( void );
|
||||
uint32_t PITCH_GetScale(int32_t pitchoffset);
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue