본문내용
print(double *input, FILE *output)
{
int t;
for(t=0 ; t
fprintf(output,"%f\n",input[t]);
}
}
void freqprint(double *input, FILE *output)
{
int t;
for(t=(int)fs/2 ; t
fprintf(output,"%f\n",input[t]);
}
for(t=0 ; t
fprintf(output,"%f\n",input[t]);
}
}
void mag(double *mag,double *real,double *image)
{
int i;
for(i=0;i
{//magnitude 연산
mag[i] = sqrt(real[i]*real[i] + image[i]*image[i]);
}
}
void LPF(double *real,double *image,int mag,int cutoff, int phasecutoff,double phase)
{
int i;
for (i=0;i
{
if ( i<=cutoff || i>=fs-cutoff ){//cutoff frequency 안의 부분이다.
real[i]=mag;//
image[i]=0;
}
else{//cutoff frequency 밖의 부분으로 모두 0이 된다.
real[i]=0;
image[i]=0;
}
}
for(i=0;i
{
if ( i<=phasecutoff )//cutoff 주파수 안이면서 주파수 축에서 양인 부분
{
real[i] = mag*cos(phase*(double)i);
image[i] = mag*sin(phase*(double)i);
}
else if ( i>=fs-phasecutoff )//cutoff 주파수 안이면서 주파수 축에서 음인 부분
{
real[i] = mag*cos( phase* (-fs+(double)i ) );
image[i] = mag*sin( phase* (-fs+(double)i ) );
}
}
}
void passft(double *in_real, double *in_image, double *ft_real, double *ft_image, double *out_real, double *out_image)
{
int i;
for(i=0;i
out_real[i]= in_real[i]*ft_real[i] - in_image[i]*ft_image[i];
out_image[i] = in_real[i]*ft_image[i] + in_image[i]*ft_real[i];
}
}
void DSB_SC_MODUL(double *in_real,double *in_image,double fc,double *out_real,double *out_image){
int t;
double a;
a=1/fs;
for(t=0;t
out_real[t] = in_real[t]*2*cos(2*pi*fc*a*(double)t);//이건 메세지에 캐리어 곱한 즉 ut
out_image[t] = 0.0;
}
}
void BPF(double *real,double *image,int mag,int cutoff1,int cutoff2)
{//BPF생성
int i;
for (i=0;i
{
if ( i>=cutoff1 && i<=cutoff1+cutoff2 ){//양수부분에서 보존되는 주파수 사이일때
real[i]=mag;
image[i]=0;
}
else if ( i>=fs-cutoff1-cutoff2 && i<=fs-cutoff1){//음수부분에서 보존되는 주파수 사이일때
real[i]=mag;
image[i]=0;
}
else{//나머지 부분은 잘라준다.
real[i]=0;
image[i]=0;
}
}
}
(6) fft.h
#include
void FFT(short int dir,long m,double *x,double *y)
{
long n,i,i1,j,k,i2,l,l1,l2;
double c1,c2,tx,ty,t1,t2,u1,u2,z;
/* Calculate the number of points */
n = 1;
for (i=0;i
n *= 2;
/* Do the bit reversal */
i2 = n >> 1;
j = 0;
for (i=0;i
if (i < j) {
tx = x[i];
ty = y[i];
x[i] = x[j];
y[i] = y[j];
x[j] = tx;
y[j] = ty;
}
k = i2;
while (k <= j) {
j -= k;
k >>= 1;
}
j += k;
}
/* Compute the FFT */
c1 = -1.0;
c2 = 0.0;
l2 = 1;
for (l=0;l
l1 = l2;
l2 <<= 1;
u1 = 1.0;
u2 = 0.0;
for (j=0;j
for (i=j;i
i1 = i + l1;
t1 = u1 * x[i1] - u2 * y[i1];
t2 = u1 * y[i1] + u2 * x[i1];
x[i1] = x[i] - t1;
y[i1] = y[i] - t2;
x[i] += t1;
y[i] += t2;
}
z = u1 * c1 - u2 * c2;
u2 = u1 * c2 + u2 * c1;
u1 = z;
}
c2 = sqrt((1.0 - c1) / 2.0);
if (dir == 1)
c2 = -c2;
c1 = sqrt((1.0 + c1) / 2.0);
}
/* Scaling for forward transform */
if (dir == 1) {
for (i=0;i
x[i] /= n;
y[i] /= n;
}
}
}
{
int t;
for(t=0 ; t
}
}
void freqprint(double *input, FILE *output)
{
int t;
for(t=(int)fs/2 ; t
}
for(t=0 ; t
}
}
void mag(double *mag,double *real,double *image)
{
int i;
for(i=0;i
mag[i] = sqrt(real[i]*real[i] + image[i]*image[i]);
}
}
void LPF(double *real,double *image,int mag,int cutoff, int phasecutoff,double phase)
{
int i;
for (i=0;i
if ( i<=cutoff || i>=fs-cutoff ){//cutoff frequency 안의 부분이다.
real[i]=mag;//
image[i]=0;
}
else{//cutoff frequency 밖의 부분으로 모두 0이 된다.
real[i]=0;
image[i]=0;
}
}
for(i=0;i
if ( i<=phasecutoff )//cutoff 주파수 안이면서 주파수 축에서 양인 부분
{
real[i] = mag*cos(phase*(double)i);
image[i] = mag*sin(phase*(double)i);
}
else if ( i>=fs-phasecutoff )//cutoff 주파수 안이면서 주파수 축에서 음인 부분
{
real[i] = mag*cos( phase* (-fs+(double)i ) );
image[i] = mag*sin( phase* (-fs+(double)i ) );
}
}
}
void passft(double *in_real, double *in_image, double *ft_real, double *ft_image, double *out_real, double *out_image)
{
int i;
for(i=0;i
out_image[i] = in_real[i]*ft_image[i] + in_image[i]*ft_real[i];
}
}
void DSB_SC_MODUL(double *in_real,double *in_image,double fc,double *out_real,double *out_image){
int t;
double a;
a=1/fs;
for(t=0;t
out_image[t] = 0.0;
}
}
void BPF(double *real,double *image,int mag,int cutoff1,int cutoff2)
{//BPF생성
int i;
for (i=0;i
if ( i>=cutoff1 && i<=cutoff1+cutoff2 ){//양수부분에서 보존되는 주파수 사이일때
real[i]=mag;
image[i]=0;
}
else if ( i>=fs-cutoff1-cutoff2 && i<=fs-cutoff1){//음수부분에서 보존되는 주파수 사이일때
real[i]=mag;
image[i]=0;
}
else{//나머지 부분은 잘라준다.
real[i]=0;
image[i]=0;
}
}
}
(6) fft.h
#include
void FFT(short int dir,long m,double *x,double *y)
{
long n,i,i1,j,k,i2,l,l1,l2;
double c1,c2,tx,ty,t1,t2,u1,u2,z;
/* Calculate the number of points */
n = 1;
for (i=0;i
/* Do the bit reversal */
i2 = n >> 1;
j = 0;
for (i=0;i
tx = x[i];
ty = y[i];
x[i] = x[j];
y[i] = y[j];
x[j] = tx;
y[j] = ty;
}
k = i2;
while (k <= j) {
j -= k;
k >>= 1;
}
j += k;
}
/* Compute the FFT */
c1 = -1.0;
c2 = 0.0;
l2 = 1;
for (l=0;l
l2 <<= 1;
u1 = 1.0;
u2 = 0.0;
for (j=0;j
t1 = u1 * x[i1] - u2 * y[i1];
t2 = u1 * y[i1] + u2 * x[i1];
x[i1] = x[i] - t1;
y[i1] = y[i] - t2;
x[i] += t1;
y[i] += t2;
}
z = u1 * c1 - u2 * c2;
u2 = u1 * c2 + u2 * c1;
u1 = z;
}
c2 = sqrt((1.0 - c1) / 2.0);
if (dir == 1)
c2 = -c2;
c1 = sqrt((1.0 + c1) / 2.0);
}
/* Scaling for forward transform */
if (dir == 1) {
for (i=0;i
y[i] /= n;
}
}
}
키워드
추천자료
[DMB]DMB(디지털멀티미디어방송)-위성DMB, 지상파DMB의 특성, 현황과 DMB(디지털멀티미디어방...
[DMB]DMB(디지털멀티미디어방송) 의의, DMB(디지털멀티미디어방송) 장점, DMB(디지털멀티미디...
DMB(디지털멀티미디어방송)의 현황, DMB(디지털멀티미디어방송)의 문제점, DMB(디지털멀티미...
[DRM][디지털저작권관리][디지털저작권보호]디지털저작물에 대한 DRM(디지털저작권관리), 저...
[DMB][디지털멀티미디어방송]DMB-디지털멀티미디어방송의 도입과 DMB-디지털멀티미디어방송의...
[DMB][디지털멀티미디어방송]DMB(디지털멀티미디어방송)의 도입, 목적, 정책과 DMB(디지털멀...
전자도서관(디지털도서관)의 개념과 특징, 전자도서관(디지털도서관)의 필요성과 기능, 전자...
[DRM]DRM(디지털저작권관리)의 의미, DRM(디지털저작권관리)의 현황, DRM(디지털저작권관리)...
[DOI][디지털객체식별자][DOI][디지털객체식별자]DOI(디지털객체식별자)의 특징, DOI(디지털...
[DOI]DOI(디지털객체식별자)의 개념, DOI(디지털객체식별자)의 특성, DOI(디지털객체식별자)...
[DRM]DRM(디지털저작권관리)의 개념과 특징, DRM(디지털저작권관리)의 업체 동향, DRM(디지털...
DRM(디지털저작권관리)의 정의와 업체 동향, DRM(디지털저작권관리)의 영향, DRM(디지털저작...
[전자도서관] 디지털 도서관에 대하여 (디지털도서관 설립배경과 정보기술 도입배경, 디지털...
[디지로그, 아날로그와 디지털 융합] 디지털과 아날로그 - 디지털 시대에 잊지 말아야 할 아...
소개글