core1/audio/n_adpcm.c done
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
# banjo (92.1173%)
|
# banjo (92.2108%)
|
||||||
|
|
||||||
<img src="./progress/progress_total.svg">
|
<img src="./progress/progress_total.svg">
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
#define N_AL_DIVIDED 368
|
#define N_AL_DIVIDED 368
|
||||||
|
|
||||||
typedef struct N_ALLoadFilter_s{
|
typedef struct N_ALLoadFilter_s{
|
||||||
//ALFilter filter;
|
u8 pad0[0xC];
|
||||||
ADPCM_STATE *state; //0xC
|
ADPCM_STATE *state; //0xC
|
||||||
ADPCM_STATE *lstate; //0x10
|
ADPCM_STATE *lstate; //0x10
|
||||||
ALRawLoop loop; //0x14
|
ALRawLoop loop; //0x14
|
||||||
|
@@ -9,7 +9,7 @@
|
|||||||
</mask>
|
</mask>
|
||||||
<g mask="url(#anybadge_1)">
|
<g mask="url(#anybadge_1)">
|
||||||
<path fill="#555" d="M0 0h44v20H0z"/>
|
<path fill="#555" d="M0 0h44v20H0z"/>
|
||||||
<path fill="#46e000" d="M44 0h67v20H44z"/>
|
<path fill="#43e000" d="M44 0h67v20H44z"/>
|
||||||
<path fill="url(#b)" d="M0 0h111v20H0z"/>
|
<path fill="url(#b)" d="M0 0h111v20H0z"/>
|
||||||
</g>
|
</g>
|
||||||
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
|
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
<text x="22.0" y="14">core1</text>
|
<text x="22.0" y="14">core1</text>
|
||||||
</g>
|
</g>
|
||||||
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
|
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
|
||||||
<text x="78.5" y="15" fill="#010101" fill-opacity=".3">84.3371%</text>
|
<text x="78.5" y="15" fill="#010101" fill-opacity=".3">84.9818%</text>
|
||||||
<text x="77.5" y="14">84.3371%</text>
|
<text x="77.5" y="14">84.9818%</text>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
@@ -17,7 +17,7 @@
|
|||||||
<text x="75.0" y="14">Banjo-Kazooie (us.v10)</text>
|
<text x="75.0" y="14">Banjo-Kazooie (us.v10)</text>
|
||||||
</g>
|
</g>
|
||||||
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
|
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
|
||||||
<text x="184.5" y="15" fill="#010101" fill-opacity=".3">92.1173%</text>
|
<text x="184.5" y="15" fill="#010101" fill-opacity=".3">92.2108%</text>
|
||||||
<text x="183.5" y="14">92.1173%</text>
|
<text x="183.5" y="14">92.2108%</text>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -1,7 +0,0 @@
|
|||||||
#include <ultra64.h>
|
|
||||||
#include "n_synth.h"
|
|
||||||
//see libultre src/audio/load.c
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/core1/audio/n_adpcm/_n_decodeChunk.s")
|
|
||||||
|
|
||||||
#pragma GLOBAL_ASM("asm/nonmatchings/core1/audio/n_adpcm/n_alAdpcmPull.s")
|
|
213
src/core1/done/audio/n_adpcm.c
Normal file
213
src/core1/done/audio/n_adpcm.c
Normal file
@@ -0,0 +1,213 @@
|
|||||||
|
#include <ultra64.h>
|
||||||
|
#include "n_synth.h"
|
||||||
|
|
||||||
|
#ifndef MIN
|
||||||
|
# define MIN(a,b) (((a)<(b))?(a):(b))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef AUD_PROFILE
|
||||||
|
extern u32 cnt_index, adpcm_num, adpcm_cnt, adpcm_max, adpcm_min, lastCnt[];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ADPCMFBYTES 9
|
||||||
|
#define LFSAMPLES 4
|
||||||
|
|
||||||
|
static
|
||||||
|
Acmd *_n_decodeChunk(Acmd *ptr, N_ALLoadFilter *f, s32 tsam, s32 nbytes, s16 outp, s16 inp, u32 flags);
|
||||||
|
|
||||||
|
Acmd *n_alAdpcmPull(void *filter, s16 *outp, s32 outCount, Acmd *p)
|
||||||
|
{
|
||||||
|
Acmd *ptr = p;
|
||||||
|
s16 inp;
|
||||||
|
s32 tsam;
|
||||||
|
s32 nframes;
|
||||||
|
s32 nbytes;
|
||||||
|
s32 overFlow;
|
||||||
|
s32 startZero;
|
||||||
|
s32 nOver;
|
||||||
|
s32 nSam;
|
||||||
|
s32 op;
|
||||||
|
s32 nLeft;
|
||||||
|
s32 bEnd;
|
||||||
|
s32 decoded = 0;
|
||||||
|
s32 looped = 0;
|
||||||
|
|
||||||
|
N_ALLoadFilter *f = (N_ALLoadFilter *)filter;
|
||||||
|
|
||||||
|
#ifdef AUD_PROFILE
|
||||||
|
lastCnt[++cnt_index] = osGetCount();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (outCount == 0)
|
||||||
|
return ptr;
|
||||||
|
|
||||||
|
inp = AL_DECODER_IN;
|
||||||
|
aLoadADPCM(ptr++, f->bookSize,
|
||||||
|
K0_TO_PHYS(f->table->waveInfo.adpcmWave.book->book));
|
||||||
|
|
||||||
|
looped = (outCount + f->sample > f->loop.end) && (f->loop.count != 0);
|
||||||
|
if (looped)
|
||||||
|
nSam = f->loop.end - f->sample;
|
||||||
|
else
|
||||||
|
nSam = outCount;
|
||||||
|
|
||||||
|
if (f->lastsam)
|
||||||
|
nLeft = ADPCMFSIZE - f->lastsam;
|
||||||
|
else
|
||||||
|
nLeft = 0;
|
||||||
|
tsam = nSam - nLeft;
|
||||||
|
if (tsam<0) tsam = 0;
|
||||||
|
|
||||||
|
nframes = (tsam+ADPCMFSIZE-1)>>LFSAMPLES;
|
||||||
|
nbytes = nframes*ADPCMFBYTES;
|
||||||
|
|
||||||
|
if (looped){
|
||||||
|
|
||||||
|
ptr = _n_decodeChunk(ptr, f, tsam, nbytes, *outp, inp, f->first);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fix up output pointer, which will be used as the input pointer
|
||||||
|
* by the following module.
|
||||||
|
*/
|
||||||
|
if (f->lastsam)
|
||||||
|
*outp += (f->lastsam<<1);
|
||||||
|
else
|
||||||
|
*outp += (ADPCMFSIZE<<1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Now fix up state info to reflect the loop start point
|
||||||
|
*/
|
||||||
|
f->lastsam = f->loop.start &0xf;
|
||||||
|
f->memin = (s32) f->table->base + ADPCMFBYTES *
|
||||||
|
((s32) (f->loop.start>>LFSAMPLES) + 1);
|
||||||
|
f->sample = f->loop.start;
|
||||||
|
|
||||||
|
bEnd = *outp;
|
||||||
|
while (outCount > nSam){
|
||||||
|
|
||||||
|
outCount -= nSam;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Put next one after the end of the last lot - on the
|
||||||
|
* frame boundary (32 byte) after the end.
|
||||||
|
*/
|
||||||
|
op = (bEnd + ((nframes+1)<<(LFSAMPLES+1)) + 0x10) & ~0x1f;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The actual end of data
|
||||||
|
*/
|
||||||
|
bEnd += (nSam<<1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* -1 is loop forever - the loop count is not exact now
|
||||||
|
* for small loops!
|
||||||
|
*/
|
||||||
|
if ((f->loop.count != -1) && (f->loop.count != 0))
|
||||||
|
f->loop.count--;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* What's left to compute.
|
||||||
|
*/
|
||||||
|
nSam = MIN(outCount, f->loop.end - f->loop.start);
|
||||||
|
tsam = nSam - ADPCMFSIZE + f->lastsam;
|
||||||
|
if (tsam<0) tsam = 0;
|
||||||
|
nframes = (tsam+ADPCMFSIZE-1)>>LFSAMPLES;
|
||||||
|
nbytes = nframes*ADPCMFBYTES;
|
||||||
|
ptr = _n_decodeChunk(ptr, f, tsam, nbytes, op, inp, f->first | A_LOOP);
|
||||||
|
/*
|
||||||
|
* Merge the two sections in DMEM.
|
||||||
|
*/
|
||||||
|
aDMEMMove(ptr++, op+(f->lastsam<<1), bEnd, nSam<<1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
f->lastsam = (outCount + f->lastsam) & 0xf;
|
||||||
|
f->sample += outCount;
|
||||||
|
f->memin += ADPCMFBYTES*nframes;
|
||||||
|
#ifdef AUD_PROFILE
|
||||||
|
PROFILE_AUD(adpcm_num, adpcm_cnt, adpcm_max, adpcm_min);
|
||||||
|
#endif
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The unlooped case, which is executed most of the time
|
||||||
|
*/
|
||||||
|
|
||||||
|
nSam = nframes<<LFSAMPLES;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* overFlow is the number of bytes past the end
|
||||||
|
* of the bitstream I try to generate
|
||||||
|
*/
|
||||||
|
overFlow = f->memin + nbytes - ((s32) f->table->base + f->table->len);
|
||||||
|
if (overFlow < 0)
|
||||||
|
overFlow = 0;
|
||||||
|
nOver = (overFlow/ADPCMFBYTES)<<LFSAMPLES;
|
||||||
|
if (nOver > nSam + nLeft)
|
||||||
|
nOver = nSam + nLeft;
|
||||||
|
|
||||||
|
nbytes -= overFlow;
|
||||||
|
|
||||||
|
if ((nOver - (nOver & 0xf))< outCount){
|
||||||
|
decoded = 1;
|
||||||
|
ptr = _n_decodeChunk(ptr, f, nSam - nOver, nbytes, *outp, inp, f->first);
|
||||||
|
|
||||||
|
if (f->lastsam)
|
||||||
|
*outp += (f->lastsam<<1);
|
||||||
|
else
|
||||||
|
*outp += (ADPCMFSIZE<<1);
|
||||||
|
|
||||||
|
f->lastsam = (outCount + f->lastsam) & 0xf;
|
||||||
|
f->sample += outCount;
|
||||||
|
f->memin += ADPCMFBYTES*nframes;
|
||||||
|
} else {
|
||||||
|
f->lastsam = 0;
|
||||||
|
f->memin += ADPCMFBYTES*nframes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Put zeros in if necessary
|
||||||
|
*/
|
||||||
|
if (nOver){
|
||||||
|
f->lastsam = 0;
|
||||||
|
if (decoded)
|
||||||
|
startZero = (nLeft + nSam - nOver)<<1;
|
||||||
|
else
|
||||||
|
startZero = 0;
|
||||||
|
aClearBuffer(ptr++, startZero + *outp, nOver<<1);
|
||||||
|
}
|
||||||
|
#ifdef AUD_PROFILE
|
||||||
|
PROFILE_AUD(adpcm_num, adpcm_cnt, adpcm_max, adpcm_min);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
Acmd *_n_decodeChunk(Acmd *ptr, N_ALLoadFilter *f, s32 tsam, s32 nbytes, s16 outp, s16 inp, u32 flags)
|
||||||
|
{
|
||||||
|
s32
|
||||||
|
dramAlign,
|
||||||
|
dramLoc;
|
||||||
|
|
||||||
|
if (nbytes > 0){
|
||||||
|
dramLoc = (f->dma)(f->memin, nbytes, f->dmaState);
|
||||||
|
/*
|
||||||
|
* Make sure enough is loaded into DMEM to take care
|
||||||
|
* of 8 byte alignment
|
||||||
|
*/
|
||||||
|
dramAlign = dramLoc & 0x7;
|
||||||
|
nbytes += dramAlign;
|
||||||
|
n_aLoadBuffer(ptr++, nbytes + 8 - (nbytes & 0x7), inp, dramLoc - dramAlign);
|
||||||
|
} else
|
||||||
|
dramAlign = 0;
|
||||||
|
|
||||||
|
if (flags & A_LOOP){
|
||||||
|
aSetLoop(ptr++, K0_TO_PHYS(f->lstate));
|
||||||
|
}
|
||||||
|
|
||||||
|
n_aADPCMdec(ptr++, K0_TO_PHYS(f->state), flags, tsam<<1, dramAlign, outp);
|
||||||
|
f->first = 0;
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
@@ -108,7 +108,7 @@ segments:
|
|||||||
- [0x25360, c, done/audio/n_synstartvoiceparam] #DONE
|
- [0x25360, c, done/audio/n_synstartvoiceparam] #DONE
|
||||||
- [0x25440, c, done/audio/n_mainbus] #DONE
|
- [0x25440, c, done/audio/n_mainbus] #DONE
|
||||||
- [0x254C0, c, done/audio/n_load] #DONE
|
- [0x254C0, c, done/audio/n_load] #DONE
|
||||||
- [0x25680, c, audio/n_adpcm]
|
- [0x25680, c, done/audio/n_adpcm]
|
||||||
- [0x25C40, c, done/audio/n_resample] #DONE
|
- [0x25C40, c, done/audio/n_resample] #DONE
|
||||||
- [0x25E20, c, done/audio/n_seq] #DONE
|
- [0x25E20, c, done/audio/n_seq] #DONE
|
||||||
- [0x26110, c, done/audio/n_synsetpriority] #DONE
|
- [0x26110, c, done/audio/n_synsetpriority] #DONE
|
||||||
|
Reference in New Issue
Block a user