1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383
|
.TH tones 1 "20 Feb 1998" "Release 2.3" "Linux System Manual"
.SH NAME
.I tones \- a sequential tone generator program
.SH SYNOPSIS
.B tones [options] [waveform] T freq(s)|notes(s)|command_file(s)
.SH DESCRIPTION
.I tones
generates one or more tones of various types (waveforms) and duration (T
millisecs) of the specified frequencies or notes, or mixtures of frequencies
or notes. See
.I tones\ -h
for a list of
possible waveforms. The waveforms should include
.I sine,
.I cosine
(90 degrees out of phase to sine),
.I square
(50% mark/space ratio),
.I sawtooth
(a ramp waveform),
.I triangle
and
.I noise.
Sine is the default. Besides the inbuilt waveforms, waveforms can be loaded
from suitable WAV files - see below
.I LOADABLE\ WAVEFORMS.
.PP
.I T
is the default number of
millisecs that each tone is to be played.
Frequencies (freq(s)) are specified
in Hertz as integers. A frequency of 0 causes T millisecs of silence to be
played. Notes are specified as the musical note letter with an
optional '#' to sharpen the note, then an octave number. Octaves run from
C to C. Middle C is C3, the immediately preceding note is B2! The first
Octave is from C0 to C1.
.PP
Several frequencies/notes can be played at once, by specifying the
frequencies/notes required joined by a ',' character (but no spaces!).
.PP
e.g.
.I 1000,1500,2000
specifies that the three frequencies are played together, all at the same
relative level. See
.I AMPLITUDES
sections below for a discussion of how to set absolute amplitude levels
or differing relative amplitudes for notes played together or serially.
.PP
Each freq specification can optionally contain a duration, by
appending ':T', where 'T' is the duration in millisecs. This duration
overrides the default. Also the default duration can be changed
by using a the ':T' format on it's own - not appended to a freq spec.
.PP
e.g.
.I 1200,600:1000
play the two freqs for 1 sec
.PP
e.g.
.I c3,e3,g3
play the C major chord
.PP
e.g.
.I :250
set the default tone duration to 250ms
.PP
Waveforms can be specified/altered at anytime. A single waveform name
specifies that waveform to be used for all channels. Alternatively
a comma (',') separated list of waveforms can be given to specify or alter
the waveform to use for a given channel. Omitting a waveform in a list,
means that the previous waveform is left unchanged.
.PP
e.g.
.I square,,triangle
specifies using square waves for chan 1,
chan 2 is left unchanged, and triangular waves are used for channel 3.
.PP
The digital samples (either 8 or 16 bits) are played by default to the Linux
.I /dev/dsp
device at a samplerate of 22050 samples per second, in mono mode. (see
.I CONFIGURATION\ FILES
section below)
.PP
Fractional Hertz frequencies are not supported. Of course, only frequencies
less than half the samplerate (number of samples/sec) can be accurately
generated; but the program doesn't check this.
.PP
Instead of playing the output to
.I /dev/dsp
the samples can be written to a file as raw samples (\-o file) or written in
WAV format (\-w wavfile). These data files can then be played back quickly
with a raw data or WAV file player (e.g. wavplay) without the overhead of
actually generating the samples.
.PP
There are some special 'commands' that can be specified, that may be useful
in input files.
.IP \:N
Set default tone duration to N millisecs
.IP \@N
Set base amplitude level of tones when in absolute
.I amplitude
mode
.IP absolute
Set absolute amplitude mode (see below)
.IP echo
The rest of the line of the input file, or the rest of the command line
parameter (NB to use quotes where necessary) is output to stdout.
.IP relative
Set relative amplitude mode (see below)
.IP reset|resync
All generator points are reset to the start of the waveform buffers. This
forces subsequant generation of multiple frequencies/waveforms to be in phase.
.PP
Further, if the word is not one of the above, then tones checks to see
if a file of that name exists, and if it does then the file is assumed to be
a file of tones commands which are executed.
.PP
e.g.
.I tones\ -v\ :100\ tune1\ tune2\ \ \ \
will interpret and play the tones commands in files
.I tune1
and
.I tune2.
This file processing is recursive. Files of commands can execute other
files of commands etc. As usual,
.I '-'
can be used to specify stdin.
.SH RELATIVE\ AMPLITUDES
.PP
.I tones
by default works in a 'relative' amplitude mode, where the output level
and sample range are maximally maintained. This ensures the best signal
accuracy.
.PP
When specifying multiple frequencies/notes to be played together, then the
relative amplitudes can be specified in deciBells by appending "@db" to the
note.
.PP
e.g.
.I 440,880@-12,1760@-30
specifies a mixture with 880Hz \-12dB down, and 1760Hz \-30dB down relative
to the level of 440Hz. The mixed signal samples will span the full 16 or 8
bit range permitted for maximal signal accuracy.
.PP
The dB levels indicate the relative power levels.
.I -3dB
being at a relative power level of 0.5,
.I -20dB
being at a relative power level of 0.01 . However power levels are
proportional to the square of the signal amplitude. So a signal at \-6dB
(quarter power) will only have its amplitude down by half. To reduce a
signal amplitude by 1/10 then specify \-20dB, i.e. a power level down
by a factor of a hundredth.
.PP
dB levels can be specified as decimal values.
.SH ABSOLUTE\ AMPLITUDES
.PP
.I tones
can work in an absolute amplitude mode, where
signal power levels are specified in deciBells (dB) relative to
a 0dB level that indicates a peak value of +32767/-32768 for 16 bit signed
samples,
and 255/0 for 8 bit unsigned values. Hence any signal at a positive dB
level will be clipped. Signals at a negative dB level will attentuated.
If no level is specified then 0dB is assumed.
.PP
e.g.
.I 500@-20,750@-6,1000,-12
gives 500Hz at \-20db (amplitude 0.1), 750Hz at \-6db (amplitude 0.5),
and 1000Hz at \-12dB (amplitude 0.25). The final mixed signal will have
an amplitude of 0.1 + 0.5 + 0.25 = 0.85 or \-1.4dB.
.PP
As can be seen, there is no "hands-free" in
.I absolute
mode. You have to work out the dB levels yourself and ensure that the
resultant mixed signal does not go above 0dB and get clipped. Remember also
that a sine wave at \-80dB down (amplitude 1/10000th) only has 6 digital
levels and is a pretty poor representation of a sine wave, not suitable for
post amplification and use!
.PP
In
.I absolute
mode the base 'zero' level can be altered at any time by use of the
.I @dB
command. All subsequent dB levels specified will have this base level
added to them.
.PP
e.g.
.I @-20\ 1000,1200@+6,1400@-6
is the same as 1000Hz at \-20dB, 1200Hz at \-14dB and 1400Hz at \-26dB.
.SH LOADABLE\ WAVEFORMS
.PP
Given that the generation method used by
.I tones
to generate a waveform of FHz is simply to sequentially select
every Fth sample from a buffer containing S samples of one complete
waveform at a frequency of 1Hz (treating the buffer as circular, the
beginning conceptually joined to the end), where S is the number of samples
per second, it is possible to load a customised waveform from a WAV file
containing the S samples of a 1Hz waveform. See the
.I -load\ WavFile
and
.I -lw\ N
options below. The name of the waveform is taken as the basename of the
WavFile, i.e. with any trailing '.suffix' and leading path removed.
Each loaded waveform should hence have this name unique, and different from
the inbuilt waveform names.
.PP
The samples in WavFile should be 16 bit, mono, of the same number of samples
as tones' playing samplerate, e.g. if tones is playing at 32000 samples per
sec then the WavFile should contain 32000 16 bit samples. 16 bit samples are
needed, because tones works internally with 16 bit samples, even if it is
feeding 8 bit samples to the sound card or output file. Ideally the samples
should span one complete wavelength, i.e. represent 1 second of a 1Hz signal.
However this can be varied if used with some intelligence. If, say, 1 seconds
worth of 5Hz of the waveform is used, then the output frequency will be 5
times higher than specified. If you have a mixture of 3Hz and 5Hz samples,
then the frequencies generated will be a mixture of 3 and 5 times the
frequency specified. I hope that is all understandable!
.PP
See the
.I tones.eg
directory for some examples of loadable modules and how
.I tones
itself can be used to generate the loadable waveforms.
.SH OPTIONS
.IP -8\ |\ -b\ 8
set 8 bit unsigned data samples
.IP -16\ |\ -b\ 16
set 16 bit signed little-endian data samples.
.IP -abs|-absolute
set absolute amplitude mode
.IP -a
when used in conjunction with the \-o option, data is appended to the file.
.IP -C\ file
use "file" as the local configuration file (see below).
.IP -c\ CHANNELS
set the maximum number of channels (concurrent played frequencies) to
CHANNELS. The default number is 4. There is some virtue in keeping the
number of channels to a minimum.
.IP -f
when used in conjunction with the \-o or \-w options, any existing file is
silently overwritten.
.IP -h
display usage and help info
.IP -i\ file
read frequencies/waveforms to generate from file 'file'.
Reads from standard input if filename is '-'. Any command line specifications
are actioned before the input file is read.
.IP -l
play the tone sequence repetitively. Forced off if writing samples to a file
with the \-o or \-w options.
.IP -loop\ N
play the tone sequence N times.
.IP -o\ file
write out samples to a raw data file. You will have to remember the data
format, e.g. samplerate and 8/16 bit.
.IP -rel|-relative
set relative amplitude mode
.IP -s\ samplerate
set the number of samples per second to samplerate. For many simple uses a
samplerate of 8000 is sufficient, making any saved data files smaller.
.IP -w\ wavfile
write samples out in WAV format to wavfile. The WAV header contains details
of whether the data is 8 or 16 bits and the sampling rate. You cannot use the
append (\-a) option with WAV files.
.IP -v
be verbose
.IP -lw\ N
Specify the number of loadable waveforms allowed, the default is 4
.IP -load\ WavFile
Load the waveform from the WavFile.
.SH EXAMPLES
.IP tones\ 50\ 1000\ 700,1200\ 800,1100,1300
generates 3 50 millisecs sine tones, the first consisting of only 1000Hz,
the second of 700Hz and 1200Hz and the third of 800Hz, 1100Hz and 1300Hz
.IP tones\ -loop\ square\ 200\ 700\ 900\ 400\ 500
generates a sequence of 4 200 millisecs square wave tones which is repeated
until the program is interrupted.
.IP tones\ -w\ seq.wav\ 70\ 1016\ 1200\ 1080\ 1150\ 1016
generates a sequence of 5 70 millisecs sine tones, and instead of playing them
the samples are stored in WAV format in seq.wav which can be played by any
WAV file player.
.IP tones\ -w\ trap.wav\ :1000\ triangle\ absolute\ 1@6
Generates a WAV file
.I trap.wav
consisting of a trapezoid waveform where the rise and fall slopes take up
half the wavelength. A sawtooth is generated with a maximum that has twice
the amplitude of the maximum sample sizes allowed, hence it is clipped flat
for half the waveform period making a trapezoid shape.
.IP tones\ -load\ trap.wav\ :1000\ triangle\ 1000\ trap\ 500\ triangle\,trap\ 1000\,500
Will load the trapezoid waveform generated above as a new waveform called
.I trap
and then plays 1 seconds each of first a 1000Hz triangle wave, then a 500Hz
.I trap
waveform and finally both waveforms played together.
.PP
See also the
.I tones.eg
directory in the siggen distribution.
.SH CONFIGURATION\ FILES
.PP
Three possible configuration files can be used: a LOCAL config file (usually
in current directory), a HOME config file in user's $HOME directory and a
GLOBAL config file.
.PP
All the siggen suite of programs are compiled with the names of the config
files built in. By default the configuration files are:
.IP ./.siggen.conf
is the LOCAL config file.
.IP $HOME/.siggen.conf
is the HOME config file.
.IP /etc/siggen.conf
is the GLOBAL config file.
.IP tones\ -h
will indicate which config files will be searched for.
.PP
The config files do not have to exist. If they exist and are readable by the
program they are used, otherwise they are simply ignored.
.PP
The config files are always searched for configuration values in the order
LOCAL, HOME, GLOBAL. This allows a scheme where the sysadmin sets up default
config values in the GLOBAL config file, but allows a user to set some or
all different values in their own HOME config file, and to set yet more
specific values when run from a particular directory.
.PP
If no configuration files exist, the program provides builtin
default values, and most of these values can be set
by appropriate command line switches and flags.
.PP
See siggen.conf(5) for details of the configuration files.
.PP
.I tones
looks for configuration values CHANNELS, DACFILE, SAMPLERATE,
SAMPLESIZE, VERBOSE, LOADABLE_WAVEFORMS.
.IP CHANNELS
sets the number of channels, see '\-c' option.
.IP DACFILE
allows the name of the DAC/DSP/PCM device to be changed from /dev/dsp
.IP LOADABLE_WAVEFORMS
specifies the allowable number of loadable waveforms
.IP SAMPLERATE
sets the number of samples/sec for the DAC device
.IP SAMPLESIZE
sets whether 8 or 16 bit samples to be generated
.IP VERBOSE
sets whether or not to run in verbose mode.
.SH SEE ALSO
.IP siggen.conf(5),\ signalgen(1),\ swgen(1)
.SH
.SH BUGS
.SH
.SH COPYING
.I Copyright\ 1995-2008\ Jim\ Jackson
.PP
The software described by this manual is covered by the GNU General
Public License, Version 2, June 1991, issued by :
.IP
Free Software Foundation, Inc.,
.br
675 Mass Ave,
.br
Cambridge, MA 02139, USA
.PP
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.
.PP
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
.PP
Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
versions, except that this permission notice may be included in
translation instead of in the original English.
.SH AUTHOR
.I Jim Jackson
.br
.sp
.I Email: jj@franjam.org.uk
.br
|