Skip to content

Commit

Permalink
mcd, increase audio volume slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
irixxxx committed Feb 23, 2024
1 parent 4aaedc8 commit 2eeee07
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 18 deletions.
18 changes: 9 additions & 9 deletions pico/sound/mix.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void mix_16h_to_32(s32 *dest_buf, s16 *mp3_buf, int count)
{
while (count--)
{
*dest_buf++ += *mp3_buf++ >> 1;
*dest_buf++ += (*mp3_buf++ * 5) >> 3;
}
}

Expand All @@ -123,8 +123,8 @@ void mix_16h_to_32_s1(s32 *dest_buf, s16 *mp3_buf, int count)
count >>= 1;
while (count--)
{
*dest_buf++ += *mp3_buf++ >> 1;
*dest_buf++ += *mp3_buf++ >> 1;
*dest_buf++ += (*mp3_buf++ * 5) >> 3;
*dest_buf++ += (*mp3_buf++ * 5) >> 3;
mp3_buf += 1*2;
}
}
Expand All @@ -134,8 +134,8 @@ void mix_16h_to_32_s2(s32 *dest_buf, s16 *mp3_buf, int count)
count >>= 1;
while (count--)
{
*dest_buf++ += *mp3_buf++ >> 1;
*dest_buf++ += *mp3_buf++ >> 1;
*dest_buf++ += (*mp3_buf++ * 5) >> 3;
*dest_buf++ += (*mp3_buf++ * 5) >> 3;
mp3_buf += 3*2;
}
}
Expand All @@ -146,8 +146,8 @@ void mix_16h_to_32_resample_stereo(s32 *dest_buf, s16 *cdda_buf, int count, int
int pos16 = 0;
while (count--) {
int pos = 2 * (pos16>>16);
*dest_buf++ += cdda_buf[pos ] >> 1;
*dest_buf++ += cdda_buf[pos+1] >> 1;
*dest_buf++ += (cdda_buf[pos ] * 5) >> 3;
*dest_buf++ += (cdda_buf[pos+1] * 5) >> 3;
pos16 += fac16;
}
}
Expand All @@ -158,8 +158,8 @@ void mix_16h_to_32_resample_mono(s32 *dest_buf, s16 *cdda_buf, int count, int fa
int pos16 = 0;
while (count--) {
int pos = 2 * (pos16>>16);
*dest_buf += cdda_buf[pos ] >> 2;
*dest_buf++ += cdda_buf[pos+1] >> 2;
*dest_buf += (cdda_buf[pos ] * 5) >> 4;
*dest_buf++ += (cdda_buf[pos+1] * 5) >> 4;
pos16 += fac16;
}
}
Expand Down
51 changes: 42 additions & 9 deletions pico/sound/mix_arm.S
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ m16_32_loop:
ldmia r0, {r3-r6}
ldmia r1!,{r12,lr}
subs r2, r2, #4
add r4, r4, r12,asr #17 @ we use half volume
add r4, r4, r12,asr #17 @ we use 5/8 volume
add r4, r4, r12,asr #19
mov r12,r12,lsl #16
add r3, r3, r12,asr #17
add r3, r3, r12,asr #19
add r6, r6, lr, asr #17
add r6, r6, lr, asr #19
mov lr, lr, lsl #16
add r5, r5, lr, asr #17
add r5, r5, lr, asr #19
stmia r0!,{r3-r6}
bpl m16_32_loop

Expand All @@ -47,7 +51,9 @@ m16_32_end:
ldmia r0, {r3,r4}
mov r12,r5, lsl #16
add r3, r3, r12,asr #17
add r3, r3, r12,asr #19
add r4, r4, r5, asr #17
add r4, r4, r5, asr #19
stmia r0!,{r3,r4}

m16_32_no_unal2:
Expand All @@ -56,6 +62,7 @@ m16_32_no_unal2:
ldrsh r4, [r1], #2
ldr r3, [r0]
add r3, r3, r4, asr #1
add r3, r3, r4, asr #3
str r3, [r0], #4

ldmfd sp!, {r4-r6,lr}
Expand All @@ -76,12 +83,16 @@ m16_32_s1_loop:
ldr r12,[r1], #8
ldr lr, [r1], #8
subs r2, r2, #4
add r4, r4, r12,asr #17
add r4, r4, r12,asr #17 @ we use 5/8 volume
add r4, r4, r12,asr #19
mov r12,r12,lsl #16
add r3, r3, r12,asr #17 @ we use half volume
add r3, r3, r12,asr #17
add r3, r3, r12,asr #19
add r6, r6, lr, asr #17
add r6, r6, lr, asr #19
mov lr, lr, lsl #16
add r5, r5, lr, asr #17
add r5, r5, lr, asr #19
stmia r0!,{r3-r6}
bpl m16_32_s1_loop

Expand All @@ -92,7 +103,9 @@ m16_32_s1_end:
ldmia r0, {r3,r4}
mov r12,r5, lsl #16
add r3, r3, r12,asr #17
add r3, r3, r12,asr #19
add r4, r4, r5, asr #17
add r4, r4, r5, asr #19
stmia r0!,{r3,r4}

m16_32_s1_no_unal2:
Expand All @@ -101,6 +114,7 @@ m16_32_s1_no_unal2:
ldrsh r4, [r1], #2
ldr r3, [r0]
add r3, r3, r4, asr #1
add r3, r3, r4, asr #3
str r3, [r0], #4

ldmfd sp!, {r4-r6,lr}
Expand All @@ -121,12 +135,16 @@ m16_32_s2_loop:
ldr r12,[r1], #16
ldr lr, [r1], #16
subs r2, r2, #4
add r4, r4, r12,asr #17
add r4, r4, r12,asr #17 @ we use 5/8 volume
add r4, r4, r12,asr #19
mov r12,r12,lsl #16
add r3, r3, r12,asr #17 @ we use half volume
add r3, r3, r12,asr #17
add r3, r3, r12,asr #19
add r6, r6, lr, asr #17
add r6, r6, lr, asr #19
mov lr, lr, lsl #16
add r5, r5, lr, asr #17
add r5, r5, lr, asr #19
stmia r0!,{r3-r6}
bpl m16_32_s2_loop

Expand All @@ -137,7 +155,9 @@ m16_32_s2_end:
ldmia r0, {r3,r4}
mov r12,r5, lsl #16
add r3, r3, r12,asr #17
add r3, r3, r12,asr #19
add r4, r4, r5, asr #17
add r4, r4, r5, asr #19
stmia r0!,{r3,r4}

m16_32_s2_no_unal2:
Expand All @@ -146,6 +166,7 @@ m16_32_s2_no_unal2:
ldrsh r4, [r1], #2
ldr r3, [r0]
add r3, r3, r4, asr #1
add r3, r3, r4, asr #3
str r3, [r0], #4

ldmfd sp!, {r4-r6,lr}
Expand All @@ -171,12 +192,16 @@ m16_32_rss_loop:
ldr lr ,[r1, r9, lsl #2]
add r4, r4, r3
subs r2, r2, #2
add r6, r6, r12,asr #17
add r6, r6, r12,asr #17 @ we use 5/8 volume
add r6, r6, r12,asr #19
mov r12,r12,lsl #16
add r5, r5, r12,asr #17 @ we use half volume
add r5, r5, r12,asr #17
add r5, r5, r12,asr #19
add r8, r8, lr, asr #17
add r8, r8, lr, asr #19
mov lr, lr, lsl #16
add r7, r7, lr, asr #17
add r7, r7, lr, asr #19
stmia r0!,{r5-r8}
bpl m16_32_rss_loop

Expand All @@ -188,7 +213,9 @@ m16_32_rss_end:
ldmia r0, {r5,r6}
mov r12,lr, lsl #16
add r5, r5, r12,asr #17
add r5, r5, r12,asr #19
add r6, r6, lr, asr #17
add r6, r6, lr, asr #19
stmia r0!,{r5,r6}

ldmfd sp!, {r4-r9,lr}
Expand All @@ -214,12 +241,16 @@ m16_32_rsm_loop:
ldr lr ,[r1, r9, lsl #2]
add r4, r4, r3
subs r2, r2, #2
add r5, r5, r12,asr #18
add r5, r5, r12,asr #18 @ we use 5/8 volume (= 5/16 vol per channel)
add r5, r5, r12,asr #20
mov r12,r12,lsl #16
add r5, r5, r12,asr #18 @ we use half volume (= quarter vol per channel)
add r5, r5, r12,asr #18
add r5, r5, r12,asr #20
add r6, r6, lr, asr #18
add r6, r6, lr, asr #20
mov lr, lr, lsl #16
add r6, r6, lr, asr #18
add r6, r6, lr, asr #20
stmia r0!,{r5-r6}
bpl m16_32_rsm_loop

Expand All @@ -231,7 +262,9 @@ m16_32_rsm_end:
ldr r5, [r0]
mov r12,lr, lsl #16
add r5, r5, r12,asr #18
add r5, r5, r12,asr #20
add r5, r5, lr, asr #18
add r5, r5, lr, asr #20
str r5, [r0]

ldmfd sp!, {r4-r6,r9,lr}
Expand Down

0 comments on commit 2eeee07

Please sign in to comment.