aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-05-27 16:46:36 +0200
committerBad Diode <bd@badd10de.dev>2021-05-27 16:46:36 +0200
commitbc7f470714032c9e97798a5e532517c3d01adeef (patch)
treeb76500ee4fbbe0deacc73944db55bf7d6d03b12e /src/main.c
parentf32eda6df8e1df42e06eae55d28d9a45a92e7ecd (diff)
downloaduxngba-bc7f470714032c9e97798a5e532517c3d01adeef.tar.gz
uxngba-bc7f470714032c9e97798a5e532517c3d01adeef.zip
Add ADSR filter
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/main.c b/src/main.c
index cbf781d..aee68f8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -155,10 +155,13 @@ audio_talk(Device *d, u8 b0, u8 w) {
155 } 155 }
156 c->inc = (pitch_table[c->pitch] * sampling_rate) >> 5; 156 c->inc = (pitch_table[c->pitch] * sampling_rate) >> 5;
157 157
158 u16 adsr = mempeek16(d->dat, 0x8);
159 build_adsr(c, adsr);
158 txt_position(0, 0); 160 txt_position(0, 0);
159 txt_printf("note: %d \n", c->pitch); 161 txt_printf("note: %d \n", c->pitch);
160 txt_printf("inc: %ld \n", c->inc); 162 txt_printf("inc: %lu \n", c->inc);
161 txt_printf("length: %ld \n", c->length >> 12); 163 txt_printf("length: %lu \n", c->length >> 12);
164 txt_printf("chan: %lu \n", d - devaudio);
162 } 165 }
163} 166}
164 167
@@ -423,21 +426,24 @@ int main(void) {
423 int frame_counter = 0; 426 int frame_counter = 0;
424 evaluxn(&u, 0x0100); 427 evaluxn(&u, 0x0100);
425 u32 flip_cycles = 0; 428 u32 flip_cycles = 0;
429 u32 eval_cycles = 0;
430 u32 input_cycles = 0;
431 u32 mix_cycles = 0;
426 while(true) { 432 while(true) {
427 bios_vblank_wait(); 433 bios_vblank_wait();
428 profile_start(); 434 profile_start();
429 handle_input(&u); 435 handle_input(&u);
430 u32 input_cycles = profile_stop(); 436 input_cycles = MAX(profile_stop(), input_cycles);
431 profile_start(); 437 profile_start();
432 evaluxn(&u, mempeek16(devscreen->dat, 0)); 438 evaluxn(&u, mempeek16(devscreen->dat, 0));
433 u32 eval_cycles = profile_stop(); 439 eval_cycles = MAX(profile_stop(), eval_cycles);
434 txt_position(0, 8); 440 txt_position(0, 8);
435 profile_start(); 441 profile_start();
436 flip_cycles = profile_stop(); 442 flip_cycles = profile_stop();
437 frame_counter++; 443 frame_counter++;
438 profile_start(); 444 profile_start();
439 sound_mix(); 445 sound_mix();
440 u32 mix_cycles = profile_stop(); 446 mix_cycles = MAX(profile_stop(), mix_cycles);
441 447
442 txt_position(0, 15); 448 txt_position(0, 15);
443 txt_printf("INPUT: %lu \n", input_cycles); 449 txt_printf("INPUT: %lu \n", input_cycles);