I have been working on this thing: there is a teensy 3.6 and some multiplexers and output op amps on the back, not much else except power and supervisor.
One thing it does, is generate waveforms based on sine waves which use this code. (taken from this site) http://www.coranac.com/2009/07/sines/
it works very well, no need for interpolation or anything, but he mentions it can run even faster using the ARM assemble code he provided.(as fast as a wavetable lookup with interpolation) That would be great, because the more oscillators, the better!
I have no idea how the assembler code works, but i have looked at some examples from the PJRC audio library, but to be honest i have little idea what i am doing
here is what i have so far, i get "matching constraint not valid in output operand" when i try to compile it.
One thing it does, is generate waveforms based on sine waves which use this code. (taken from this site) http://www.coranac.com/2009/07/sines/
Code:
static inline int32_t SIN3(int32_t x)
{
// S(x) = x * ( (3<<p) - (x*x>>r) ) >> s
// n : Q-pos for quarter circle 13
// A : Q-pos for output 12
// p : Q-pos for parentheses intermediate 15
// r = 2n-p 11
// s = A-1-p-n 17
static const int qN = 13, qA = 12, qP = 15, qR = 2 * qN - qP, qS = qN + qP + 1 - qA;
x = x << (30 - qN); // shift to full s32 range (Q13->Q30)
if ( (x ^ (x << 1)) < 0) // test for quadrant 1 or 2
x = (1 << 31) - x;
x = x >> (30 - qN);
return x * ( (3 << qP) - (x * x >> qR) ) >> qS;
}
it works very well, no need for interpolation or anything, but he mentions it can run even faster using the ARM assemble code he provided.(as fast as a wavetable lookup with interpolation) That would be great, because the more oscillators, the better!
I have no idea how the assembler code works, but i have looked at some examples from the PJRC audio library, but to be honest i have little idea what i am doing
Code:
static inline int32_t iSIN3(int32_t x)
{
int32_t out;
//register int32_t _r0 asm("r0");
asm volatile (
"mov r0, r0, lsl #(30-13) \n"
"teq r0, r0, lsl #1 \n"
"rsbmi r0, r0, #1<<31 \n"
"mov r0, r0, asr #(30-13) \n"
"mul r1, r0, r0 \n"
"mov r1, r1, asr #11 \n"
"rsb r1, r1, #3<<15 \n"
"mul r0, r1, r0 \n"
"mov r0, r0, asr #17 \n"
"bx lr \n"
: "=r0" (out)
: "r0" (x)
);
return out;
}
here is what i have so far, i get "matching constraint not valid in output operand" when i try to compile it.
Last edited: