sgopen.com
上传用户:szhypcb168
上传日期:2007-01-06
资源大小:2187k
文件大小:11k
源码类别:

语音压缩

开发平台:

Unix_Linux

  1. C===========================================================================
  2. C
  3. C    SUNGRAPH OPEN FILE AND DEFINE VARIABLE (doesn't apply to PC release)
  4. C
  5. C===========================================================================
  6. C
  7. C *** SUNGRAPH FILES AND VARIABLES
  8. C
  9. C ifile.spd    input file
  10. C
  11. C ifile_ofile.sg_data    input and output file 
  12. C    'ifile' 'ifile_hp' 
  13. C    'ofile_npf' 'ofile_pf' 'ofile_hpf'
  14. C
  15. C channel.sg_data    4800 bps bit stream
  16. C    'stream'
  17. C
  18. C stream_error.sg_data    4800 bps bit stream with errors
  19. C    'stream' 'stream_error' 'stream_error_s' 
  20. C    'error'
  21. C
  22. C lsp1.sg_data    line spectral pairs file on a frame basis
  23. C    comparing unquantized and quantized
  24. C      'lsp 1' 'lsp 2' ... 'lsp10' ...
  25. C    'qlsp 1' ...  'qlsp10'
  26. C    'qslsp 1' ... 'qslsp10'
  27. C
  28. C lsp2.sg_data    line spectral pairs file on a subframe basis
  29. C    comparing analysis and synthesis
  30. C    'lsp_analy 1' 'lsp_analy 2' ...
  31. C    'lsp_synth 1' 'lsp_synth 2' ...
  32. C
  33. C pitch.sg_data    pitch variables 
  34. C    'match' 'tau' tau_synth' 'ir'
  35. C    'gain' 'qgain' 'qgain_synth'
  36. C
  37. C constrain.sg_data    constrained excitation data
  38. C    'gain', 'ccor', 'dbcon'
  39. C
  40. C codebook.sg_data    code book variables
  41. C    'match' 'index' 'index_synth' 'exc' 'ir'
  42. C    'gain' 'qgain' 'qgain_synth'
  43. C
  44. C error.sg_data    error signals
  45. C    'fndpp_e0' 'fndpp_v0' 'fndex_e0'
  46. C
  47. C rc.sg_data    reflection coeficients
  48. C    'rc 1' 'rc2' ... 'rc10' ...
  49. C
  50. C**************************************************************************
  51. c
  52. c *** open files and define variables in sungraph format
  53. c
  54. c
  55. c * disable disk_io auto error reporting
  56. call disk_io_erh(0)
  57. c
  58. c * open input speech file
  59. temp_fname=ifile
  60. I=index(temp_fname,' ')
  61. temp_fname(I:I)=char(0)
  62. input_fid=open_var_channel(temp_fname,'speech_data')
  63. if (input_fid .lt. 0) call read_error(input_fid,' open input_fid')
  64. c
  65. c * open input_output speech file (4 variables)
  66. ifile_ofile_fid=open_file('ifile_ofile' // char(0),1)
  67. if (ifile_ofile_fid .lt. 0) call write_error(ifile_ofile_fid,
  68.      &  'open ifile_ofile_fid')
  69. c
  70. c * define input_output speech variables
  71. ifile_vid=def_variable(ifile_ofile_fid,'ifile' // char(0),r4,ll,0)
  72. if (ifile_vid .lt. 0) call write_error(ifile_vid,'define ifile_vid')
  73. ifile_hp_vid=def_variable(ifile_ofile_fid,'ifile_hp' // 
  74.      &  char(0),r4,ll,0.0)
  75. if (ifile_hp_vid .lt. 0) call write_error(ifile_hp_vid,
  76.      &  'define ifile_hp_vid')
  77. ofile_npf_vid=def_variable(ifile_ofile_fid,'ofile_npf' // 
  78.      &  char(0),i2,ll,0)
  79. if (ofile_npf_vid .lt. 0) call write_error(ofile_npf_vid,
  80.      &  'define ofile_npf_vid')
  81. ofile_pf_vid=def_variable(ifile_ofile_fid,'ofile_pf' // 
  82.      &  char(0),i2,ll,0)
  83. if (ofile_pf_vid .lt. 0) call write_error(ofile_pf_vid,
  84.      &  'define ofile_pf_vid')
  85. ofile_hpf_vid=def_variable(ifile_ofile_fid,'ofile_hpf' // 
  86.      &  char(0),i2,ll,0)
  87. if (ofile_hpf_vid .lt. 0) call write_error(ofile_hpf_vid,
  88.      &  'define ofile_hpf_vid')
  89. c
  90. c * open channel file
  91. channel_fid=open_file('channel' // char(0),1)
  92. if (channel_fid .lt. 0) call write_error(channel_fid,
  93.      &  'open channel_fid')
  94. c
  95. c * define channel variable
  96. channel_vid=def_variable(channel_fid,'stream' //char(0),
  97.      &  1,streambits,0)
  98. if (channel_vid .lt. 0) call write_error(channel_vid,
  99.      &  'define channel_vid')
  100. c
  101. c * open stream_error file
  102. stream_error_fid=open_file('stream_error' // char(0),1)
  103. if (stream_error_fid .lt. 0) call write_error(stream_error_fid,
  104.      &  'open stream_error_fid')
  105. c
  106. c * define stream_error variables
  107. stream_vid=def_variable(stream_error_fid,'stream' //char(0),
  108.      &  1,streambits,0)
  109. if (stream_vid .lt. 0) call write_error(stream_vid,
  110.      &  'define stream_vid')
  111. stream_error_vid=def_variable(stream_error_fid,
  112.      &  'stream_error'//char(0),1,streambits,0)
  113. if (stream_error_vid .lt. 0) call write_error(stream_error_vid,
  114.      &  'define stream_error_vid')
  115. stream_error_s_vid=def_variable(stream_error_fid,
  116.      &  'stream_error_s'//char(0),1,streambits,0)
  117. if (stream_error_s_vid .lt. 0) call write_error(stream_error_s_vid,
  118.      &  'define stream_error_s_vid')
  119. bit_error_vid=def_variable(stream_error_fid,
  120.      &  'bit_error' //char(0),1,streambits,0)
  121. if (bit_error_vid .lt. 0) call write_error(bit_error_vid,
  122.      &  'define bit_error_vid')
  123. c
  124. c * open lsp1 file (number of variables = order)
  125. lsp1_fid=open_file('lsp1' // char(0), 1)
  126. if (lsp1_fid .lt. 0) call write_error(lsp1_fid,'open lsp1_fid')
  127. c
  128. c * define lsp and qlsp variables 
  129. do 90 i=1,no
  130.    write(str,91) i,0
  131. 91    format('lsp',i2,a)
  132.    lsp_vid(i)=def_variable(lsp1_fid, str, r4, 1, 0.0)
  133.    if (lsp_vid(i) .lt. 0) call write_error(lsp_vid(i),
  134.      &     'define lsp_vid')
  135.    write(str,92) i,0
  136. 92    format('qlsp',i2,a)
  137.    qlsp_vid(i)=def_variable(lsp1_fid, str, r4, 1, 0.0)
  138.    if (qlsp_vid(i) .lt. 0) call write_error(qlsp_vid(i),
  139.      &     'define qlsp_vid')
  140. 90 continue
  141. c
  142. c * open lsp2 file (number of variables = order)
  143. lsp2_fid=open_file('lsp2' // char(0), 1)
  144. if (lsp2_fid .lt. 0) call write_error(lsp2_fid,'open lsp2_fid')
  145. c
  146. c * define qlsp variables
  147. do 93 i=1,no
  148.    write(str,94) i,0
  149. 94    format('lsp_analy',i2,a)
  150.    lsp_analy_vid(i)=def_variable(lsp2_fid, str, r4, nn, 0.0)
  151.    if (lsp_analy_vid(i) .lt. 0) call write_error(lsp_analy_vid(i),
  152.      &     'define lsp_analy_vid')
  153.    write(str,95) i,0
  154. 95    format('lsp_synth',i2,a)
  155.    lsp_synth_vid(i)=def_variable(lsp2_fid, str, r4, nn, 0.0)
  156.    if (lsp_synth_vid(i) .lt. 0) call write_error(lsp_synth_vid(i),
  157.      &     'define lsp_synth_vid')
  158. 93    continue
  159. c
  160. c *open pitch file
  161. pitch_fid=open_file('pitch' // char(0),1)
  162. if (pitch_fid .lt. 0) call write_error(pitch_fid,
  163.      &  'open pitch_fid')
  164. c
  165. c *define pitch variables
  166. pitch_match_vid=def_variable(pitch_fid,'match' // char(0),r4,
  167.      &  nn*plevel1,0.0)
  168. if (pitch_match_vid .lt. 0) call write_error(pitch_match_vid,
  169.      &  'define pitch_match_vid')
  170. pitch_tau_vid=def_variable(pitch_fid,'tau' // char(0),r4,nn,0)
  171. if (pitch_tau_vid .lt. 0) call write_error(pitch_tau_vid,
  172.      &  'define pitch_tau_vid')
  173. pitch_tau_synth_vid=def_variable(pitch_fid,'tau_synth' // char(0),
  174.      &  r4,nn,0)
  175. if (pitch_tau_synth_vid .lt. 0) call write_error
  176.      &  (pitch_tau_synth_vid,'define pitch_tau_synth_vid')
  177. pitch_gain_vid=def_variable(pitch_fid,'gain' // char(0),r4,nn,0.0)
  178. if (pitch_gain_vid .lt. 0) call write_error(pitch_gain_vid,
  179.      &  'define pitch_gain_vid')
  180. pitch_qgain_vid=def_variable(pitch_fid,'qgain' // char(0),r4,nn,0.0)
  181. if (pitch_qgain_vid .lt. 0) call write_error(pitch_qgain_vid,
  182.      &  'define pitch_qgain_vid')
  183. pitch_qgain_synth_vid=def_variable(pitch_fid,
  184.      &  'qgain_synth' // char(0),r4,nn,0.0)
  185. if (pitch_qgain_synth_vid .lt. 0) 
  186.      &  call write_error(pitch_qgain_synth_vid,
  187.      &  'define pitch_qgain_synth_vid')
  188. pitch_ir_vid=def_variable(pitch_fid,'ir' // char(0),r4,ll,0.0)
  189. if (pitch_ir_vid .lt. 0) call write_error(pitch_ir_vid,
  190.      &  'define pitch_ir_vid')
  191. c
  192. c *open constrain file
  193. constrain_fid=open_file('constrain' // char(0),1)
  194. if (constrain_fid .lt. 0) call write_error(constrain_fid,
  195.      &              'open constrain_fid')
  196. c
  197. c *define constrain variables
  198. gain_vid=def_variable(constrain_fid,'gain' // char(0),r4,nn,0.0)
  199. if (gain_vid .lt. 0) call write_error(gain_vid,
  200.      &  'define gain_vid')
  201.     ccor_vid=def_variable(constrain_fid,'ccor' // char(0),r4,nn,0)
  202. if (ccor_vid .lt. 0) call write_error(ccor_vid,
  203.      &  'define ccor_vid')
  204.     dbcon_vid=def_variable(constrain_fid,'dbcon' // char(0),r4,nn,0)
  205. if (ccor_vid .lt. 0) call write_error(ccor_vid,
  206.      &  'define ccor_vid')
  207. c
  208. c *open code book file
  209. cb_fid=open_file('codebook' // char(0),1)
  210. if (cb_fid .lt. 0) call write_error(cb_fid,'open cb_fid')
  211. c
  212. c *define code book variables
  213. cb_match_vid=def_variable(cb_fid,'match' // char(0),r4,nn*ncsize,0.0)
  214. if (cb_match_vid .lt. 0) call write_error(cb_match_vid,
  215.      &  'define cb_match_vid')
  216.     cb_index_vid=def_variable(cb_fid,'index' // char(0),2,nn,0)
  217. if (cb_index_vid .lt. 0) call write_error(cb_index_vid,
  218.      &  'define cb_index_vid')
  219.     cb_index_synth_vid=def_variable(cb_fid,
  220.      &  'index_synth' // char(0),2,nn,0)
  221. if (cb_index_synth_vid .lt. 0) call write_error(cb_index_synth_vid,
  222.      &  'define cb_index_synth_vid')
  223.     cb_gain_vid=def_variable(cb_fid,'gain' // char(0),r4,nn,0.0)
  224. if (cb_gain_vid .lt. 0) call write_error(cb_gain_vid,
  225.      &  'define cb_gain_vid')
  226.     cb_qgain_vid=def_variable(cb_fid,'qgain' // char(0),r4,nn,0.0)
  227. if (cb_qgain_vid .lt. 0) call write_error(cb_qgain_vid,
  228.      &  'define cb_qgain_vid')
  229.     cb_qgain_synth_vid=def_variable(cb_fid,'qgain_synth' // char(0),
  230.      &  r4,nn,0.0)
  231. if (cb_qgain_synth_vid .lt. 0) call write_error(cb_qgain_synth_vid,
  232.      &  'define cb_qgain_synth_vid')
  233.      cb_exc_vid=def_variable(cb_fid,'exc' // char(0),r4,ll,0.0)
  234. if (cb_exc_vid .lt. 0) call write_error (cb_exc_vid,
  235.      &  'define cb_exc_vid')
  236. cb_ir_vid=def_variable(cb_fid,'ir' // char(0),r4,ll,0.0)
  237. if (cb_ir_vid .lt. 0) call write_error(cb_ir_vid,'define cb_ir_vid')
  238. c
  239. c *open error file
  240. error_fid=open_file('error' // char(0),1)
  241. if (error_fid .lt. 0) call write_error(error_fid,
  242.      &  'open error_fid')
  243. c
  244. c *define error variables
  245. fndpp_v0_vid=def_variable(error_fid,'fndpp_v0' // char(0),
  246.      &  r4,ll,0.0)
  247. if (fndpp_v0_vid .lt. 0) call write_error(fndpp_v0_vid,
  248.      &  'define fndpp_v0_vid')
  249. fndpp_e0_vid=def_variable(error_fid,'fndpp_e0' // char(0),
  250.      &  r4,ll,0.0)
  251. if (fndpp_e0_vid .lt. 0) call write_error(fndpp_e0_vid,
  252.      &  'define fndpp_e0_vid')
  253. fndex_e0_vid=def_variable(error_fid,'fndex_e0' // char(0),r4,
  254.      &  ll,0.0)
  255. if (fndex_e0_vid .lt. 0) call write_error(fndex_e0_vid,
  256.      &  'define fndex_e0_vid')
  257. c
  258. c *open reflection coefficient file
  259. rc_fid=open_file('rc' // char(0),1)
  260. if (rc_fid .lt. 0) call write_error(rc_fid, 'open rc_fid')
  261. c
  262. c *define rc variables
  263. do 351 i=1,no
  264.    write(str,352) i,0
  265. 352    format('rc',i2,a)
  266.    rc_vid(i)=def_variable(rc_fid, str, r4, 1, 0.0)
  267.    if (rc_vid(i) .lt. 0) call write_error(rc_vid(i), 
  268.      &     'define rc_vid')
  269. 351 continue
  270. predgain_vid=def_variable(rc_fid,'prediction_gain' // char(0),
  271.      &  r4,1,0.0)
  272. if (predgain_vid .lt. 0) call write_error(predgain_vid,
  273.      &  'define predgain_vid')
  274. preddiff_vid=def_variable(rc_fid,'prediction_delta' // char(0),
  275.      &  r4,1,0.0)
  276. if (preddiff_vid .lt. 0) call write_error(preddiff_vid,
  277.      &  'define preddiff_vid')
  278. predavg_vid=def_variable(rc_fid,'prediction_avg' // char(0),
  279.      &  r4,1,0.0)
  280. if (predavg_vid .lt. 0) call write_error(predavg_vid,
  281.      &  'define predavg_vid')
  282. mindiff_vid=def_variable(rc_fid,'minlspdelta' // char(0),
  283.      &  r4,1,0.0)
  284. if (mindiff_vid .lt. 0) call write_error(mindiff_vid,
  285.      &  'define mindiff_vid')
  286. c