audio_synthesis.c OK and Documented (#1090)

* import synth docs

* cleanup

* small followup cleanup

* PR Suggestions, small cleanup

* fix bss

* PR suggestion

* fix enum

* PR Suggestions
This commit is contained in:
engineer124
2022-10-02 20:24:10 +01:00
committed by GitHub
parent 0e2de439dd
commit 3e32379c2b
18 changed files with 2612 additions and 770 deletions
+60 -31
View File
@@ -53,6 +53,7 @@
#define A_INIT 0x01
#define A_CONTINUE 0x00
#define A_LOOP 0x02
#define A_ADPCM_SHORT 0x04
#define A_OUT 0x02
#define A_LEFT 0x02
#define A_RIGHT 0x00
@@ -331,13 +332,20 @@ typedef short ENVMIX_STATE[40];
_a->words.w1 = (unsigned int)(a2); \
}
#define aClearBuffer(pkt, d, c) \
{ \
Acmd *_a = (Acmd *)pkt; \
\
_a->words.w0 = _SHIFTL(A_CLEARBUFF, 24, 8) | _SHIFTL(d, 0, 24); \
_a->words.w1 = (unsigned int)(c); \
}
/*
* Clears DMEM by writing zeros.
*
* @param pkt pointer to an Acmd buffer
* @param dmem DMEM address to clear
* @param size number of bytes to clear (rounded up to the next multiple of 16)
*/
#define aClearBuffer(pkt, dmem, size) \
{ \
Acmd* _a = (Acmd*)pkt; \
\
_a->words.w0 = _SHIFTL(A_CLEARBUFF, 24, 8) | _SHIFTL(dmem, 0, 24); \
_a->words.w1 = (uintptr_t)(size); \
}
#define aEnvMixer(pkt, dmemi, count, swapLR, x0, x1, x2, x3, m, bits) \
{ \
@@ -368,14 +376,21 @@ typedef short ENVMIX_STATE[40];
_a->words.w1 = _SHIFTL(dmemi, 16, 16) | _SHIFTL(dmemo, 0, 16); \
}
#define aLoadBuffer(pkt, s, d, c) \
{ \
Acmd *_a = (Acmd *)pkt; \
\
_a->words.w0 = _SHIFTL(A_LOADBUFF, 24, 8) | \
_SHIFTL((c) >> 4, 16, 8) | _SHIFTL(d, 0, 16); \
_a->words.w1 = (unsigned int)(s); \
}
/*
* Loads a buffer to DMEM from any physical source address, KSEG0, or KSEG1
*
* @param pkt pointer to an Acmd buffer
* @param addrSrc Any physical source address, KSEG0, or KSEG1
* @param dmemDest DMEM destination address
* @param size number of bytes to copy (rounded down to the next multiple of 16)
*/
#define aLoadBuffer(pkt, addrSrc, dmemDest, size) \
{ \
Acmd* _a = (Acmd*)pkt; \
\
_a->words.w0 = (_SHIFTL(A_LOADBUFF, 24, 8) | _SHIFTL((size) >> 4, 16, 8) | _SHIFTL(dmemDest, 0, 16)); \
_a->words.w1 = (uintptr_t)(addrSrc); \
}
#define aMix(pkt, f, g, i, o) \
{ \
@@ -404,14 +419,21 @@ typedef short ENVMIX_STATE[40];
_a->words.w1 = (unsigned int)(s); \
}
#define aSaveBuffer(pkt, s, d, c) \
{ \
Acmd *_a = (Acmd *)pkt; \
\
_a->words.w0 = _SHIFTL(A_SAVEBUFF, 24, 8) | \
_SHIFTL((c) >> 4, 16, 8) | _SHIFTL(s, 0, 16); \
_a->words.w1 = (unsigned int)(d); \
}
/*
* Stores a buffer from DMEM to any physical source address, KSEG0, or KSEG1
*
* @param pkt pointer to an Acmd buffer
* @param dmemSrc DMEM source address
* @param addrDest Any physical source address, KSEG0, or KSEG1
* @param size number of bytes to copy (rounded down to the next multiple of 16)
*/
#define aSaveBuffer(pkt, dmemSrc, addrDest, size) \
{ \
Acmd* _a = (Acmd*)pkt; \
\
_a->words.w0 = (_SHIFTL(A_SAVEBUFF, 24, 8) | _SHIFTL((size) >> 4, 16, 8) | _SHIFTL(dmemSrc, 0, 16)); \
_a->words.w1 = (uintptr_t)(addrDest); \
}
#define aSegment(pkt, s, b) \
{ \
@@ -501,14 +523,21 @@ typedef short ENVMIX_STATE[40];
_a->words.w1 = (unsigned int)(addr); \
}
#define aDuplicate(pkt, count, dmemi, dmemo, a4) \
{ \
Acmd *_a = (Acmd *)pkt; \
\
_a->words.w0 = (_SHIFTL(A_DUPLICATE, 24, 8) | \
_SHIFTL(count, 16, 8) | _SHIFTL(dmemi, 0, 16)); \
_a->words.w1 = _SHIFTL(dmemo, 16, 16) | _SHIFTL(a4, 0, 16); \
}
/*
* Duplicates 128 bytes of data a specified number of times.
*
* @param pkt pointer to an Acmd buffer
* @param numCopies number of times to duplicate 128 bytes from src
* @param dmemSrc DMEM source address
* @param dmemDest DMEM destination address for the duplicates, size 128 * numCopies
*/
#define aDuplicate(pkt, numCopies, dmemSrc, dmemDest) \
{ \
Acmd* _a = (Acmd*)pkt; \
\
_a->words.w0 = (_SHIFTL(A_DUPLICATE, 24, 8) | _SHIFTL(numCopies, 16, 8) | _SHIFTL(dmemSrc, 0, 16)); \
_a->words.w1 = _SHIFTL(dmemDest, 16, 16) | _SHIFTL(0x80, 0, 16); \
}
#define aAddMixer(pkt, count, dmemi, dmemo, a4) \
{ \