怎样利用visual c++生成.mif文件
2个回答
展开全部
可以根据mif文件的格式编写,我给你个生成正弦波的mif格式的c++,波形可以随自己设定
#include<iostream.h>
#include<fstream.h>
#include<math.h>
void main()
{
double pi=3.141593;
double step=pi*2/256;
ofstream outfile;
outfile.open("sin.mif");
outfile<<"--Maxplus Memory Initiallization File"<<endl;
outfile<<"--sin.mif"<<endl;
outfile<<"WIDTH=8;"<<endl;
outfile<<"DEPTH=256;"<<endl;
outfile<<"ADDRESS_RADIX=HEX;"<<endl;
outfile<<"DATA_RADIX=DEC;"<<endl<<endl;
outfile<<"CONTENT BEGIN"<<endl;
for(int i=0;i<256;i++)
{
outfile<<hex<<i<<" : "<<dec<<int((sin(i*step)+1)/2*255+0.5)<<";"<<endl;
}
outfile<<"END;";
}
#include<iostream.h>
#include<fstream.h>
#include<math.h>
void main()
{
double pi=3.141593;
double step=pi*2/256;
ofstream outfile;
outfile.open("sin.mif");
outfile<<"--Maxplus Memory Initiallization File"<<endl;
outfile<<"--sin.mif"<<endl;
outfile<<"WIDTH=8;"<<endl;
outfile<<"DEPTH=256;"<<endl;
outfile<<"ADDRESS_RADIX=HEX;"<<endl;
outfile<<"DATA_RADIX=DEC;"<<endl<<endl;
outfile<<"CONTENT BEGIN"<<endl;
for(int i=0;i<256;i++)
{
outfile<<hex<<i<<" : "<<dec<<int((sin(i*step)+1)/2*255+0.5)<<";"<<endl;
}
outfile<<"END;";
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询