| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3048 人关注过本帖, 1 人收藏
标题:关于图像抖动的问题,请大侠们指点是怎么回事?
只看楼主 加入收藏
aaaaaa
Rank: 8Rank: 8
等 级:贵宾
威 望:21
帖 子:796
专家分:937
注 册:2012-9-4
收藏
得分:20 
图像抖动是和 Chr(7) 有关,用 sndPlaySound API 方式,还可以同步或异步方法。
VFP 的 Set Bell 是同步方式,多多少少会影响或延迟你的计时器的速度的。
屏蔽掉屏幕,比如:SET CONSOLE OFF,同时也屏蔽掉了 ?? Chr(7)。

这个试试看:

Declare Integer sndPlaySound In winmm ;
    STRING lpszSound, Integer fuSound

#Define SND_SYNC       0
#Define SND_ASYNC      1
#Define SND_NODEFAULT  2

=sndPlaySound("1.wav", SND_SYNC + SND_NODEFAULT)
=sndPlaySound("2.wav", SND_SYNC + SND_NODEFAULT)

民工子弟学校22班团小组长阳光模特队长冲锋篮球队前锋小苹果合唱队领唱蓝天舞蹈队编舞
2016-04-09 17:54
w7802672
Rank: 1
等 级:新手上路
帖 子:231
专家分:0
注 册:2015-5-20
收藏
得分:0 
论坛真是藏龙卧虎之地呀!11楼的办法试过了,正是我想要的效果,非常感谢!!!
2016-04-09 19:47
w7802672
Rank: 1
等 级:新手上路
帖 子:231
专家分:0
注 册:2015-5-20
收藏
得分:0 
回复 11楼 aaaaaa
可否请教一下:=sndPlaySound("2.wav", SND_SYNC + SND_NODEFAULT)里面snd_sync+snd_nodefault参数的意义?非常感谢!
2016-04-09 19:52
w7802672
Rank: 1
等 级:新手上路
帖 子:231
专家分:0
注 册:2015-5-20
收藏
得分:0 
' SND_SYNC(=&H0)       同步调用,声音播放完毕   程序才能继续
' SND_ASYNC(=&H1)     非同步调用,不必等声音播放完毕   程序即可继续
' SND_NODEFAULT(=&H2)当声音文件未找到就停止播音返回
' SND_MEMORY(&H4)       播放内存中的声音
' SND_LOOP(=&H8)       声音播放完毕后   从头重复播放   与SND_ASYNC(=&H1)使用
' SND_NOSTOP(=&H10)   如果其他声音正在播放   则不终止该声音的播放,而返回False

查到了一些参数的用法,我们的用法与这个一样吧?
2016-04-09 20:10
aaaaaa
Rank: 8Rank: 8
等 级:贵宾
威 望:21
帖 子:796
专家分:937
注 册:2012-9-4
收藏
得分:0 
别别别,是楼主的提问到位,几句话抛出问题,没有废话,还上传了示例,跟帖者很容易对接,更难能可贵的是及时的与回帖者交流、回馈、沟通、互动。
希望以后的发帖者像楼主学习,会哭有奶吸,善问有助者。不是吗?

民工子弟学校22班团小组长阳光模特队长冲锋篮球队前锋小苹果合唱队领唱蓝天舞蹈队编舞
2016-04-09 20:11
aaaaaa
Rank: 8Rank: 8
等 级:贵宾
威 望:21
帖 子:796
专家分:937
注 册:2012-9-4
收藏
得分:0 
14楼的已经解释的很清楚了,而且比我的示例全,我就不画蛇添足了。谢谢 w7802672 同志和老师。

民工子弟学校22班团小组长阳光模特队长冲锋篮球队前锋小苹果合唱队领唱蓝天舞蹈队编舞
2016-04-09 20:15
w7802672
Rank: 1
等 级:新手上路
帖 子:231
专家分:0
注 册:2015-5-20
收藏
得分:0 
现将网上搜索到的具体参数附后,方便大家,也方便自己日后查阅:
一、PlaySound函数用法

PlaySound函数的声明为:
BOOL PlaySound(LPCSTR pszSound, HMODULE hmod,DWORD fdwSound);


1、参数pszSound是指定了要播放声音的字符串,该参数可以是WAVE文件的名字,或是WAV资源的名字,或是内存中声音数据的指针,或是在系统注册表WIN.INI中定义的系统事件声音。如果该参数为NULL则停止正在播放的声音。

2、参数hmod是应用程序的实例句柄,当播放WAV资源时要用到该参数,否则它必须为NULL。参数fdwSound是标志的组合,如下表所示。若成功则函数返回TRUE,否则返回FALSE。

3、播放标志以及含义:

SND_APPLICATION
用应用程序指定的关联来播放声音。

SND_ALIAS
pszSound参数指定了注册表或WIN.INI中的系统事件的别名。

SND_ALIAS_ID
pszSound参数指定了预定义的声音标识符。

SND_ASYNC
用异步方式播放声音,PlaySound函数在开始播放后立即返回。

SND_FILENAME
pszSound参数指定了WAVE文件名。

SND_LOOP
重复播放声音,必须与SND_ASYNC标志一块使用。

SND_MEMORY
播放载入到内存中的声音,此时pszSound是指向声音数据的指针。

SND_NODEFAULT
不播放缺省声音,若无此标志,则PlaySound在没找到声音时会播放缺省声音。

SND_NOSTOP
PlaySound不打断原来的声音播出并立即返回FALSE。

SND_NOWAIT
如果驱动程序正忙则函数就不播放声音并立即返回。

SND_PURGE
停止所有与调用任务有关的声音。若参数pszSound为NULL,就停止所有的声音,否则,停止pszSound指定的声音。

SND_RESOURCE
pszSound参数是WAVE资源的标识符,这时要用到hmod参数。

SND_SYNC
同步播放声音,在播放完后PlaySound函数才返回。


4、举例:

    在C:\WINDOWS\MEDIA目录下有一个名为The Microsoft Sound.wav的声音文件,在Windows 95启动时会播放这个声音。下面我们用三种方法来调用PlaySound函数播出Windows 95的启动声音。

第一种方法是直接播出声音文件,相应的代码为:

PlaySound("c:\\win95\\media\\The Microsoft Sound.wav", NULL, SND_FILENAME | SND_ASYNC);

注意参数中的路径使用两个连续的反斜杠转义代表一个反斜杠。

第二种方法是把声音文件加入到资源中,然后从资源中播放声音。Visual C++支持WAVE型资源,用户在资源视图中单击鼠标右键并选择Import命令,然后在文件选择对话框中选择The Microsoft Sound.wav文件,则该文件就会被加入到WAVE资源中。假定声音资源的ID为IDR_STARTWIN,则下面的调用同样会输出启动声音:

PlaySound((LPCTSTR)IDR_STARTWIN, AfxGetInstanceHandle(), SND_RESOURCE | SND_ASYNC);

第三种方法是用PlaySound播放系统声音,Windows启动的声音是由SystemStart定义的系统声音,因此可以用下面的方法播放启动声音:

PlaySound("SystemStart",NULL,SND_ALIAS|SND_ASYNC);

5、MSDN上关于PlaySound这个函数的说明如下:


This function plays a sound specified by a file name, resource, or system event.

BOOL WINAPI PlaySound(
  LPCSTR pszSound,
  HMODULE hmod,
  DWORD fdwSound
);

Parameters

 

pszSound
Pointer to a null-terminated string that specifies the sound to play. If this parameter is NULL, any currently playing waveform sound is stopped. To stop a non-waveform sound, specify SND_PURGE in the fdwSound parameter.
Three flags in fdwSound (SND_ALIAS, SND_FILENAME, and SND_RESOURCE) determine whether the name is interpreted as an alias for a system event, a file name, or a resource identifier. If none of these flags are specified, PlaySound searches the registry or the WIN.INI file for an association with the specified sound name. If an association is found, the sound event is played. If no association is found in the registry, the name is interpreted as a file name.


hmod
Handle to the executable file that contains the resource to be loaded. This parameter must be NULL unless SND_RESOURCE is specified in fdwSound.

 

fdwSound
Flags for playing the sound. The following table shows the possible values.
Value Description
SND_ALIAS The pszSound parameter is a system-event alias in the registry or the WIN.INI file. Do not use with either SND_FILENAME or SND_RESOURCE.
SND_ASYNC The sound is played asynchronously and PlaySound returns immediately after beginning the sound. To terminate an asynchronously played waveform sound, call PlaySound with pszSound set to NULL.
SND_FILENAME The pszSound parameter is a file name.
SND_LOOP The sound plays repeatedly until PlaySound is called again with the pszSound parameter set to NULL. You must also specify the SND_ASYNC flag to indicate an asynchronous sound event.
SND_MEMORY A sound event's file is loaded in RAM. The parameter specified by pszSound must point to an image of a sound in memory.
SND_NODEFAULT No default sound event is used. If the sound cannot be found, PlaySound returns silently without playing the default sound.
SND_NOSTOP The specified sound event will yield to another sound event that is already playing. If a sound cannot be played because the resource needed to generate that sound is busy playing another sound, the function immediately returns FALSE without playing the requested sound.
If this flag is not specified, PlaySound attempts to stop the currently playing sound so that the device can be used to play the new sound.
SND_NOWAIT If the driver is busy, return immediately without playing the sound.
SND_RESOURCE The pszSound parameter is a resource identifier; hmod must identify the instance that contains the resource. When creating the resource, you must identify it as being of the WAVE type, see Using PlaySound with a Resource Identifier.
SND_SYNC Synchronous playback of a sound event. PlaySound returns after the sound event completes.


