... | ... |
@@ -6,10 +6,10 @@ |
6 | 6 |
|
7 | 7 |
|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] |
8 | 8 |
|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ] |
9 |
-|30 @Audio0 [ &vector $2 &duration $2 &attack $1 &decay $1 &sustain $1 &release $1 &length $2 &addr $2 &expansion $1 &volume $1 &detune $1 &pitch $1 ] |
|
10 |
-|40 @Audio1 [ &vector $2 &duration $2 &attack $1 &decay $1 &sustain $1 &release $1 &length $2 &addr $2 &expansion $1 &volume $1 &detune $1 &pitch $1 ] |
|
11 |
-|50 @Audio2 [ &vector $2 &duration $2 &attack $1 &decay $1 &sustain $1 &release $1 &length $2 &addr $2 &expansion $1 &volume $1 &detune $1 &pitch $1 ] |
|
12 |
-|60 @Audio3 [ &vector $2 &duration $2 &attack $1 &decay $1 &sustain $1 &release $1 &length $2 &addr $2 &expansion $1 &volume $1 &detune $1 &pitch $1 ] |
|
9 |
+|30 @Audio0 [ &vector $2 &position $2 &output $1 &duration $2 &pad $1 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |
|
10 |
+|40 @Audio1 [ &vector $2 &position $2 &output $1 &duration $2 &pad $1 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |
|
11 |
+|50 @Audio2 [ &vector $2 &position $2 &output $1 &duration $2 &pad $1 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |
|
12 |
+|60 @Audio3 [ &vector $2 &position $2 &output $1 &duration $2 &pad $1 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |
|
13 | 13 |
|80 @Controller &vector $2 &button $1 &key $1 |
14 | 14 |
|
15 | 15 |
( variables ) |
... | ... |
@@ -40,36 +40,24 @@ |
40 | 40 |
;kick/end ;kick SUB2 |
41 | 41 |
.Audio0/length DEO2 |
42 | 42 |
#ff .Audio0/volume DEO |
43 |
- #00 .Audio0/attack DEO |
|
44 |
- #f0 .Audio0/decay DEO |
|
45 |
- #ff .Audio0/sustain DEO |
|
46 |
- #1e .Audio0/release DEO |
|
43 |
+ #00ff .Audio0/adsr DEO2 |
|
47 | 44 |
|
48 | 45 |
;sine .Audio1/addr DEO2 |
49 | 46 |
#0054 .Audio1/length DEO2 |
50 | 47 |
#ff .Audio1/volume DEO |
51 |
- #00 .Audio1/attack DEO |
|
52 |
- #11 .Audio1/decay DEO |
|
53 |
- #00 .Audio1/sustain DEO |
|
54 |
- #1e .Audio1/release DEO |
|
48 |
+ #01ff .Audio1/adsr DEO2 |
|
55 | 49 |
#0074 .Audio1/duration DEO2 |
56 | 50 |
|
57 | 51 |
;sine .Audio2/addr DEO2 |
58 | 52 |
#00a8 .Audio2/length DEO2 |
59 | 53 |
#ff .Audio2/volume DEO |
60 |
- #00 .Audio2/attack DEO |
|
61 |
- #f0 .Audio2/decay DEO |
|
62 |
- #00 .Audio2/sustain DEO |
|
63 |
- #1e .Audio2/release DEO |
|
54 |
+ #2200 .Audio2/adsr DEO2 |
|
64 | 55 |
#01d0 .Audio2/duration DEO2 |
65 | 56 |
|
66 | 57 |
;sine .Audio3/addr DEO2 |
67 | 58 |
#00a8 .Audio3/length DEO2 |
68 | 59 |
#ff .Audio3/volume DEO |
69 |
- #00 .Audio3/attack DEO |
|
70 |
- #f0 .Audio3/decay DEO |
|
71 |
- #00 .Audio3/sustain DEO |
|
72 |
- #1e .Audio3/release DEO |
|
60 |
+ #38ff .Audio3/adsr DEO2 |
|
73 | 61 |
#00e8 .Audio3/duration DEO2 |
74 | 62 |
BRK |
75 | 63 |
|
... | ... |
@@ -117,17 +117,17 @@ void |
117 | 117 |
note_on(AudioChannel *channel, Uint16 duration, Uint8 *data, Uint16 len, Uint8 vol, |
118 | 118 |
Uint8 attack, Uint8 decay, Uint8 sustain, Uint8 release, Uint8 pitch, bool loop) { |
119 | 119 |
channel->duration = duration; |
120 |
- channel->vol_l = (vol >> 4) / 16.0f; |
|
121 |
- channel->vol_r = (vol & 0xf) / 16.0f; |
|
120 |
+ channel->vol_l = (vol >> 4) / 16.0f * 0.9; |
|
121 |
+ channel->vol_r = (vol & 0xf) / 16.0f * 0.9; |
|
122 | 122 |
|
123 | 123 |
Sample sample = {0}; |
124 | 124 |
sample.data = data; |
125 | 125 |
sample.len = len; |
126 | 126 |
sample.pos = 0; |
127 |
- sample.env.a = attack * 10.0f; |
|
128 |
- sample.env.d = decay * 10.0f; |
|
129 |
- sample.env.s = sustain / 256.0f; |
|
130 |
- sample.env.r = release * 10.0f; |
|
127 |
+ sample.env.a = attack * 62.0f; |
|
128 |
+ sample.env.d = decay * 62.0f; |
|
129 |
+ sample.env.s = sustain / 16.0f; |
|
130 |
+ sample.env.r = release * 62.0f; |
|
131 | 131 |
if (loop) { |
132 | 132 |
sample.loop = len; |
133 | 133 |
} else { |
... | ... |
@@ -284,20 +284,21 @@ audio_handler(void *ctx, Uint8 *out_stream, int len) { |
284 | 284 |
void |
285 | 285 |
audio_start(int idx, Uint8 *d, Uxn *u) |
286 | 286 |
{ |
287 |
- Uint16 duration = PEEK2(d + 0x2); |
|
287 |
+ Uint16 duration = PEEK2(d + 0x5); |
|
288 | 288 |
Uint8 off = d[0xf] == 0xff; |
289 | 289 |
|
290 | 290 |
if (!off) { |
291 |
- Uint16 addr = PEEK2(d + 0xa); |
|
291 |
+ Uint16 addr = PEEK2(d + 0xc); |
|
292 | 292 |
Uint8 *data = &u->ram[addr]; |
293 |
- Uint16 len = PEEK2(d + 0x8); |
|
294 |
- Uint8 volume = d[0xd]; |
|
293 |
+ Uint16 len = PEEK2(d + 0xa); |
|
294 |
+ Uint8 volume = d[0xe]; |
|
295 | 295 |
bool loop = !!(d[0xf] & 0x80); |
296 | 296 |
Uint8 pitch = d[0xf] & 0x7f; |
297 |
- Uint8 attack = d[0x4]; |
|
298 |
- Uint8 decay = d[0x5]; |
|
299 |
- Uint8 sustain = d[0x6]; |
|
300 |
- Uint8 release = d[0x7]; |
|
297 |
+ Uint16 adsr = PEEK2(d + 0x8); |
|
298 |
+ Uint8 attack = (adsr >> 12) & 0xF; |
|
299 |
+ Uint8 decay = (adsr >> 8) & 0xF; |
|
300 |
+ Uint8 sustain = (adsr >> 4) & 0xF; |
|
301 |
+ Uint8 release = (adsr >> 0) & 0xF; |
|
301 | 302 |
note_on(&channel[idx], duration, data, len, volume, attack, decay, sustain, release, pitch, loop); |
302 | 303 |
} else { |
303 | 304 |
note_off(&channel[idx], duration); |