forked from libxmp/libxmp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_effect_set_nna_cont.c
More file actions
92 lines (76 loc) · 2.8 KB
/
Copy pathtest_effect_set_nna_cont.c
File metadata and controls
92 lines (76 loc) · 2.8 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
#include "test.h"
#include "../src/effects.h"
#include "../src/mixer.h"
#include "../src/virtual.h"
TEST(test_effect_set_nna_cont)
{
xmp_context opaque;
struct context_data *ctx;
struct player_data *p;
struct mixer_voice *vi, *vi2;
int i, voc;
opaque = xmp_create_context();
ctx = (struct context_data *)opaque;
p = &ctx->p;
create_simple_module(ctx, 2, 2);
set_instrument_volume(ctx, 0, 0, 22);
set_instrument_volume(ctx, 1, 0, 33);
set_instrument_fadeout(ctx, 0, 10000);
new_event(ctx, 0, 0, 0, 60, 1, 44, 0x0f, 2, FX_IT_INSTFUNC, 0x04);
new_event(ctx, 0, 1, 0, 50, 2, 0, 0x00, 0, 0, 0);
set_quirk(ctx, QUIRKS_IT, READ_EVENT_IT);
xmp_start_player(opaque, 44100, 0);
/* Row 0 */
xmp_play_frame(opaque);
voc = map_channel(p, 0);
fail_unless(voc >= 0, "virtual map");
vi = &p->virt.voice_array[voc];
fail_unless(vi->note == 59, "set note");
fail_unless(vi->ins == 0, "set instrument");
fail_unless(vi->vol / 16 == 43, "set volume");
fail_unless(vi->pos0 == 0, "sample position");
xmp_play_frame(opaque);
/* Row 1: new event to test NNA */
xmp_play_frame(opaque);
fail_unless(vi->note == 59, "not same note");
fail_unless(vi->ins == 0, "not same instrument");
fail_unless(vi->vol / 16 == 43, "not fading out");
fail_unless(vi->pos0 != 0, "sample reset");
/* Find virtual voice for channel 0 */
for (i = 0; i < p->virt.maxvoc; i++) {
if (p->virt.voice_array[i].chn == 0) {
break;
}
}
fail_unless(i != p->virt.maxvoc, "didn't virtual voice");
/* New instrument in virtual channel. When NNA is set to OFF,
* the new instrument plays in a new voice and the old instrument
* escapes from the envelope sustain point (keyoff event), follows
* the rest of the envelope and resets the virtual channel
*/
vi2 = &p->virt.voice_array[i];
fail_unless(vi2->ins == 1, "not new instrument");
fail_unless(vi2->note == 49, "not new note");
fail_unless(vi2->vol == 33 * 16, "not new instrument volume");
fail_unless(vi2->pos0 == 0, "sample didn't reset");
/* Fadeout */
xmp_play_frame(opaque);
fail_unless(vi->chn == 4, "didn't copy channel");
fail_unless(vi->note == 59, "not same note");
fail_unless(vi->ins == 0, "not same instrument");
fail_unless(vi->vol / 16 == 43, "not continuing");
fail_unless(vi->pos0 != 0, "sample reset");
xmp_play_frame(opaque);
fail_unless(vi->chn == 4, "didn't copy channel");
fail_unless(vi->note == 59, "not same note");
fail_unless(vi->ins == 0, "not same instrument");
fail_unless(vi->vol / 16 == 43, "not continuing");
fail_unless(vi->pos0 != 0, "sample reset");
xmp_play_frame(opaque);
fail_unless(vi->chn == 4, "didn't copy channel");
fail_unless(vi->note == 59, "not same note");
fail_unless(vi->ins == 0, "not same instrument");
fail_unless(vi->vol / 16 == 43, "not continuing");
fail_unless(vi->pos0 != 0, "sample reset");
}
END_TEST