// (c) Theo Verelst // Uncommercial use only permitted with this notice clearly // visible, commercial rights reserved, contact: theover@tiscali.nl #include "Talkthrough.h" #include //--------------------------------------------------------------------------// // Function: Process_Data() // // // // Description: This function is called from inside the SPORT0 ISR every // // time a complete audio frame has been received. The new // // input samples can be found in the variables iChannel0LeftIn,// // iChannel0RightIn, iChannel1LeftIn and iChannel1RightIn // // respectively. The processed data should be stored in // // iChannel0LeftOut, iChannel0RightOut, iChannel1LeftOut, // // iChannel1RightOut, iChannel2LeftOut and iChannel2RightOut // // respectively. // // // // Chorus function added by variable delay line // // // //--------------------------------------------------------------------------// #define SW7 0x0100 // switch SW7, LED pattern 0 (PF8) #define SW6 0x0200 // switch SW6, LED pattern 1 (PF9) #define SW4 0x0400 // switch SW4, LED pattern 2 (PF10) #define SW5 0x0800 // switch SW5, stop (PF11) int buttonsprev; int buttonsprev = 0; unsigned char out=1; #define MAXCHARDEF 2 unsigned char dis57[5*MAXCHARDEF] = {0xf8, 0x24, 0x22, 0x24, 0xf8 , 0x82, 0x82, 0x92, 0x92, 0x7c }; unsigned char *midipointer, midicount; unsigned char measurenext = 0; extern int *sinewave; extern int si1,si2,si3; extern int sincr1, sincr2, sincr3; extern int sc, vul, vur; extern int *dell, *delr, dml, dmr, dil, dir, dol, dor, dom; extern int sine[], sinincr[]; extern unsigned char midinote[], midivel[], midibyte; extern char midistate, midipstate; unsigned char mi1, mi2, mi3; extern int *wavetable, wtlen; void initmidi() { midipointer = MIDIBASE; } //--------------------------------------------------------------------------// // Function: Process_Data() // // // // Description: This function is called from inside the SPORT0 ISR every // // time a complete audio frame has been received. The new // // input samples can be found in the variables iChannel0LeftIn,// // iChannel0RightIn, iChannel1LeftIn and iChannel1RightIn // // respectively. The processed data should be stored in // // iChannel0LeftOut, iChannel0RightOut, iChannel1LeftOut, // // iChannel1RightOut, iChannel2LeftOut and iChannel2RightOut // // respectively. // //--------------------------------------------------------------------------// void Process_Data(void) { int t,v,i,j; int k; unsigned char ext_switches, l; k = *pFIO_FLAG_D; iChannel1LeftOut = iChannel0LeftIn; iChannel1RightOut = iChannel0RightIn; iChannel0LeftIn = iChannel0LeftIn >> 2; iChannel0RightIn = iChannel0RightIn >> 2; if (((* (unsigned char *) 0x20300006) & 0x20) == 0x20) { if (((* (unsigned char *) 0x20300006) & 0xc0) != midicount) { midicount = (*((unsigned char *) 0x20300006)) & 0xc0; l = *midipointer = *((unsigned char *) 0x20300004); /* Read byte */ midipointer++; if (midipointer>= MIDIMAX+MIDIBASE) { midipointer = MIDIBASE; } if (midistate == MIDINIT) { l = 0; midistate = MIDDONE; } if ((l & 0x80) != 0) { /* first message byte ? */ midibyte = 1; switch (l>>4) { case MIDNOTEON: case MIDNOTEOFF: case MIDCONT: case MIDPITCH: midistate = (l>>4); midipstate = midistate; break; case MIDTIMING: break; default: midistate = MIDUNKNOWN; /* Unknown message: wait for new status word */ } mi1 = l; } else { if (midistate == MIDDONE) { /* More data without header: running status */ midibyte = 1; midistate = midipstate; } midibyte++; if (midistate != MIDUNKNOWN) { switch (midibyte) { case 2: mi2 = l; break; case 3: mi3 = l; midibyte = 0; /* Here we received one of the 3 byte midi messages fully */ switch (midistate) { case MIDNOTEON: if (mi3 == 0) { /* Is actually note off ? */ for (i=0; i 0) i++; if (i< MAXPOLY) { midinote[i] = mi2; midivel[i] = mi3; sinincr[i] = (int) ( ((wtlen*440)/48000) * pow( 2, (mi2-69.0)/12)); sine[i] = 0; /* initial phase == 0 */ } } break; case MIDNOTEOFF: for (i=0; i>16])>>(23-5+3)) ); if (t < 0) t+= dml; iChannel0LeftOut = dell[t] + iChannel0LeftIn; dell[dil] = iChannel0LeftIn; dil = (dil+1) % dml; t = dir - (dor + ((i*sinewave[si2>>16])>>(23-5+3)) ); if (t < 0) t+= dmr; iChannel0RightOut = delr[t] + iChannel0RightIn; delr[dir] = iChannel0RightIn; dir = (dir+1) % dmr; i = (dom + ((i*sinewave[si3>>16])>>(23-5+3)) ); t = dil - i; if (t < 0) t+= dml; v = dell[t]; t = dir - i; if (t < 0) t+= dmr; v += delr[t]; iChannel0LeftOut += v; iChannel0RightOut += v; v=0; for (i=0; i> 4) & 0x07; j = (((* (unsigned char *) 0x20300000) >> 0) & 0x0F)/8; j = * (unsigned char *) (0x20300000); buttonsprev = k; }