RubyÉùÒô
ת Adding Sound to Your Ruby Apps
Have you ever thought about including sounds in your Ruby application? Used sparingly, sound may enhance your applications by adding audio cues or a custom touch. You could, for example, play a beep or chime that announces the completion of a lengthy process. Perhaps a humorous sound to accompany an error message .
The win32-sound library makes using sounds really simple.
If you installed Ruby with the One-Click Ruby Installer, then you probably already have the win32-sound library installed, along with other win32 utilities. Otherwise, you can install it in seconds via gem. Open up a console window and enter..
gem install win32-sound
To use the win32-sound library, add these require and include statements to the top of your script...
require 'win32/sound'
include Win32
Then, to play a sound file on the PC, call the Sound.play method, passing it the name of the file...
Sound.play('chimes.wav')
Sound.play('c:\sounds\hal9000.wav')
In the example above, you don't have to include the path to the file 'chimes.wav', because 'chimes.wav' is usually installed in the Windows folder. But in most cases, you'll want to include the full path to the sound file.
To generate a simple beep, call the Sound.beep method, passing it the tone frequency (in Hertz, between 37 and 32767) and the duration in milliseconds. For example, to play a low tone for half a second...
Sound.beep(100, 500)
...or to play an annoyingly high-pitched tone for 3 full seconds...
Sound.beep(5000, 3000)
The complete docs for this library can be found here.
Distributing your sound files with your application is also simple. You can embed your sound files in an executable created with RubyScript2Exe, or include them in an install package produced with Inno Setup.
Be careful not to overdo it, though, if your program is to be used by others besides yourself. It's a fine line between clever and annoying.
×¢£º
win-32ÉùÒô¿âÎļþ¼ÐλÖÃΪ
C:\WINDOWS\Media
Sound.pl
Ïà¹ØÎĵµ£º
phpRPC + Ruby + Arduino = 遠³Ì¿ØÖÆLED開關(?)
àÅ£¬ÎÒÖªµÀ這ÊÇ個ºÜ無ÁĵÄSample :P
關ì¶phpRPC與Arduino請×ÔÐÐGoogle
觀¿´´Ëdemo֮ǰ請ÏȰ²裝ÁíÍâһƪËùÌáµ½µÄserialport
與ÁíÍâÒ»個Gem
Ì×¼þ£ºphprpc
ÔÚ這個ļ ......
To get it done is not easy. I spent a whole day to figure out the various compatibility issues along the way out.
Now there still might be potential issues, but it works by my rough test.
Step 1: Install Apache Cassandra
You may know that the Ruby gem cassandra will do it for you.
  ......
ѧÁËÒ»¸öѧÆÚµÄCÓïÑÔ£¬¿´ÁËÒ»¸öÐÇÆÚµÄruby£¬ÎҲŷ¢ÏÖΪʲôÀÏʦ˵CÊÇ×î»ù´¡µÄ£¬¼ÙÈçûÓÐÒ»¸öѧÆÚµÄC»ù´¡£¬ÄÇrubyÎÒÒ²²»Óÿ´ÁË¡£
RubyºÍCÓïÑÔÓÐÐí¶àµÄÏàͬµãºÍ²»Í¬µã£¬ÔÚѧϰrubyʱ£¬ÓÐʱ¿ÉÒÔÓÃCÀïÃæµÄ˼άÀ´Àí½â£¬¾ÍÏñrubyÀïÃæµÄ·½·¨Æäʵ¾Í¸úCµÄº¯ÊýÈç³öÒ» ......
Ruby£¬Ò»ÖÖ為簡單¿ì½ÝÎï¼þ導Ïò編³Ì£¨ÃæÏò¶ÔÏó³ÌÐòÉè¼Æ£©¶ø創µÄ½Å±¾語ÑÔ£¬ÔÚ20ÊÀ¼Í90Äê´úÓÉÈÕ±¾ÈËËɱ¾Ðк루¤Þ¤Ä¤â¤È¤æ¤¤Ò¤í£¯Yukihiro Matsumoto£©¿ª·¢£¬×ñÊØGPLÐÒéºÍRuby License¡£ËüµÄÁé¸ÐÓëÌØÐÔÀ´×ÔÓÚPerl¡¢Smalltalk¡¢Eiffel¡¢Ada ÒÔ¼° Lisp ......
¿ÉÓÿ⣺getoptlong.rs£¬ optionparser
¶ÔÓ¦ÀࣺGetoptLong, OptionParser
ǰÕßÒѹýʱ£¬½¨ÒéʹÓúóÕߣ¬ÇÒºóÕß±ÈǰÕßÒ×Óá£
ºóÕßÌØµã£º
1. ²ÎÊýÃèÊöºÍ´úÂë´¦ÀíдÔÚÒ»Æð
2. Êä³ö²ÎÊý˵Ã÷£¬²»Ðèµ¥¶Àά»¤
3. ¿ÉÑ¡²ÎÊýºÍÃüÁî²ÎÊýÃèÊö¼ò½à
4. ²ÎÊý¿É×Ô¶¯×ª»»ÎªÌض¨µÄÀà
5. ......