| 网站首页 | 文秘范文 | 论文中心 | 小品剧本 | 小说 | 藏金阁 | 留言簿 | 汇款帮助 | 客服中心 | FAQ | 电视 | 免费文秘 | 代写 | 
您现在的位置: 中国文秘网 >> 论文中心 >> 理工科论文 >> 正文 用户登录 新用户注册
→中国文秘网温馨提示:为方便你访问本站,请将本站设为首页或加入收藏夹中(点击加入收藏)。
紧急公告:近来发现有些不法网站复制本站版面进行欺骗,为防止上当,敬请会员记好本站网址或把本站加入收藏夹中。
轻松入会,年卡、点卡任君选择,QQ及电话24小时服务,付款后5分钟开通,在线QQ:87651921 ,客服电话:013923833528,详情见"汇款须知"
也谈下重放*.WAV文件          【字体:
也谈下重放*.WAV文件
作者:佚名    论文来源:中国文秘网    点击数:1685    更新时间:2006-4-4
将此页收藏到: 网摘中国 | 新浪 | 热门 | Hao6 | 和讯 | 天极 | YouNote | 5Seek | 365Fav | 365key |博采 | 亿友响享 | 狐摘
3万篇免费论文,近200个详细分类,为你的论文写作排忧解难。点击进入

《计算机世界月刊》1995.3期曾刊登了《在DOS下使用Windows *.WAV文件》一文,根据《在》文中所附的源程序重放WAV文件,发现其音质确实较差;又用文中所提及的第二种延时方法,效果并无改善(大概是循环次数int(vol[counter]/256)≡0)。究其原因,可能是重放时将原WAV文件中127/128的有用信息抛弃了。
实际上,我们是可以把原来抛弃的127/128的有用信息捡回来的。我们知道,WAV文件中所存的是采样时的电压幅值信号,只要将电压信号重现在PC的小喇叭上,就可以逼真地重放WAV文件了。
喇叭上发出的声音,其实就是驱动喇叭的电压变化。而对PC上的数字开关喇叭,只有“0”和“1”两种状态:“1”时喇叭纸盆向外运动,“0”则纸盆向内运动而回复正常位置。
但是向喇叭发送“1”信号时,喇叭向外运动有一个延迟时间,当喇叭还没到达最外位置时,立即再发送“0”信号,纸盆来不及运动到最外位置而转向向内运动。根据这一原理,我们控制喇叭向外运动的时间,就可以间接地控制纸盆运动的幅度,从而根据WAV文件的采样值来控制喇叭的声音大小。
对于PC时钟,显然来不及控制纸盆运动的幅度(即使对8253定时器重新编程,也无法使纸盆从正常位置到最外位置有若干个int08h发生),因此,对于WAV文件的延时,只能采用loop指令。实际上,Windows也正是用这种方法来延时的(以标准模式和增强模式分别启动时,Windows要重新建立延迟时间而发出测试的声音)。
程序中读WAV文件头信息和WAV数据与《在》文相同,发声子程序重新改写了。若发出的声音在频率上有失真,可以修改wave函数中cx的初值(386增强模式、386DX33微机上Windows使用0x13)。
程序运行环境:386兼容机,DOS6.2,Twrbo C++3.0编译系统。
#include<dos.h>
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h> お
#define MAXSIZE 50000 お
unsigned int a[]=
{
0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,
0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,
0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,
0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,
0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,
0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,
0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,
0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,
0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,
0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,
0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,
0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,
0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff81,0xff83,
0xff88,0xff8d,0xff92,0xff97,0xff9c,0xffa1,0xffa6,0xffab,
0xffb0,0xffb5,0xffba,0xffbf,0xffc4,0xffc9,0xffce,0xffd3,
0xffd8,0xffdd,0xffe2,0xffe7,0xffec,0xfff1,0xfff6,0xfffb,
0x0000,0x0005,0x000a,0x000f,0x0014,0x0019,0x001e,0x0023,
0x0028,0x002d,0x0032,0x0037,0x003c,0x0041,0x0046,0x004b,
0x0050,0x0055,0x005a,0x005f,0x0064,0x0069,0x006e,0x0073,
0x0078,0x007d,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,
0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,
0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,
0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,
0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,
0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,
0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,
0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,
0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,
0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,
0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,
0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f,0x007f
=======================================================
}; お
struct wave-file-head
{
char riff-id[4];
long size0;
char wave-fmt[8];
long size1;
int fmttag;
int channel;
long samplespersec;
long bytepersec;
int blockalign;
int bitpersamples;
} filehead; お
long datasize;
unsigned char vol[MAXSIZE];
void wave(void); お
void wave()
{
unsigned int i; お
for(i=0;i<datasize;i++)
{
_BL=vol[i];
asm {
xor bh,bh
shl bx,1
mov bx,a[bx];
xor di,di;
xor dx,dx;
in al,0x61;
and al,0xfc;
out 0x61,al;
mov cx,17;
}
loc33:
asm{
add di,bx;
jge loc34
and al,0xfc;
sub di,0xff81;
out 0x61,al;
loop loc33;
jmp loc35;
}
loc34:
asm{
or al,3;
sub di,0x7f;
out 0x61,al;
loop loc33;
}
loc35;
}
} お
void main(int argc,char *argv[])
{
long j;
int key;
char *s;
FILE *fp; お
if (argc==1)
{
printf("Required parameter missing\n");
exit(0);

>}
if((fp=fopen(argv[1],"rb"))==NULL)
{
printf("File not open\n");
exit(0);
}
if(fread(&filehead,sizeof(struct wave-file-head),1,fp) ==NULL)
{
prinft("File read error\n");
exit(0);
}
fseek(fp,4,SEEK-CUR);
fread(&datasize,4,1,fp); お
for(j=0;j<datasize;j++)
vol[j]=getc(fp);
fclose(fp);
printf("%s\n","Press[ESC] to stop\nSounding...");
while(bioskey(1)==0)wave();
nosound();
}

转贴于 中国文秘网 http://www.zgwmw.com
《也谈下重放*.WAV文件》来源于中国文秘网,中国最专业的文秘网站,欢迎阅读也谈下重放*.WAV文件。
论文录入:中国文秘网    责任编辑:中国文秘网 
  • 上一篇论文:

  • 下一篇论文:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关论文
    也谈中国的自由主义与中国的…
    也谈激励机制
    也谈人力资源会计的确认与计…
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    sitemap: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 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
    136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
    163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
    190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
    217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
    244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
    271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297
    298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
    325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
    352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
    379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405
    406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432
    433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
    460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480