Skip to content

Commit eac8fe2

Browse files
committed
aesnd: add unsigned PCM support
1 parent 4d95d74 commit eac8fe2

3 files changed

Lines changed: 50 additions & 33 deletions

File tree

gc/aesndlib.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@
1717
#define VOICE_STATE_RUNNING 1
1818
#define VOICE_STATE_STREAM 2
1919

20-
#define VOICE_MONO8 0x00000000
21-
#define VOICE_STEREO8 0x00000001
22-
#define VOICE_MONO16 0x00000002
23-
#define VOICE_STEREO16 0x00000003
20+
#define VOICE_MONO8 0x00000000
21+
#define VOICE_STEREO8 0x00000001
22+
#define VOICE_MONO16 0x00000002
23+
#define VOICE_STEREO16 0x00000003
24+
#define VOICE_MONO8_UNSIGNED 0x00000004
25+
#define VOICE_STEREO8_UNSIGNED 0x00000005
26+
#define VOICE_MONO16_UNSIGNED 0x00000006
27+
#define VOICE_STEREO16_UNSIGNED 0x00000007
2428

2529
#define VOICE_FREQ32KHZ 32000
2630
#define VOICE_FREQ48KHZ 48000

libaesnd/aesndlib.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
#define PB_STRUCT_SIZE 64
1313
#define DSP_DRAMSIZE 8192
1414

15-
#define VOICE_PAUSE 0x00000004
16-
#define VOICE_LOOP 0x00000008
17-
#define VOICE_ONCE 0x00000010
18-
#define VOICE_STREAM 0x00000020
15+
16+
#define VOICE_PAUSE 0x00000008
17+
#define VOICE_LOOP 0x00000010
18+
#define VOICE_ONCE 0x00000020
19+
#define VOICE_STREAM 0x00000040
1920

2021
#define VOICE_FINISHED 0x00100000
2122
#define VOICE_STOPPED 0x00200000
@@ -127,16 +128,21 @@ static __inline__ void __aesndcopycommand(AESNDPB *dst,AESNDPB *src)
127128
dst->cb = src->cb;
128129
}
129130

131+
130132
static __inline__ void __aesndsetvoiceformat(AESNDPB *pb,u32 format)
131133
{
132-
pb->flags = (pb->flags&~0x03)|(format&0x03);
133-
switch((format&0x03)) {
134+
pb->flags = (pb->flags&~0x07)|(format&0x07);
135+
switch((format&0x07)) {
134136
case VOICE_MONO8:
135137
case VOICE_STEREO8:
138+
case VOICE_MONO8_UNSIGNED:
139+
case VOICE_STEREO8_UNSIGNED:
136140
pb->shift = 0;
137141
break;
138142
case VOICE_MONO16:
139143
case VOICE_STEREO16:
144+
case VOICE_MONO16_UNSIGNED:
145+
case VOICE_STEREO16_UNSIGNED:
140146
pb->shift = 1;
141147
break;
142148
}

libaesnd/dspcode/dspmixer.s

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ PB_STURCT_SIZE: equ 64
8282
NUM_SAMPLES: equ 96 //process 2ms of sample data
8383
DEF_FREQ_INT: equ 0x0001
8484

85-
VOICE_FLAGL_PAUSE: equ 0x0004
86-
VOICE_FLAGL_LOOP: equ 0x0008
87-
VOICE_FLAGL_ONCE: equ 0x0010
85+
VOICE_FLAGL_PAUSE: equ 0x0008
86+
VOICE_FLAGL_LOOP: equ 0x0010
87+
VOICE_FLAGL_ONCE: equ 0x0020
8888

8989
VOICE_FLAGH_END: equ 0x0010
9090
VOICE_FLAGH_STOP: equ 0x0020
@@ -299,7 +299,7 @@ no_change_buffer:
299299
call setup_accl
300300

301301
mrr $acc1.m,$acc1.l
302-
andi $acc1.m,#0x03
302+
andi $acc1.m,#0x07
303303
addi $acc1.m,#select_mixer
304304
mrr $ar3,$acc1.m
305305
ilrr $acc1.m,@$ar3
@@ -359,34 +359,38 @@ no_delay:
359359

360360
jmp no_mix
361361

362-
mono_8bits:
363-
bloop $acx0.l,mono_8bits_end
362+
mono_unsigned_mix:
363+
bloop $acx0.l,mono_unsigned_mix_end
364364
lrs $acc0.m,@ACDAT //right channel
365-
mono_8bits_end:
365+
mono_unsigned_mix_end:
366366
mrr $acc1.m,$acc0.m //left channel
367+
xori $acc0.m,#0x8000
368+
xori $acc1.m,#0x8000
367369

368370
jmp mix_samples
369371

370-
stereo_8bits:
371-
bloop $acx0.l,stereo_8bits_end
372+
mono_mix:
373+
bloop $acx0.l,mono_mix_end
372374
lrs $acc0.m,@ACDAT //right channel
373-
stereo_8bits_end:
374-
lrs $acc1.m,@ACDAT //left channel
375+
mono_mix_end:
376+
mrr $acc1.m,$acc0.m //left channel
375377

376378
jmp mix_samples
377379

378-
mono_16bits:
379-
bloop $acx0.l,mono_16bits_end
380+
stereo_unsigned_mix:
381+
bloop $acx0.l,stereo_unsigned_mix_end
380382
lrs $acc0.m,@ACDAT //right channel
381-
mono_16bits_end:
382-
mrr $acc1.m,$acc0.m //left channel
383+
stereo_unsigned_mix_end:
384+
lrs $acc1.m,@ACDAT //left channel
385+
xori $acc0.m,#0x8000
386+
xori $acc1.m,#0x8000
383387

384388
jmp mix_samples
385389

386-
stereo_16bits:
387-
bloop $acx0.l,stereo_16bits_end
390+
stereo_mix:
391+
bloop $acx0.l,stereo_mix_end
388392
lrs $acc0.m,@ACDAT //right channel
389-
stereo_16bits_end:
393+
stereo_mix_end:
390394
lrs $acc1.m,@ACDAT //left channel
391395

392396
mix_samples:
@@ -563,14 +567,17 @@ exception7: // External interrupt (message from CPU)
563567
rti
564568

565569
select_mixer:
566-
cw mono_8bits
567-
cw stereo_8bits
568-
cw mono_16bits
569-
cw stereo_16bits
570+
cw mono_mix
571+
cw stereo_mix
572+
cw mono_mix
573+
cw stereo_mix
574+
cw mono_unsigned_mix
575+
cw stereo_unsigned_mix
576+
cw mono_unsigned_mix
577+
cw stereo_unsigned_mix
570578

571579
select_format:
572580
cw ACCL_FMT_8BIT
573581
cw ACCL_GAIN_8BIT
574582
cw ACCL_FMT_16BIT
575583
cw ACCL_GAIN_16BIT
576-

0 commit comments

Comments
 (0)