Add DECPS Play Sound
There are some differences from the VT520: volume is ignored (although silence is honored); duration is in 1/32 of a second up to and including 48 (1.5 seconds), after which it is in milliseconds (but still a maximum of 8 seconds); notes are 1..25, anything else is frequency.
This commit is contained in:
parent
aa8b0c6a36
commit
826b0b66ba
46
ANSI.c
46
ANSI.c
@ -152,7 +152,7 @@
|
||||
remove wcstok, avoiding potential interference with the host;
|
||||
similarly, use a private heap instead of malloc.
|
||||
|
||||
v1.80, 26 October to 17 November, 2017:
|
||||
v1.80, 26 October to 19 November, 2017:
|
||||
fix unloading;
|
||||
revert back to (re)storing buffer cursor position;
|
||||
increase cache to five handles;
|
||||
@ -160,7 +160,8 @@
|
||||
fix cursor report with duplicated digits (e.g. "11" was just "1");
|
||||
preserve escape that isn't part of a sequence;
|
||||
fix escape followed by CRM in control mode;
|
||||
use the system default sound for the bell.
|
||||
use the system default sound for the bell;
|
||||
add DECPS Play Sound.
|
||||
*/
|
||||
|
||||
#include "ansicon.h"
|
||||
@ -1150,6 +1151,41 @@ void InterpretEscSeq( void )
|
||||
case 'l': // ESC[#l Reset Mode
|
||||
return; // ESC[3l is handled during parsing
|
||||
|
||||
case '~':
|
||||
if (suffix2 == ',') // ESC[#;#;#...,~ Play Sound
|
||||
{
|
||||
// Frequencies of notes obtained from:
|
||||
// https://pages.mtu.edu/~suits/notefreqs.html
|
||||
// http://www.liutaiomottola.com/formulae/freqtab.htm
|
||||
// This is different to what the VT520 manual has, but since that
|
||||
// only specifies four frequencies, so be it. I've also rounded to
|
||||
// even numbers, as the Beep function seems to stutter on odd.
|
||||
static const DWORD snd_freq[] = { 0,
|
||||
// C C#/Db D D#/Eb E F F#/Gb G G#/Ab A A#/Bb B
|
||||
/* 5 */ 524, 554, 588, 622, 660, 698, 740, 784, 830, 880, 932, 988,
|
||||
/* 6 */ 1046, 1108, 1174, 1244, 1318, 1396, 1480, 1568, 1662, 1760, 1864, 1976,
|
||||
/* 7 */ 2094
|
||||
};
|
||||
DWORD dur;
|
||||
if (es_argc < 2) return;
|
||||
dur = es_argv[1];
|
||||
if (dur <= 48) // use 1/32 second
|
||||
dur = 1000 * dur / 32;
|
||||
else if (dur > 8000) // max out at 8 seconds
|
||||
dur = 8000;
|
||||
if (es_argc == 2) // no notes
|
||||
Sleep( dur );
|
||||
else for (i = 2; i < es_argc; ++i)
|
||||
{
|
||||
if (es_argv[0] == 0) // zero volume
|
||||
Sleep( dur );
|
||||
else
|
||||
Beep( (es_argv[i] < lenof(snd_freq)) ? snd_freq[es_argv[i]]
|
||||
: es_argv[i], dur );
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@ -1285,7 +1321,7 @@ ParseAndPrintString( HANDLE hDev,
|
||||
{
|
||||
suffix2 = c;
|
||||
}
|
||||
else if (suffix2 != 0)
|
||||
else if (suffix2 != 0 && suffix2 != ',')
|
||||
{
|
||||
state = 1;
|
||||
}
|
||||
@ -1318,7 +1354,7 @@ ParseAndPrintString( HANDLE hDev,
|
||||
{
|
||||
suffix2 = c;
|
||||
}
|
||||
else if (suffix2 != 0)
|
||||
else if (suffix2 != 0 && suffix2 != ',')
|
||||
{
|
||||
state = 1;
|
||||
}
|
||||
@ -2113,7 +2149,7 @@ WINAPI MyWriteConsoleA( HANDLE hCon, LPCVOID lpBuffer,
|
||||
if (nNumberOfCharsToWrite != 0 && IsConsoleHandle( hCon ))
|
||||
{
|
||||
DEBUGSTR( 4, "%s: %u %\"<s",
|
||||
write_func == NULL ? "WriteConsoleA" : write_func,
|
||||
(write_func == NULL) ? "WriteConsoleA" : write_func,
|
||||
nNumberOfCharsToWrite, lpBuffer );
|
||||
write_func = NULL;
|
||||
aBuf = lpBuffer;
|
||||
|
@ -90,7 +90,7 @@
|
||||
write newline with _putws, not putwchar (fixes redirecting to CON).
|
||||
*/
|
||||
|
||||
#define PDATE L"17 November, 2017"
|
||||
#define PDATE L"19 November, 2017"
|
||||
|
||||
#include "ansicon.h"
|
||||
#include "version.h"
|
||||
|
@ -170,6 +170,7 @@ Sequences Recognised
|
||||
\e[#P DCH Delete Character
|
||||
\e[?7h DECAWM DEC Autowrap Mode (autowrap)
|
||||
\e[?7l DECAWM DEC Autowrap Mode (no autowrap)
|
||||
\e[#;#;#...,~ DECPS DEC Play Sound
|
||||
\e[?25h DECTCEM DEC Text Cursor Enable Mode (show cursor)
|
||||
\e[?25l DECTCEM DEC Text Cursor Enable Mode (hide cursor)
|
||||
\e[#M DL Delete Line
|
||||
@ -304,7 +305,8 @@ Version History
|
||||
- fix escape followed by CRM in control mode;
|
||||
* go back to saving the buffer cursor position;
|
||||
* preserve escape that isn't part of a sequence;
|
||||
+ use the system default sound for the bell.
|
||||
+ use the system default sound for the bell;
|
||||
+ added Play Sound DECPS.
|
||||
|
||||
1.72 - 24 December, 2015:
|
||||
- handle STD_OUTPUT_HANDLE & STD_ERROR_HANDLE in WriteFile;
|
||||
@ -533,4 +535,4 @@ Distribution
|
||||
|
||||
|
||||
=============================
|
||||
Jason Hood, 17 November, 2017.
|
||||
Jason Hood, 19 November, 2017.
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
ANSICON
|
||||
Version 1.70
|
||||
Version 1.80
|
||||
|
||||
This is a complete list of the ANSI escape sequences recognised by ANSICON,
|
||||
roughly ordered by function. The initial escape character is assumed.
|
||||
@ -128,3 +128,20 @@ roughly ordered by function. The initial escape character is assumed.
|
||||
]2;TitleST
|
||||
sets the console title to "Title"; ST (string terminator) is either
|
||||
character 7 (BEL) or escape and backslash
|
||||
|
||||
[#;#;#...,~
|
||||
play sound (beep):
|
||||
the first value is volume: 0 is silence, anything else is ignored
|
||||
the second value is duration: up to and including 48 is in 1/32 of a
|
||||
second; anything else is milliseconds (maximum of 8000)
|
||||
the remaining values (if any; 14 allowed) are notes or frequencies:
|
||||
Value Note Freq Value Note Freq Value Note Freq
|
||||
0 silence 0 9 G#5/Ab5 830 18 F6 1396
|
||||
1 C5 524 10 A5 880 19 F#6/Gb6 1480
|
||||
2 C#5/Db5 554 11 A#5/Bb5 932 20 G6 1568
|
||||
3 D5 588 12 B5 988 21 G#6/Ab6 1662
|
||||
4 D#5/Eb5 622 13 C6 1046 22 A6 1760
|
||||
5 E5 660 14 C#6/Db6 1108 23 A#6/Bb6 1864
|
||||
6 F5 698 15 D6 1174 24 B6 1976
|
||||
7 F#5/Gb5 740 16 D#6/Eb6 1244 25 C7 2094
|
||||
8 G5 784 17 E6 1318
|
||||
|
Loading…
x
Reference in New Issue
Block a user