File: sound_libmikmod.c

package info (click to toggle)
gltron 0.61-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 3,948 kB
  • ctags: 1,175
  • sloc: ansic: 7,580; perl: 168; makefile: 149; sh: 15
file content (77 lines) | stat: -rw-r--r-- 1,299 bytes parent folder | download
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
#include "sound.h"

/* the following functions do nothing and are provided for
   compatibility only */

void playGameFX(int fx) { }
void playMenuFX(int fx) { }
void playEngine() { }
void stopEngine() { }
void shutdownSound() { }

/* here is the music stuff */

MODULE* sound_module;

int initSound() {
  char *drivers;
  md_mode |= DMODE_SOFT_MUSIC;
  md_mixfreq = 44100;
  md_reverb = 0;

#ifdef WIN32
  MikMod_RegisterDriver(&drv_win);
#else
  MikMod_RegisterAllDrivers();
#endif
  drivers = MikMod_InfoDriver();
  printf("%s\n", drivers);
  free(drivers);

  MikMod_RegisterAllLoaders();

  if(MikMod_Init("")) {
    printf("Cound not initialize sound: %s\n",
	   MikMod_strerror(MikMod_errno));
    return 1;
  }
  return 0;
}

void loadSound(char* name) {
  sound_module = Player_Load(name, 64, 0);
  if(!sound_module) {
    fprintf(stderr, "Could not load module: %s\n",
	   MikMod_strerror(MikMod_errno));
  }
}

void playSound() {
  if (sound_module) {
    Player_Start(sound_module);
    printf("sound startet\n");
  }
}

void stopSound() {
  Player_Stop();
  printf("sound stopped");
}

void deleteSound() {
  if(Player_Active())
    Player_Stop();
  if(sound_module)
    Player_Free(sound_module);
  MikMod_Exit();
}

void soundIdle() {
  if(Player_Active())
    MikMod_Update();
}