-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmikmod_playwav.h
More file actions
100 lines (68 loc) · 2.1 KB
/
mikmod_playwav.h
File metadata and controls
100 lines (68 loc) · 2.1 KB
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
// /////////////////////////////////////////////////////////////////
// Copyright Haris Hasanudin 2010
// /////////////////////////////////////////////////////////////////
// libMikmod sample
// `libmikmod-config --cflags` `libmikmod-config --libs`
// /////////////////////////////////////////////////////////////////
#include <unistd.h>
#include <mikmod.h>
#include <stdio.h>
#include <stdlib.h>
void mymikmod_play(char fname[256]);
void * mikmod_play_BGM( void * fname );
void * mikmod_play_BGM( void * arg )
{
TH_BOX * arg_bgm = (TH_BOX * ) arg;
char *fname=NULL;
fname = arg_bgm->myfile;
// printf("inside: %s\n", arg_bgm->myfile);
pthread_detach ( pthread_self() );
mymikmod_play( arg_bgm->myfile );
//printf( "\nselesai.\n" );
if(arg_bgm != NULL)
free (arg_bgm);
return 0;
}
void mymikmod_play(char fname[256])
{
int i;
/* sound effects */
SAMPLE *sfx1=NULL;
/* voices */
int v1;
// printf("mikmod read %s\n", fname);
/* register all the drivers */
MikMod_RegisterAllDrivers();
//printf("register ok\n");
/* initialize the library */
md_mode |= DMODE_SOFT_SNDFX;
if (MikMod_Init("")) {
fprintf(stderr, "Could not initialize sound, reason: %s\n",
MikMod_strerror(MikMod_errno));
return;
}
/* load samples */
sfx1 = Sample_Load( fname );
if (!sfx1) {
MikMod_Exit();
fprintf(stderr, "Could not load the first sound, reason: %s\n",
MikMod_strerror(MikMod_errno));
return;
}
// printf("load sample ok\n");
/* reserve voices for sound effects */
MikMod_SetNumVoices(-1, 1);
/* get ready to play */
MikMod_EnableOutput();
/* play first sample */
v1 = Sample_Play(sfx1, 0, 0);
//printf("\n");
do {
MikMod_Update();
Voice_SetVolume(v1, 180);
usleep(100000);
} while (!Voice_Stopped(v1));
MikMod_DisableOutput();
Sample_Free(sfx1);
MikMod_Exit();
}