Return Values
TRUE indicates success. FALSE indicates failure.

Remarks
Windows CE does not support the SND_ALIAS_ID and SND_PURGE flags for the fdwSound parameter. The sound specified by pszSound must fit into available physical memory and be playable by an installed waveform-audio device driver. PlaySound searches the file system directories for the sound according to the search order that was specified by the OEM of the target device. If it cannot find the specified sound, PlaySound uses the default system event sound entry instead. If the function can find neither the system default entry nor the default sound, it makes no sound and returns FALSE.


二、sndPlaySound函数用法

函数sndPlaySound的功能与PlaySound类似,但少了一个参数。

sndPlaySound函数的声明为:
BOOL sndPlaySound(LPCSTR lpszSound, UINT fuSound);

 

1、除了不能指定资源名字外,参数lpszSound与PlaySound的是一样的。

2、参数fuSound是如何播放声音的标志,可以是SND_ASYNC、SND_LOOP、SND_MEMORY、SND_NODEFAULT、SND_NOSTOP和SND_SYNC的组合,这些标志的含义与PlaySound的一样。

可以看出,sndPlaySound不能直接播放声音资源。要用该函数播放WAVE文件,可按下面的方式调用:
sndPlaySound(“MYSOUND.WAV”,SND_ASYNC);

 

3、MSDN上关于sndPlaySound函数的用法如下:

This function plays a single waveform sound. To play multiple sounds simultaneously, use the waveOut* functions in the Waveform Audio API.

BOOL sndPlaySound(
  LPCTSTR lpszSoundName,
  UINT fuSound
);

Parameters

 

lpszSoundName
Long pointer to a null-terminated string that specifies the sound to play. This parameter can be either an entry in the registry or in WIN.INI that identifies a system sound, or it can be the name of a waveform-audio file. (If the function does not find the entry, the parameter is treated as a file name.) If this parameter is NULL, any currently playing sound is stopped.


fuSound
Flags for playing the sound. The following table shows the possible values.
Value Description
SND_ALIAS The pszSound parameter is a system-event alias in the registry or the WIN.INI file. Do not use with either SND_FILENAME or SND_RESOURCE.
SND_ASYNC The sound is played asynchronously and PlaySound returns immediately after beginning the sound. To terminate an asynchronously played waveform sound, call PlaySound with pszSound set to NULL.
SND_FILENAME The pszSound parameter is a file name.
SND_LOOP The sound plays repeatedly until PlaySound is called again with the pszSound parameter set to NULL. You must also specify the SND_ASYNC flag to indicate an asynchronous sound event.
SND_MEMORY A sound event's file is loaded in RAM. The parameter specified by pszSound must point to an image of a sound in memory.
SND_NODEFAULT No default sound event is used. If the sound cannot be found, PlaySound returns silently without playing the default sound.
SND_NOSTOP The specified sound event will yield to another sound event that is already playing. If a sound cannot be played because the resource needed to generate that sound is busy playing another sound, the function immediately returns FALSE without playing the requested sound.
If this flag is not specified, PlaySound attempts to stop the currently playing sound so that the device can be used to play the new sound.
SND_SYNC Synchronous playback of a sound event. PlaySound returns after the sound event completes.


Return Values
TRUE indicates success. FALSE indicates failure.

Remarks
The SND_NOSTOP flag controls how the current call to sndPlaySound behaves if a previous call is still playing.

If the specified sound cannot be found, sndPlaySound plays the system default sound. If there is no system default entry in the registry or WIN.INI file, or if the default sound cannot be found, the function makes no sound and returns FALSE.

The specified sound must fit in available physical memory and be playable by an installed waveform-audio device driver.
2016-04-29 21:52
w7802672
Rank: 1
等 级:新手上路
帖 子:231
专家分:0
注 册:2015-5-20
收藏
得分:0 
sndPlaySound(NULL,SND_PURGE);//停止播放
2016-04-29 22:01
快速回复:关于图像抖动的问题,请大侠们指点是怎么回事?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018000 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved