Changeset 55 for psi/trunk

Show
Ignore:
Timestamp:
09/21/06 00:43:03 (2 years ago)
Author:
dmik
Message:

Psi: General: Changed the !beep format to specify sequences of beeps: !beep[:freq[,dur]]...

Location:
psi/trunk/src
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • psi/trunk/src/common.cpp

    r54 r55  
    15991599                lock.unlock(); 
    16001600        } 
    1601         void add(ulong freq, ulong dur) { 
     1601        void beginSequence() { 
    16021602                lock.lock(); 
     1603                queue.clear(); // stop the previous sequence 
     1604        } 
     1605        void addNote(ulong freq, ulong dur) { 
    16031606                queue.push_back(Beep(freq, dur)); 
     1607        } 
     1608        void endSequence() { 
    16041609                lock.unlock(); 
    16051610                if (!sem.available()) 
     
    16221627        }; 
    16231628        QMutex lock; 
    1624         QSemaphore sem; 
     1629        QSemaphore sem; // not QWaitCond cause we need level-triggered semantics 
    16251630        QValueList<Beep> queue; 
    16261631        bool terminate; 
     
    16401645void soundPlay(const QString &str) 
    16411646{ 
    1642         if(str.startsWith("!beep")) { 
    1643                 QStringList list = QStringList::split(':',str); 
    1644                 if (list[0].length() == 5 /* strlen("!beep") */) { 
    1645                         ulong freq = 0, dur = 0; 
    1646                         if (list.count() == 3) { 
    1647                                 freq = list[1].toULong(); 
    1648                                 dur = list[2].toULong(); 
    1649                                 if (freq < 0x25 || freq > 0x7FFF || 
    1650                                         dur == 0 || dur > 3000 /* 3s is the reasonable maximum */) 
    1651                                         freq = dur = 0; 
    1652                         } 
     1647        if (str.startsWith("!beep")) { 
     1648                QStringList seq = QStringList::split(':',str); 
     1649                if (seq[0].length() == 5 /* strlen("!beep") */) { 
    16531650                        if (beepThread == 0) { 
    16541651                                beepThread = new BeepThread(); 
     
    16581655                                } 
    16591656                        } 
    1660                         if (beepThread) 
    1661                                 beepThread->add(freq, dur); 
     1657                        Q_ASSERT(beepThread); 
     1658                        if (beepThread) { 
     1659                                beepThread->beginSequence(); 
     1660#if defined(Q_WS_WIN) || defined(Q_WS_PM) 
     1661                                ulong lastDur = 100; 
     1662                                size_t i = 1; 
     1663                                for (; i < seq.count(); ++i) { 
     1664                                        QStringList note = QStringList::split(',',seq[i]); 
     1665                                        if (note.count() < 1) break; 
     1666                                        ulong freq = note[0].toULong(); 
     1667                                        if (freq < 0x25 || freq > 0x7FFF) break; 
     1668                                        ulong dur = lastDur; 
     1669                                        if (note.count() > 2) break; 
     1670                                        if (note.count() == 2) { 
     1671                                                dur = note[1].toULong(); 
     1672                                                // 3s is the reasonable maximum for the duration 
     1673                                                if (dur == 0 || dur > 3000) break; 
     1674                                                lastDur = dur; 
     1675                                        } 
     1676                                        beepThread->addNote(freq, dur); 
     1677                                } 
     1678                                if (i == 1) // didn't find a single note 
     1679#endif                           
     1680                                        beepThread->addNote(0, 0); 
     1681                                beepThread->endSequence(); 
     1682                        } 
    16621683                        return; 
    16631684                } 
  • psi/trunk/src/options/opt_sound-ui.ui

    r54 r55  
    103103                    </property> 
    104104                    <property name="toolTip" stdset="0"> 
    105                         <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string> 
     105                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string> 
    106106                    </property> 
    107107                </widget> 
     
    119119                    </property> 
    120120                    <property name="toolTip" stdset="0"> 
    121                         <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string> 
     121                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string> 
    122122                    </property> 
    123123                </widget> 
     
    135135                    </property> 
    136136                    <property name="toolTip" stdset="0"> 
    137                         <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string> 
     137                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string> 
    138138                    </property> 
    139139                </widget> 
     
    159159                    </property> 
    160160                    <property name="toolTip" stdset="0"> 
    161                         <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string> 
     161                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string> 
    162162                    </property> 
    163163                </widget> 
     
    207207                    </property> 
    208208                    <property name="toolTip" stdset="0"> 
    209                         <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string> 
     209                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string> 
    210210                    </property> 
    211211                </widget> 
     
    239239                    </property> 
    240240                    <property name="toolTip" stdset="0"> 
    241                         <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string> 
     241                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string> 
    242242                    </property> 
    243243                </widget> 
     
    319319                    </property> 
    320320                    <property name="toolTip" stdset="0"> 
    321                         <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string> 
     321                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string> 
    322322                    </property> 
    323323                </widget> 
     
    343343                    </property> 
    344344                    <property name="toolTip" stdset="0"> 
    345                         <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string> 
     345                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string> 
    346346                    </property> 
    347347                </widget> 
     
    351351                    </property> 
    352352                    <property name="toolTip" stdset="0"> 
    353                         <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string> 
     353                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string> 
    354354                    </property> 
    355355                </widget> 
     
    367367                    </property> 
    368368                    <property name="toolTip" stdset="0"> 
    369                         <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string> 
     369                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string> 
    370370                    </property> 
    371371                </widget> 
  • psi/trunk/src/options/opt_sound_events.ui

    r54 r55  
    6868                    </property> 
    6969                    <property name="toolTip" stdset="0"> 
    70                         <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string> 
     70                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string> 
    7171                    </property> 
    7272                </widget> 
     
    8484                    </property> 
    8585                    <property name="toolTip" stdset="0"> 
    86                         <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string> 
     86                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string> 
    8787                    </property> 
    8888                </widget> 
     
    140140                    </property> 
    141141                    <property name="toolTip" stdset="0"> 
    142                         <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string> 
     142                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string> 
    143143                    </property> 
    144144                </widget> 
     
    164164                    </property> 
    165165                    <property name="toolTip" stdset="0"> 
    166                         <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string> 
     166                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string> 
    167167                    </property> 
    168168                </widget> 
     
    212212                    </property> 
    213213                    <property name="toolTip" stdset="0"> 
    214                         <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string> 
     214                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string> 
    215215                    </property> 
    216216                </widget> 
     
    244244                    </property> 
    245245                    <property name="toolTip" stdset="0"> 
    246                         <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string> 
     246                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string> 
    247247                    </property> 
    248248                </widget> 
     
    252252                    </property> 
    253253                    <property name="toolTip" stdset="0"> 
    254                         <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string> 
     254                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string> 
    255255                    </property> 
    256256                </widget> 
     
    268268                    </property> 
    269269                    <property name="toolTip" stdset="0"> 
    270                         <string>Enter a filename or &lt;tt&gt;!beep[:freq:duration]&lt;/tt&gt; for a system beep</string> 
     270                        <string>Enter a filename or &lt;tt&gt;!beep[:freq[,dur]]...&lt;/tt&gt; for a system beep</string> 
    271271                    </property> 
    272272                </widget>