Litet bilder:
PRINT_47.jpg
1: Hög
2: Låg
D8: Hög - låg
D9: Samplad vågform
D10: Samplingspunkter
D11: När jag klockar ut 7 bitar
PRINT_48.jpg
Enveloppen
PRINT_49.TIF
PRINT_50.jpg
Enveloppen, detalj. 
Vet inte var "luddet" kommer ifrån. jag gör lika med båda:
Multiplicerar signalen med sig själv
Multiplicerar med 0,2 sparar värdet
Tar den gamla summan, multiplicerar med 0,8
Adderar dem
I detta använder jag DSPns inbyggda instruktioner som använder en 40-bitars ackumulator och sedan "saturerar" jag ned det till Q15. 
Kod: Markera allt
                //
                // Calculate Basic exponential smoothing for hi
                //
                resultACCA = __builtin_clr();            // clear out accumulator
                                                        // square signal
                resultACCA = __builtin_mpy(outputSignal[0], outputSignal[0], NULL, NULL, 0, NULL, NULL, 0);
                ftemp1 = __builtin_sac(resultACCA, 0);   //
                resultACCA = __builtin_clr();            // clear out accumulator
                                                        // multiply by weighthing factor
                resultACCA = __builtin_mpy(ftemp1, f2, NULL, NULL, 0, NULL, NULL, 0);
                ftemp1 = __builtin_sac(resultACCA, 0);   // Weighted new value
                //spi_send((ftemp1^0x8000)>>4);
                resultACCA = __builtin_clr();            // clear out accumulator
                                                        // multiply by weighthing factor
                resultACCA = __builtin_mpy(hi_ave, f1, NULL, NULL, 0, NULL, NULL, 0);
                ftemp2 = __builtin_sac(resultACCA, 0);   // weighted old value
                //
                //hi_ave = ftemp1 + ftemp22;
                resultACCA = __builtin_clr();            // clear out accumulator
                resultACCA = __builtin_add(resultACCA, ftemp1, 0);
                resultACCA = __builtin_add(resultACCA, ftemp2, 0);
                hi_ave = __builtin_sac(resultACCA, 0);
                //
                //spi_send((hi_ave^0x8000)>>4);
                //
                // Calculate Basic exponential smoothing for lo
                //
                resultACCB = __builtin_clr();            // clear out accumulator
                                                        // square signal
                resultACCB = __builtin_mpy(outputSignal2[0], outputSignal2[0], NULL, NULL, 0, NULL, NULL, 0);
                ftemp1 = __builtin_sac(resultACCB, 0);   //
                resultACCB = __builtin_clr();            // clear out accumulator
                                                        // multiply by weighthing factor
                resultACCB = __builtin_mpy(ftemp1, f2, NULL, NULL, 0, NULL, NULL, 0);
                ftemp1 = __builtin_sac(resultACCB, 0);   // Weighted new value
                //spi_send((ftemp1^0x8000)>>4);
                resultACCB = __builtin_clr();            // clear out accumulator
                                                        // multiply by weighthing factor
                resultACCB = __builtin_mpy(lo_ave, f1, NULL, NULL, 0, NULL, NULL, 0);
                ftemp2 = __builtin_sac(resultACCB, 0);   // weighted old value
                //
                //hi_ave = ftemp1 + ftemp22;
                resultACCB = __builtin_clr();            // clear out accumulator
                resultACCB = __builtin_add(resultACCB, ftemp1, 0);
                resultACCB = __builtin_add(resultACCB, ftemp2, 0);
                lo_ave = __builtin_sac(resultACCB, 0);
 
			
			
						Du har inte behörighet att öppna de filer som bifogats till detta inlägg.