forked from libxmp/libxmp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen_mixer_data.c
More file actions
79 lines (60 loc) · 1.54 KB
/
Copy pathgen_mixer_data.c
File metadata and controls
79 lines (60 loc) · 1.54 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
#include <stdio.h>
#include <stdlib.h>
#include "../include/xmp.h"
#include "../src/common.h"
#include "../src/mixer.h"
#include "../src/virtual.h"
#include "../src/player.h"
static int map_channel(struct player_data *p, int chn)
{
int voc;
if ((uint32)chn >= p->virt.virt_channels)
return -1;
voc = p->virt.virt_channel[chn].map;
if ((uint32)voc >= p->virt.maxvoc)
return -1;
return voc;
}
int main(int argc, char **argv)
{
xmp_context opaque;
struct context_data *ctx;
struct module_data *m;
struct player_data *p;
struct mixer_voice *vi;
struct xmp_frame_info fi;
int i, voc;
if (argc < 2) {
fprintf(stderr, "usage: %s <module>\n", argv[0]);
exit(1);
}
opaque = xmp_create_context();
if (xmp_load_module(opaque, argv[1]) < 0) {
fprintf(stderr, "can't load module\n");
exit(1);
}
ctx = (struct context_data *)opaque;
m = &ctx->m;
p = &ctx->p;
xmp_start_player(opaque, 44100, 0);
xmp_set_player(opaque, XMP_PLAYER_MIX, 100);
while (xmp_play_frame(opaque) == 0) {
xmp_get_frame_info(opaque, &fi);
if (fi.loop_count > 0)
break;
for (i = 0; i < m->mod.chn; i++) {
struct xmp_channel_info *ci = &fi.channel_info[i];
struct channel_data *xc = &p->xc_data[i];
voc = map_channel(p, i);
if (voc < 0 || TEST_NOTE(NOTE_SAMPLE_END))
continue;
vi = &p->virt.voice_array[voc];
printf("%d %d %d %d %d %d %d %d %d %d %d\n",
fi.time, fi.row, fi.frame, i, ci->period,
vi->note, vi->ins, vi->vol, vi->pan, vi->pos0,
vi->filter.cutoff);
}
}
xmp_end_player(opaque);
xmp_release_module(opaque);
}