Index: /psi/trunk/src/common.cpp
===================================================================
--- /psi/trunk/src/common.cpp	(revision 54)
+++ /psi/trunk/src/common.cpp	(revision 55)
@@ -1599,7 +1599,12 @@
 		lock.unlock();
 	}
-	void add(ulong freq, ulong dur) {
+	void beginSequence() {
 		lock.lock();
+		queue.clear(); // stop the previous sequence
+	}
+	void addNote(ulong freq, ulong dur) {
 		queue.push_back(Beep(freq, dur));
+	}
+	void endSequence() {
 		lock.unlock();
 		if (!sem.available())
@@ -1622,5 +1627,5 @@
 	};
 	QMutex lock;
-	QSemaphore sem;
+	QSemaphore sem; // not QWaitCond cause we need level-triggered semantics
 	QValueList<Beep> queue;
 	bool terminate;
@@ -1640,15 +1645,7 @@
 void soundPlay(const QString &str)
 {
-	if(str.startsWith("!beep")) {
-		QStringList list = QStringList::split(':',str);
-		if (list[0].length() == 5 /* strlen("!beep") */) {
-			ulong freq = 0, dur = 0;
-			if (list.count() == 3) {
-				freq = list[1].toULong();
-				dur = list[2].toULong();
-				if (freq < 0x25 || freq > 0x7FFF ||
-					dur == 0 || dur > 3000 /* 3s is the reasonable maximum */)
-					freq = dur = 0;
-			}
+	if (str.startsWith("!beep")) {
+		QStringList seq = QStringList::split(':',str);
+		if (seq[0].length() == 5 /* strlen("!beep") */) {
 			if (beepThread == 0) {
 				beepThread = new BeepThread();
@@ -1658,6 +1655,30 @@
 				}
 			}
-			if (beepThread)
-				beepThread->add(freq, dur);
+			Q_ASSERT(beepThread);
+			if (beepThread) {
+				beepThread->beginSequence();
+#if defined(Q_WS_WIN) || defined(Q_WS_PM)
+				ulong lastDur = 100;
+				size_t i = 1;
+				for (; i < seq.count(); ++i) {
+					QStringList note = QStringList::split(',',seq[i]);
+					if (note.count() < 1) break;
+					ulong freq = note[0].toULong();
+					if (freq < 0x25 || freq > 0x7FFF) break;
+					ulong dur = lastDur;
+					if (note.count() > 2) break;
+					if (note.count() == 2) {
+						dur = note[1].toULong();
+						// 3s is the reasonable maximum for the duration
+						if (dur == 0 || dur > 3000) break;
+						lastDur = dur;
+					}
+					beepThread->addNote(freq, dur);
+				}
+				if (i == 1) // didn't find a single note
+#endif				
+					beepThread->addNote(0, 0);
+				beepThread->endSequence();
+			}
 			return;
 		}
Index: /psi/trunk/src/options/opt_sound-ui.ui
===================================================================
--- /psi/trunk/src/options/opt_sound-ui.ui	(revision 54)
+++ /psi/trunk/src/options/opt_sound-ui.ui	(revision 55)
@@ -103,5 +103,5 @@
                     </property>
                     <property name="toolTip" stdset="0">
-                        <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string>
+                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string>
                     </property>
                 </widget>
@@ -119,5 +119,5 @@
                     </property>
                     <property name="toolTip" stdset="0">
-                        <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string>
+                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string>
                     </property>
                 </widget>
@@ -135,5 +135,5 @@
                     </property>
                     <property name="toolTip" stdset="0">
-                        <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string>
+                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string>
                     </property>
                 </widget>
@@ -159,5 +159,5 @@
                     </property>
                     <property name="toolTip" stdset="0">
-                        <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string>
+                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string>
                     </property>
                 </widget>
@@ -207,5 +207,5 @@
                     </property>
                     <property name="toolTip" stdset="0">
-                        <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string>
+                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string>
                     </property>
                 </widget>
@@ -239,5 +239,5 @@
                     </property>
                     <property name="toolTip" stdset="0">
-                        <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string>
+                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string>
                     </property>
                 </widget>
@@ -319,5 +319,5 @@
                     </property>
                     <property name="toolTip" stdset="0">
-                        <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string>
+                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string>
                     </property>
                 </widget>
@@ -343,5 +343,5 @@
                     </property>
                     <property name="toolTip" stdset="0">
-                        <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string>
+                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string>
                     </property>
                 </widget>
@@ -351,5 +351,5 @@
                     </property>
                     <property name="toolTip" stdset="0">
-                        <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string>
+                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string>
                     </property>
                 </widget>
@@ -367,5 +367,5 @@
                     </property>
                     <property name="toolTip" stdset="0">
-                        <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string>
+                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string>
                     </property>
                 </widget>
Index: /psi/trunk/src/options/opt_sound_events.ui
===================================================================
--- /psi/trunk/src/options/opt_sound_events.ui	(revision 54)
+++ /psi/trunk/src/options/opt_sound_events.ui	(revision 55)
@@ -68,5 +68,5 @@
                     </property>
                     <property name="toolTip" stdset="0">
-                        <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string>
+                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string>
                     </property>
                 </widget>
@@ -84,5 +84,5 @@
                     </property>
                     <property name="toolTip" stdset="0">
-                        <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string>
+                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string>
                     </property>
                 </widget>
@@ -140,5 +140,5 @@
                     </property>
                     <property name="toolTip" stdset="0">
-                        <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string>
+                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string>
                     </property>
                 </widget>
@@ -164,5 +164,5 @@
                     </property>
                     <property name="toolTip" stdset="0">
-                        <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string>
+                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string>
                     </property>
                 </widget>
@@ -212,5 +212,5 @@
                     </property>
                     <property name="toolTip" stdset="0">
-                        <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string>
+                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string>
                     </property>
                 </widget>
@@ -244,5 +244,5 @@
                     </property>
                     <property name="toolTip" stdset="0">
-                        <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string>
+                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string>
                     </property>
                 </widget>
@@ -252,5 +252,5 @@
                     </property>
                     <property name="toolTip" stdset="0">
-                        <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string>
+                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string>
                     </property>
                 </widget>
@@ -268,5 +268,5 @@
                     </property>
                     <property name="toolTip" stdset="0">
-                        <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string>
+                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string>
                     </property>
                 </widget>
