S
sweeet_addiction16
hello experts...pls help me debug this code........im not able to
write in the data bytes ..only the few header bytes are written...
#include<stdio.h>
struct mthd_chunk
{
char id[4];
unsigned long Length; /* This will be 6 */
/* Here are the 6 bytes */
unsigned short Format;
unsigned short NumTrack;
unsigned short Division;
};
struct MTRK_CHUNK
{
/* Here's the 8 byte header that all chunks must have */
char ID[4]; /* This will be 'M','T','r','k' */
unsigned long Length; /* This will be the actual size of
Data[] */
/* Here are the data bytes */
unsigned char Data[20]; /* Its actual size is Data[Length]
*/
};
int main()
{
FILE *fp;
struct mthd_chunk mthd;
struct MTRK_CHUNK mtrk;
mthd.id[0]=0x4d;
mthd.id[1]=0x54;
mthd.id[2]=0x68;
mthd.id[3]=0x64;
mthd.Length=0x00000006;
mthd.Format=0x0000;
mthd.NumTrack=0x0001;
mthd.Division=0x0080;
mtrk.ID[0]=0x4d;
mtrk.ID[1]=0x54;
mtrk.ID[2]=0x72;
mtrk.ID[3]=0x6b;
mtrk.Length=0x0000000d;
mtrk.Data[0]=0x40;
mtrk.Data[1]=0x90;
mtrk.Data[2]=0x3c;
mtrk.Data[3]=0x1e;
mtrk.Data[4]=0x82;
mtrk.Data[5]=0x00;
mtrk.Data[6]=0x90;structures in c
mtrk.Data[7]=0x3c;
mtrk.Data[8]=0x00;
mtrk.Data[9]=0x00;
mtrk.Data[10]=0xff;
mtrk.Data[11]=0x2f;
mtrk.Data[12]=0x00;
fp=fopen("star.mid","w");
fwrite(&mthd,sizeof mthd,1,fp);
fwrite(&mtrk,sizeof mtrk,1,fp);
}
write in the data bytes ..only the few header bytes are written...
#include<stdio.h>
struct mthd_chunk
{
char id[4];
unsigned long Length; /* This will be 6 */
/* Here are the 6 bytes */
unsigned short Format;
unsigned short NumTrack;
unsigned short Division;
};
struct MTRK_CHUNK
{
/* Here's the 8 byte header that all chunks must have */
char ID[4]; /* This will be 'M','T','r','k' */
unsigned long Length; /* This will be the actual size of
Data[] */
/* Here are the data bytes */
unsigned char Data[20]; /* Its actual size is Data[Length]
*/
};
int main()
{
FILE *fp;
struct mthd_chunk mthd;
struct MTRK_CHUNK mtrk;
mthd.id[0]=0x4d;
mthd.id[1]=0x54;
mthd.id[2]=0x68;
mthd.id[3]=0x64;
mthd.Length=0x00000006;
mthd.Format=0x0000;
mthd.NumTrack=0x0001;
mthd.Division=0x0080;
mtrk.ID[0]=0x4d;
mtrk.ID[1]=0x54;
mtrk.ID[2]=0x72;
mtrk.ID[3]=0x6b;
mtrk.Length=0x0000000d;
mtrk.Data[0]=0x40;
mtrk.Data[1]=0x90;
mtrk.Data[2]=0x3c;
mtrk.Data[3]=0x1e;
mtrk.Data[4]=0x82;
mtrk.Data[5]=0x00;
mtrk.Data[6]=0x90;structures in c
mtrk.Data[7]=0x3c;
mtrk.Data[8]=0x00;
mtrk.Data[9]=0x00;
mtrk.Data[10]=0xff;
mtrk.Data[11]=0x2f;
mtrk.Data[12]=0x00;
fp=fopen("star.mid","w");
fwrite(&mthd,sizeof mthd,1,fp);
fwrite(&mtrk,sizeof mtrk,1,fp);
}