Sound effects with Rotation control Prateek Jain May 2,2009 Microcomputer Systems I Dr. Kepuska
Overview Purpose Audio Generation Code Demo Talkthrough.h Main.c Initialize.c ISR.c Process_data.c Demo
Purpose Press PF8 once: rotation of sound is heard in anti-clock wise direction. Press PF8 twice: rotation of sound is heard in clock wise direction. Press PF9: echo effect is heard and when pressed again its off. Press PF10: Bouncy effect is heard and when pressed again its off.
Talkthrough.h …//Surround Sound void Surround_Snd(void); extern int SkipPosition; extern int check; extern int checkleft; extern int checkright; extern int echosound; extern int bouncysound; void LeftSurround(void); void RightSurround(void); void echoeffect(void); void bounceeffect(void);
Main.c …int SkipPosition = 0; int bouncysound=0; int check = 0; int echosound=0; int checkleft=0; int checkright=0;
Initialize.c … void Init_Interrupts(void) { // Set System Interrupt Assignment Registers //2 for Sport0 RX, 5 for Flag A, and 4 for Timer0 *pSIC_IAR0 = 0xffffffff; *pSIC_IAR1 = 0xffffff2f; *pSIC_IAR2 = 0xffff5ff4; // assign ISRs to interrupt vectors register_handler(ik_ivg9, Sport0_RX_ISR); register_handler(ik_ivg12, FlagA_ISR); register_handler(ik_ivg11, Timer0_ISR); // enable interrupts Timer0, Sport0 RX, and Flag A *pSIC_IMASK = 0x00090200; }
Initialize.c (cont’d) … void Init_Flags(void) { *pFIO_INEN = 0x0700; //need PF8, PF9, and PF10 *pFIO_DIR = 0x0000; *pFIO_EDGE = 0x0700; *pFIO_MASKA_D = 0x0700; } void Init_Timers(void) *pTIMER0_CONFIG =0x0019; *pTIMER0_PERIOD =0x03000000; *pTIMER0_WIDTH =0x00200000; *pTIMER_ENABLE =0x0001;
Process_data.c void echoeffect(void) {static short echoBufferL[4000],echoBufferR[4000]; int left, right; static int i = 0; echoBufferL[i] = (short)(iChannel0LeftIn>>8) + (echoBufferL[i]/2); echoBufferR[i] = (short)(iChannel0RightIn>>8) + (echoBufferR[i]/2); left = echoBufferL[i]; right = echoBufferR[i]; I Channel0LeftOut = left << 8; iChannel0RightOut = right << 8; if(i>=4000-1) i = 0; else i++; }
Demo
Questions?