Julia
Julia аватар
User offline. Last seen 5 недель 2 дня ago. Не в сети
Зарегистрирован(а): 07/06/2007

How to create a Quick Alarm Application with Sound Play

alarmI was looking for a freeware for a quick sound alarm and surprisingly couldn’t any that was really quick to use. Naturally I thought about using Rebol and happily this is going to be really easy with the wait and the open sound:// command.

Put a wav file in your rebol directory (for example this one named attention.wav).

Then type or copy and paste in rebol console the code below:

wav: load %attention.wav
sound-port: open sound://
wait 30 do [
insert sound-port wav
]

After 30 seconds, the wav should play, easy isn’t it ?

But there is a problem with the code above, if you try again it won’t work as you need to wait for the sound to finish and close the sound port so that the final code is rather:

wav: load %attention.wav
sound-port: open sound://
wait 30 do [
insert sound-port wav
wait sound-port
close sound-port
]

Of course you can then create an alarm function and put it in user.r for recurrent and immediate use each time you launch Rebol’s Console:

alarm: func[seconds][
     wav: load %attention.wav
     sound-port: open sound://
     wait seconds do [
     insert sound-port wav
     wait sound-port
     close sound-port
   ]
]

Finally if you want OPTIONALLY to add a message use unset! pseudo-type for the message parameter like this:

	alarm: func[seconds message [string! unset!]][
		 wav: load %attention.wav
		 sound-port: open sound://
		 wait seconds do [
		 insert sound-port wav
		 wait sound-port
		 close sound-port
		 if (value? 'message) [
            print message
         ]
	   ]
	]

You can then create an alarm like this

alarm 5

or like this:

alarm 5 "attention"

<!-- Social Bookmarks BEGIN -->

<!-- Social Bookmarks END -->

 

Если женщина злится, значит

Если женщина злится, значит она не только неправа, но и понимает это.
Любовь - это то, чем занимается женщина, пока вы её ебёте...
В постели можно делать все, что доставляет удовольствие обоим, даже читать.
У женщин язык без костей, а у мужиков - член... Совпадение?
Человек собаку вдруг...

Мало ли у кого какие дела

Мало ли у кого какие дела Может, у той девицы тоже пара таких субъектов в кармане

Отправить комментарий

Содержание этого поля является приватным и не предназначено к показу.

Подробнее о форматировании

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.