这个程序难道是要把TXT变MID!~
c语言吧
全部回复
仅看楼主
level 1
/* file rec.cppby dustin caldwell ([email protected])*/#include
#include
#include
#include
void helpdoc();main(int argc,char *argv[]){FILE *rfp, *wfp;unsigned char ch, c;char s[20];if((rfp=fopen(argv[1], "r"))==NULL) /* open the read file */{printf("cannot open file %s \n",argv[1]);helpdoc();exit(-1);}if((wfp=fopen(argv[2], "wb"))==NULL) /* open the write file */{printf("cannot open file %s \n",argv[1]);helpdoc();exit(-1);}c=0;ch=fgetc(rfp);while(!feof(rfp)) /* loop for whole file */{if(isalnum(ch)) /* only 'see' valid ascii chars */{c=0;while(isdigit(ch)) /* only use decimal digits (0-9) */{s[c]=ch; /* build a string containing the number */c++;ch=fgetc(rfp);}s[c]=NULL; /* must have null terminator */fputc(atoi(s), wfp);/* write the binary equivalent to file */}ch=fgetc(rfp); /* loop until next number starts */}fclose(rfp); /* close up */fclose(wfp);}void helpdoc() /* print help message */{printf("\n text file encoder\n\n");printf("\n syntax: rec text_file_name binary_file_name\n\n");printf("by dustin caldwell ([email protected])\n\n");printf("this is a program that reads an ascii tab-\n");printf("delimited file and builds a binary file where\n");printf("each byte of the binary file is one of the decimal\n");printf("digits in the text file.\n");printf(" eg:\n\n");printf("c:\>rec son3.txt son3.mid\n\n");printf("(this will create a file called son3.mid which is\n");printf("a valid binary file)\n\n");printf("(dec.exe may also be useful, as it decodes binary files)\n\n");printf("have fun!!\n");}
2005年10月21日 14点10分 1
level 1
我是从网路上看到滴,一篇讲MIDI格式的文章最后留下这个原代码,我随便写了个TXT,用程序换成MID不能播放汗...原文地址如下http://www.moon-soft.com/program/FORMAT/sound/mid1.htm
2005年10月21日 14点10分 2
1