-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaudio.cpp
104 lines (88 loc) · 2.69 KB
/
audio.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/************************************************************************************
* audio.h
*
* descp : FMOD/audio interface ( http://www.fmod.org/ )
*
* auth : javery
*
* path : C:\Program Files\Microsoft Visual Studio\MyProjects\PrimaryCubes3D\audio.cpp
*
* iDate : 10/26/06
* version:
************************************************************************************/
#include <fmod/fmod.h>
#include "common.h"
#include "audio.h"
static FMUSIC_MODULE* fmodMusicModules[ MAX_FMOD_MUSIC_HANDLES ];
static FSOUND_SAMPLE* fmodSampleModules[ MAX_FMOD_SAMPLE_HANDLES ];
static FSOUND_STREAM* fmodStreamModules[ MAX_FMOD_STREAM_HANDLES ];
/*
========================================================================
AUD_InitFMOD
Inits the FMOD libary.
========================================================================
*/
c_boolean AUD_InitFMOD( int rate , int channels )
{
c_boolean success = (c_boolean)FSOUND_Init( rate , channels , FSOUND_INIT_ACCURATEVULEVELS /*| FSOUND_INIT_GLOBALFOCUS */);
return success;
}
/*
========================================================================
AUDO_ShutDownFMOD
Shutsdown FMOD
========================================================================
*/
void AUD_ShutdownFMOD( void )
{
FSOUND_Close();
}
/*
=========================================================================
AUD_LoadSong
Loads the specified songs into FMOD
=========================================================================
*/
int AUD_LoadSong( char* songFile , c_boolean looping )
{
static int fmodSong=0;
fmodSampleModules[ fmodSong ] =
FSOUND_Sample_Load( 0 , songFile ,
FSOUND_LOOP_NORMAL | FSOUND_FORCEMONO | FSOUND_16BITS | FSOUND_STREAMABLE | FSOUND_2D ,
0 , 0 );
//FSOUND_SetLooping( fmodMusicModules[ fmodSong ] , looping );
return fmodSong++;
}
/*
==========================================================================
AUD_PlaySong
Play music via FMOD
==========================================================================
*/
void AUD_PlaySong( int handleIndex )
{
FSOUND_PlaySound( 0 , fmodSampleModules[ handleIndex ] );
}
/*
==========================================================================
AUD_StopSong
Stops the current song.
==========================================================================
*/
void AUD_StopSong( int handleIndex )
{
FSOUND_StopSound( handleIndex );
}
/*
==========================================================================
AUD_FadeOutSong
Fades the passed song out to NULL dB
==========================================================================
*/
void AUD_FadeOutSong( int handleIndex )
{
for( int vol=255;vol>0;vol--)
{
FSOUND_SetVolume( handleIndex , (int)vol );
}
}