1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
| #include <iostream>
#include<fstream>
#include<cstring>
#define CHSIZE 9
#define LPC_ORD 10 /* LPC order */
#define NUM_GAINFR 2 /* number of gains per frame */
#define NUM_BANDS 5 /* number of frequency bands */
#define NUM_HARM 10 /* number of Fourier magnitudes */
struct melp_param { /* MELP parameters */
float pitch;
float lsf[LPC_ORD+1];
float gain[NUM_GAINFR];
float jitter;
float bpvc[NUM_BANDS];
int pitch_index;
int lsf_index[LPC_ORD];
int jit_index;
int bpvc_index;
int gain_index[NUM_GAINFR];
unsigned int *chptr;
int chbit;
int uv_flag;
float fs_mag[NUM_HARM];
int *fsvq_index;
int *msvq_index;
int msvq_stages;
int *msvq_bits;
int *msvq_levels;
};
using namespace std;
int main()
{
struct melp_param chbuf;
ifstream intbal("data.bit",ios::in | ios::binary);
if (!intbal)
{
cout<<"can't open the file."<<endl;
return 1;
}
intbal.read((char *)&chbuf,sizeof(struct melp_param));
int i,j;
int packet=0;
for(i=0;i<sizeof(struct melp_param);i++)
{
cout<<"pitch:"<<chbuf.pitch<<endl;
for( j=0;j<LPC_ORD+1;j++)
{
cout<<"LSF: "<<chbuf.lsf[j]<<endl;
}
for(j=0;j<NUM_GAINFR;j++)
{
cout<<"GAIN: "<<chbuf.gain[j]<<endl;
}
cout<<"JITTER: "<<chbuf.jitter<<endl;
for(j=0;j<NUM_BANDS;j++)
{
cout<<"bpvc: "<<chbuf.bpvc[j]<<endl;
}
cout<<"pitch_index: "<<chbuf.pitch_index<<endl;
for(j=0;j<LPC_ORD;j++)
{
cout<<"LSF INDEX: "<<chbuf.lsf_index[j]<<endl;
}
cout<<"jit_index: $"<<chbuf.jit_index<<endl;
cout<<"uv_flag: $"<<chbuf.uv_flag<<endl;
cout<<"uv_flag: $"<<chbuf.bpvc_index<<endl;
for(j=0;j<NUM_GAINFR;j++)
{
cout<<"GAIN INDEX: "<<chbuf.gain_index[j]<<endl;
}
cout<<"channel pointer: $"<<&chbuf.chptr<<endl;
cout<<"channel pointer: $"<<chbuf.chbit<<endl;
cout<<"channel pointer: $"<<chbuf.uv_flag<<endl;
for(j=0;j<NUM_HARM;j++)
{
cout<<"fourier_MAG: "<<chbuf.fs_mag[j]<<endl;
}
cout<<"fsvq_index: $"<<chbuf.fsvq_index<<endl;
cout<<"msvq_index: $"<<chbuf.msvq_index<<endl;
cout<<"msvq_stages: $"<<chbuf.msvq_stages<<endl;
cout<<"msvq_bits: $"<<chbuf.msvq_bits<<endl;
cout<<"msvq_bits: $"<<chbuf.msvq_bits<<endl;
cout<<"msvq_LEVELS: $"<<chbuf.msvq_levels<<endl;
packet++;
cout<<"frame="<<packet<<endl;
}
intbal.close();
return 0;
} |
Partager