Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Digital Signal Processing Coding Example, Summaries of Financial Market

A coding example for digital signal processing, specifically focusing on the aic23 codec and the generation of sine waves. The example includes various tables for sine values and global variables for buffer storage.

Typology: Summaries

2023/2024

Uploaded on 04/11/2024

kha-vy-5
kha-vy-5 🇻🇳

1 document

1 / 21

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
#include "dsk6416_aic23.h" //support file for codec,DSK Uint32 fs =
DSK6416_AIC23_FREQ_48KHZ;//set sampling rate short loop = 0; short loop1 = 0; short loop2 = 0;
short loop3 = 0; short loop4 = 0; short i=0; short j=0; short m=0; //table index short gain =
10; //gain factor short
sine_table[15]={0,406.7366,743.1448,951.0565,994.5219,866.0254,587.7853,207.9117,-207.9117,-
587.7853,-866.0254,-994.5219,-951.0565,-743.1448,406.7366};//sine values short
sine_table1[14]={ 0,433.8837,781.8315,974.9279,974.9279,781.8315,433.8837,0.0000,-433.8837,-
781.8315,-974.9279,-974.9279,-781.8315,-433.8837};
short sine_table1[12]={0,0.5000,0.8660,1.0000,0.8660,0.5000,0.0000,-0.5000,-0.8660,-1.0000,-
0.8660,-0.5000};
short sine_table1[12]={0,0.5000,0.8660,1.0000,0.8660,0.5000,0.0000,-0.5000,-0.8660,-1.0000,-
0.8660,-0.5000};
short sine_table1[10]={0,587.7853,951.0565,951.0565,587.7853,0.0000,-587.7853,-951.0565,-
951.0565,-587.7853};
short sine_table1[9]={0,642.7876,984.8078,866.0254,342.0201,-342.0201,-866.0254,-984.8078,-
642.7876};
#define BUFFSIZE 128 //
Global Variables Global Variables short
gBuffer[BUFFSIZE];
short aaa[BUFFSIZE];
short gBuffer1[BUFFSIZE];
short gBuffer2[BUFFSIZE];
short gBuffer3[BUFFSIZE];
short gBuffer4[BUFFSIZE];
short aaa1[BUFFSIZE];
short aaa2[BUFFSIZE];
void main()
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Partial preview of the text

Download Digital Signal Processing Coding Example and more Summaries Financial Market in PDF only on Docsity!

#include "dsk6416_aic23.h" //support file for codec,DSK Uint32 fs =

DSK6416_AIC23_FREQ_48KHZ;//set sampling rate short loop = 0; short loop1 = 0; short loop2 = 0;

short loop3 = 0; short loop4 = 0; short i=0; short j=0; short m=0; //table index short gain =

10; //gain factor short

sine_table[15]={ 0,406.7366,743.1448,951.0565,994.5219,866.0254,587.7853,207.9117,-207.9117,- 587.7853,-866.0254,-994.5219,-951.0565,-743.1448,406.7366} ;//sine values short sine_table1[14]={ 0,433.8837,781.8315,974.9279,974.9279,781.8315,433.8837,0.0000,-433.8837,- 781.8315,-974.9279,-974.9279,-781.8315,-433.8837}; short sine_table1[12]={0,0.5000,0.8660,1.0000,0.8660,0.5000,0.0000,-0.5000,-0.8660,-1.0000,- 0.8660,-0.5000}; short sine_table1[12]={0,0.5000,0.8660,1.0000,0.8660,0.5000,0.0000,-0.5000,-0.8660,-1.0000,- 0.8660,-0.5000}; short sine_table1[10]={0,587.7853,951.0565,951.0565,587.7853,0.0000,-587.7853,-951.0565,- 951.0565,-587.7853}; short sine_table1[9]={0,642.7876,984.8078,866.0254,342.0201,-342.0201,-866.0254,-984.8078,- 642.7876};

#define BUFFSIZE 128 //

