Minor fixes and formatting to 2001/coupard
main() now returns a value rather than just 'return' to be more portable. Format/typo check README.md file. I believe this completes the review of this entry.
This commit is contained in:
1 parent
681e626665
commit
3c18e84a48
4 files changed
+27
-18
No files matched your search
@@ -38,7 +38,7 @@ include ../../var.mk
|
|||||||
|
|
||||||
# Common C compiler warnings to silence
|
# Common C compiler warnings to silence
|
||||||
#
|
#
|
||||||
CSILENCE= -Wno-empty-body -Wno-pointer-sign -Wno-return-type -Wno-deprecated-non-prototype -Wno-implicit-int
|
CSILENCE= -Wno-empty-body -Wno-pointer-sign -Wno-deprecated-non-prototype -Wno-implicit-int
|
||||||
|
|
||||||
# Common C compiler warning flags
|
# Common C compiler warning flags
|
||||||
#
|
#
|
||||||
|
|||||||
+19
-12
@@ -14,15 +14,16 @@ make
|
|||||||
|
|
||||||
### Try:
|
### Try:
|
||||||
|
|
||||||
|
If you have access to `/dev/audio` or `/dev/sound/dsp`:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./coupard > /dev/audio
|
./coupard > /dev/audio
|
||||||
./coupard > /dev/sound/dsp
|
./coupard > /dev/sound/dsp
|
||||||
```
|
```
|
||||||
|
|
||||||
If you're using macOS then you won't have these devices. If however you install
|
If you do not, first install [sox](https://en.wikipedia.org/wiki/SoX). If you
|
||||||
[sox](https://en.wikipedia.org/wiki/SoX) from
|
use macOS you might install it from [MacPorts](https://www.macports.org) or
|
||||||
[MacPorts](https://www.macports.org) or [Homebrew](https://brew.sh) you can do
|
[Homebrew](https://brew.sh). Then you can try:
|
||||||
something like:
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./coupard | sox -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio
|
./coupard | sox -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio
|
||||||
@@ -68,33 +69,36 @@ To listen to what the program says directly, invoke
|
|||||||
|
|
||||||
The program then speaks out something like
|
The program then speaks out something like
|
||||||
|
|
||||||
"The time is HH hours MM minutes SS seconds"
|
> The time is HH hours MM minutes SS seconds
|
||||||
|
|
||||||
in military time (24 hours). Of course, you need to have permissions
|
in military time (24 hours). Of course, you need to have permissions
|
||||||
to write to `/dev/audio`, have your sound card enabled, the volume up,
|
to write to `/dev/audio`, have your sound card enabled, the volume up,
|
||||||
the speakers connected ... :-)
|
the speakers connected ... :-)
|
||||||
|
|
||||||
If you want to convert the audio output of the program into another audio
|
If you want to convert the audio output of the program into another audio
|
||||||
format, you can pipe it to [sox](https://en.wikipedia.org/wiki/SoX) for example
|
format, you can pipe it to [SoX](https://en.wikipedia.org/wiki/SoX) for example
|
||||||
(`sox` is the Swiss army knife of Unix audio tools): the command:
|
(`sox` is the Swiss army knife of Unix audio tools). The command:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./coupard | sox -c1 -r8000 -tub - -c2 -r44100 -twav test.wav
|
./coupard | sox -c1 -r8000 -tub - -c2 -r44100 -twav test.wav
|
||||||
```
|
```
|
||||||
|
|
||||||
converts the output of the program into a 44.1KHz stereo .WAV
|
converts the output of the program into a 44.1KHz stereo .WAV
|
||||||
file and saves it into "test.wav".
|
file and saves it into `test.wav`.
|
||||||
|
|
||||||
The output format of the program is 8KHz, unsigned 8-bit samples.
|
The output format of the program is 8KHz, unsigned 8-bit samples.
|
||||||
|
|
||||||
NOTE: the program's return code is meaningless.
|
NOTE: the program's return code is meaningless.
|
||||||
|
|
||||||
|
|
||||||
### Audio quality
|
### Audio quality
|
||||||
|
|
||||||
The quality of the sound produced by the program is cross between a
|
The quality of the sound produced by the program is cross between a
|
||||||
yogurt-pot-and-string telephone and a bad gramophone, i.e. the S/N ratio is very
|
[yogurt-pot-and-string
|
||||||
low and the signal's top frequency is very low as well. This is because the
|
telephone](https://en.wikipedia.org/wiki/Tin_can_telephone) and a bad
|
||||||
audio is stored internally at a sampling rate of 4KHz (the [Nyquist
|
[gramophone](https://en.wikipedia.org/wiki/Phonograph), i.e. the S/N ratio is
|
||||||
|
very low and the signal's top frequency is very low as well. This is because
|
||||||
|
the audio is stored internally at a sampling rate of 4KHz (the [Nyquist
|
||||||
frequency](https://en.wikipedia.org/wiki/Nyquist_frequency) is only 2KHz) with
|
frequency](https://en.wikipedia.org/wiki/Nyquist_frequency) is only 2KHz) with
|
||||||
only 4-bit samples (adding 24db of quantization noise to an already poor
|
only 4-bit samples (adding 24db of quantization noise to an already poor
|
||||||
signal).
|
signal).
|
||||||
@@ -103,12 +107,13 @@ In short, you might have to listen twice to understand what the
|
|||||||
program is saying. 2048 bytes including the sound generation program
|
program is saying. 2048 bytes including the sound generation program
|
||||||
doesn't leave much room for audio quality ;-)
|
doesn't leave much room for audio quality ;-)
|
||||||
|
|
||||||
|
|
||||||
### Speech generation
|
### Speech generation
|
||||||
|
|
||||||
Only 9 phonemes are used to generate the speech. Beside the limited
|
Only 9 phonemes are used to generate the speech. Beside the limited
|
||||||
number of words the program has to generate (66 words), the low sound
|
number of words the program has to generate (66 words), the low sound
|
||||||
quality is actually exploited to take liberties with certain
|
quality is actually exploited to take liberties with certain
|
||||||
consonants (for example, "s" and "f" sound very much the same at 4KHz,
|
consonants (for example, `s` and `f` sound very much the same at 4KHz,
|
||||||
so they can be merged into one phoneme). Because the
|
so they can be merged into one phoneme). Because the
|
||||||
[psychoacoustic](https://en.wikipedia.org/wiki/Psychoacoustics)
|
[psychoacoustic](https://en.wikipedia.org/wiki/Psychoacoustics)
|
||||||
context around those phonemes is just sufficient, the words can be
|
context around those phonemes is just sufficient, the words can be
|
||||||
@@ -119,6 +124,7 @@ Internally, a table is used to generate most of the words, and
|
|||||||
composite words such as "thirty-five" are made up by the C code
|
composite words such as "thirty-five" are made up by the C code
|
||||||
externally.
|
externally.
|
||||||
|
|
||||||
|
|
||||||
### Data compression
|
### Data compression
|
||||||
|
|
||||||
Even at 4KHz / 4 bits, the weight of all the phoneme samples and the
|
Even at 4KHz / 4 bits, the weight of all the phoneme samples and the
|
||||||
@@ -139,6 +145,7 @@ characters, which leaves just enough room for the decompressor with a
|
|||||||
hard-coded Huffman tree, and the code that plays the phonemes in the
|
hard-coded Huffman tree, and the code that plays the phonemes in the
|
||||||
right order.
|
right order.
|
||||||
|
|
||||||
|
|
||||||
### Note on compiler warnings and lint
|
### Note on compiler warnings and lint
|
||||||
|
|
||||||
The program should build with `gcc -Wall -Werror -ansi`. If the `-pedantic`
|
The program should build with `gcc -Wall -Werror -ansi`. If the `-pedantic`
|
||||||
|
|||||||
@@ -39,4 +39,4 @@ int main(){
|
|||||||
for(;i<8476;j[p]=k>=0?j<*o?k-2:(p[j+1]=k<<4):0,j+=k>=0?1+(j>=*o):0,
|
for(;i<8476;j[p]=k>=0?j<*o?k-2:(p[j+1]=k<<4):0,j+=k>=0?1+(j>=*o):0,
|
||||||
l=-k*(k<0),i++);e(21,4);x(hour)e(22,1);x(min)e(23,1);e(25,0);x(sec)e(24,0);
|
l=-k*(k<0),i++);e(21,4);x(hour)e(22,1);x(min)e(23,1);e(25,0);x(sec)e(24,0);
|
||||||
|
|
||||||
return;}
|
return 0;}
|
||||||
+6
-4
@@ -2503,6 +2503,8 @@ He also fixed it to check the number of args.
|
|||||||
|
|
||||||
## [2001/coupard](2001/coupard/coupard.c) ([README.md](2001/coupard/README.md]))
|
## [2001/coupard](2001/coupard/coupard.c) ([README.md](2001/coupard/README.md]))
|
||||||
|
|
||||||
|
Cody added a value to `return` in `main()` to make it more portable.
|
||||||
|
|
||||||
Cody fixed this to compile with clang in linux. The problem was C99 does not
|
Cody fixed this to compile with clang in linux. The problem was C99 does not
|
||||||
support implicit int:
|
support implicit int:
|
||||||
|
|
||||||
@@ -2516,11 +2518,11 @@ void e(n,h){
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The easiest fix is to just disable the warning which is what was done.
|
This was not really worth a thanks per se but it was originally done by adding
|
||||||
Originally the code was changed to use `int` but to make it more like the
|
`int`. The better solution is to disable the warning which is what was done
|
||||||
original this was undone.
|
later on to make it more like the original.
|
||||||
|
|
||||||
Yusuke for providing a proper command line for macOS (to do with sound; see his
|
Yusuke provided a proper command line for macOS (to do with sound; see his
|
||||||
[/2013/endoh3/README.md](2013/endoh3/README.md) entry where he also refers to
|
[/2013/endoh3/README.md](2013/endoh3/README.md) entry where he also refers to
|
||||||
sound devices in macOS).
|
sound devices in macOS).
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user