Global Variables Global Variables short gBuffer[BUFFSIZE]; short aaa[BUFFSIZE]; short gBuffer1[BUFFSIZE]; short gBuffer2[BUFFSIZE]; short gBuffer3[BUFFSIZE]; short gBuffer4[BUFFSIZE]; short aaa1[BUFFSIZE]; short aaa2[BUFFSIZE];

void main ()

{ c6416_dsk_init();

DSK6416_LED_init(); //init LED from BSL DSK6416_DIP_init(); //init DIP from BSL while (1) //infinite loop { for (i=0; i< BUFFSIZE; i++) { if (DSK6416_DIP_get(0)==0) //=0 if DIP switch #0 pressed { DSK6416_LED_on(0);//turn LED #0 ON for (loop=0; loop <= 14; loop++) { output_left_sample(sine_table[loop]gain);//output sine values gBuffer[i+loop]=(sine_table[loop]gain); } if (loop == 15) i=i+loop-1, loop = 0 ; //check for end of table } else DSK6416_LED_off(0); } for (j=0; j< BUFFSIZE; j++) { if (DSK6416_DIP_get(1)==0) { for (loop1=0; loop1 <= 13; loop1++) { output_right_sample(sine_table1[loop1]gain);//output sine values gBuffer1[j+loop1]=(sine_table1[loop1]gain); } if (loop1 == 14) j=j+loop1-1, loop1 = 0 ; //check for end of table } else DSK6416_LED_off(1); } for (j=0; j< BUFFSIZE; j++)

if (loop4 == 9) j=j+loop4-1, loop4 = 0 ; //check for end of table

else DSK6416_LED_off(4);

for (m=0; m< BUFFSIZE; m++)

aaa[m]=gBuffer1[m]+gBuffer[m];

aaa1[m]=gBuffer3[m]+gBuffer2[m]

aaa2[m]=gBuffer5[m]+gBuffer[4]

KÌA CON BƯỚM VÀNG

#include "dsk6416_aic23.h"

Uint32 fs = DSK6416_AIC23_FREQ_4KHZ;

void notdof(float a);

void notre(float a);

void notmi(float a);

void notpha(float a);

void notson(float a);

void notla(float a);

void notsi(float a);

void notdos(float a);

void tre(int a);

short A = 5;

short

dof[ 15]={ 0,406.7366,743.1448,951.0565,994.5219,866.0254,587.7853,207.9117,-

207.9117,-587.7853,-866.0254,-994.5219,-951.0565,-743.1448,406.7366} ;//sine

values short

short

re[ 14]={ 0,433.8837,781.8315,974.9279,974.9279,781.8315,433.8837,0.0000,-

short mi[12]={0,0.5000,0.8660,1.0000,0.8660,0.5000,0.0000,-0.5000,-0.8660,-

short pha[12]={0,0.5000,0.8660,1.0000,0.8660,0.5000,0.0000,-0.5000,-0.8660,-

short son[10]={0,587.7853,951.0565,951.0565,587.7853,0.0000,-587.7853,-

short la[9]={0,642.7876,984.8078,866.0254,342.0201,-342.0201,-866.0254,-

short si[10]={0, 578, 943, 962, 628, 63, -525, -920, -977, -675};

short dos[9]={0, 637, 982, 876, 368, -309, -844, -992, -685};

short outdof[];

short outre[];

short outmi[];

short outpha[];

short outson[];

short outla[];

short outsi[];

short outdos[];

notson(1);

tre(1000);

notson(1);

notla(1);

notson(1);

notpha(0.7);

notmi(1);

notdof(0.4);

tre(1000);

notson(1);

notla(1);

notson(1);

notpha(0.7);

notmi(1);

notdof(0.4);

tre(1000);

notdof(0.5);

notson(1);

notdos(1);

notdof(0.5);

notson(1);

notdos(1);

tre(1000);

void tre(int a)

int i;

for(i=1;i<=a;i++)

output_sample(0);

void notdof(float a)// a la gia tri tinh bang giay (s);

unsigned int b,i,k;

b=a*440;

for(i=1;i<=b;i++)

for(k=0;k<=17;k++)

outdof[k]= dof[k]*A;

output_sample(outdof[k]);

for(k=0;k<=14;k++)

outmi[k]= mi[k]*A;

output_sample(outmi[k]);

void notpha(float a)

unsigned int b,i,k;

b=a*587;

for(i=1;i<=b;i++)

for(k=0;k<=12;k++)

outpha[k]= pha[k]*A;

output_sample(outpha[k]);

void notson(float a)

unsigned int b,i,k;

b=a*660;

for(i=1;i<=b;i++)

for(k=0;k<=11;k++)

outson[k]= son[k]*A;

output_sample(outson[k]);

void notla(float a)

unsigned int b,i,k;

b=a*699;

for(i=1;i<=b;i++)

for(k=0;k<=10;k++)

outla[k]= la[k]*A;

output_sample(outla[k]);

void notsi(float a)

unsigned int b,i,k;

#include "dsk6416_aic23.h" Uint32 fs = DSK6416_AIC23_FREQ_8KHZ; void notdof ( float a); void notre ( float a); void notmi ( float a); void notpha ( float a); void notson ( float a); void notla ( float a); void notsi ( float a); void notdos ( float a); void tre ( int a); short A = 5; short dof[18]={0, 339, 637, 861, 982, 988, 876, 661, 368, 31, -309, -613, - 844, -976, -992, -891, -685, -397}; short re[16]={0, 378, 700, 918, 1000, 933, 727, 413, 38, -343, -673, -903, - 998, -946, -752, -447}; short mi[15]={0, 400, 733, 944, 997, 884, 623, 258, -150, -533, -827, -983, - 975, -803, -498}; short pha[13]={0, 445, 797, 982, 963, 742, 367, -86, -520, -846, -995, -936, -682}; short son[12]={0, 495, 861, 1000, 876, 522, 31, -468, -844, -999, -891, - 549}; short la[11]={0, 522, 890, 997, 811, 386, -152, -645, -949, -974, -713}; short si[10]={0, 578, 943, 962, 628, 63, -525, -920, -977, -675}; short dos[9]={0, 637, 982, 876, 368, -309, -844, -992, -685}; short outdof[]; short outre[]; short outmi[]; short outpha[]; short outson[]; short outla[]; short outsi[]; short outdos[]; void main () { c6416_dsk_init(); DSK6416_LED_init(); //init LED from BSL DSK6416_DIP_init(); //init DIP from BSL while (1) { notdof(0.4); notre(0.4); notmi(0.4); notdof(0.4); tre(1000); notdof(0.4); notre(0.4); notmi(0.4);

notdof(0.4); tre(1000); notmi(0.7); notpha(1); notson(1); tre(1000); notmi(0.7); notpha(1); notson(1); tre(1000); notson(1); notla(1); notson(1); notpha(0.7); notmi(1); notdof(0.4); tre(1000); notson(1); notla(1); notson(1); notpha(0.7); notmi(1); notdof(0.4); tre(1000); notdof(0.5); notson(1); notdos(1); notdof(0.5); notson(1); notdos(1); tre(1000); } } void tre ( int a) { int i; for (i=1;i<=a;i++) { output_sample(0); } } void notdof ( float a)// a la gia tri tinh bang giay (s); { unsigned int b,i,k; b=a440; for (i=1;i<=b;i++) { for (k=0;k<=17;k++) { outdof[k]= dof[k]A;

output_sample(outson[k]); } } } void notla ( float a) { unsigned int b,i,k; b=a699; for (i=1;i<=b;i++) { for (k=0;k<=10;k++) { outla[k]= la[k]A; output_sample(outla[k]); } } } void notsi ( float a) { unsigned int b,i,k; b=a784; for (i=1;i<=b;i++) { for (k=0;k<=9;k++) { outsi[k]= si[k]A; output_sample(outsi[k]); } } } void notdos ( float a) { unsigned int b,i,k; b=a880; for (i=1;i<=b;i++) { for (k=0;k<=8;k++) { outdos[k]= dos[k]A; output_sample(outdos[k]); } } } C2: #include "dsk6416_aic23.h" Uint32 fs = DSK6416_AIC23_FREQ_8KHZ; void notdof ( float a);

void notre ( float a); void notmi ( float a); void notpha ( float a); void notson ( float a); void notla ( float a); void notsi ( float a); void notdos ( float a); void notsonf ( float a); void tre ( int a); short A = 5; short dof[18]={0, 339, 637, 861, 982, 988, 876, 661, 368, 31, -309, -613, - 844, -976, -992, -891, -685, -397}; short re[16]={0, 378, 700, 918, 1000, 933, 727, 413, 38, -343, -673, -903, - 998, -946, -752, -447}; short mi[15]={0, 400, 733, 944, 997, 884, 623, 258, -150, -533, -827, -983, - 975, -803, -498}; short pha[13]={0, 445, 797, 982, 963, 742, 367, -86, -520, -846, -995, -936, -682}; short son[12]={0, 495, 861, 1000, 876, 522, 31, -468, -844, -999, -891, - 549}; short la[11]={0, 522, 890, 997, 811, 386, -152, -645, -949, -974, -713}; short si[10]={0, 578, 943, 962, 628, 63, -525, -920, -977, -675}; short dos[9]={0, 637, 982, 876, 368, -309, -844, -992, -685}; short sonf[125]={ 0,50,100,150,200,249,297,345,391, ,482,525,567,608,647,685,720,754,786, ,844,870,894,915,934,951,965,977,987, ,998,1000,999,996,990,982,972,959,943, ,905,882,858,831,802,771,738,703,666, ,588,546,504,460,414,368,321,273,224, ,125,75,25,-25,-75,-125,-175,-224,-273,- ,-368,-414,-460,-504,-546,-588,-628,-666,-703,- ,-771,-802,-831,-858,-882,-905,-925,-943,-959,- ,-982,-990,-996,-999,-1000,-998,-994,-987,-977,- ,-951,-934,-915,-894,-870,-844,-816,-786,-754,- ,-685,-647,-608,-567,-525,-482,-437,-391,-345,- ,-249,-200,-150,-100,- }; short outdof[]; short outre[]; short outmi[]; short outpha[]; short outson[]; short outla[]; short outsi[]; short outdos[]; short outsonf[]; void main () {

output_sample(0); } } void notdof ( float a)// a la gia tri tinh bang giay (s); { unsigned int b,i,k; b=a262; for (i=1;i<=b;i++) { for (k=0;k<=17;k++) { outdof[k]= dof[k]A; output_sample(outdof[k]); } } } void notre ( float a) { unsigned int b,i,k; b=a294; for (i=1;i<=b;i++) { for (k=0;k<=15;k++) { outre[k]= re[k]A; output_sample(outre[k]); } } } void notmi ( float a) { unsigned int b,i,k; b=a330; for (i=1;i<=b;i++) { for (k=0;k<=14;k++) { outmi[k]= mi[k]A; output_sample(outmi[k]); } } } void notpha ( float a) { unsigned int b,i,k; b=a*350; for (i=1;i<=b;i++) { for (k=0;k<=12;k++) {

outpha[k]= pha[k]A; output_sample(outpha[k]); } } } void notson ( float a) { unsigned int b,i,k; b=a392; for (i=1;i<=b;i++) { for (k=0;k<=11;k++) { outson[k]= son[k]A; output_sample(outson[k]); } } } void notla ( float a) { unsigned int b,i,k; b=a440; for (i=1;i<=b;i++) { for (k=0;k<=10;k++) { outla[k]= la[k]A; output_sample(outla[k]); } } } void notsi ( float a) { unsigned int b,i,k; b=a494; for (i=1;i<=b;i++) { for (k=0;k<=9;k++) { outsi[k]= si[k]A; output_sample(outsi[k]); } } } void notdos ( float a) { unsigned int b,i,k; b=a523; for (i=1;i<=b;i++) { for (k=0;k<=8;k++) { outdos[k]= dos[k]*A;