Browse Source

Initial commit

master
Doug Le Tough 2 years ago
commit
1a906f6145
127 changed files with 774179 additions and 0 deletions
  1. +49
    -0
      4500.txt
  2. +49
    -0
      6300.txt
  3. BIN
      arkanoid.k7
  4. BIN
      arkanoid.wav
  5. +37031
    -0
      filelist.txt
  6. +35
    -0
      freq.sh
  7. +723189
    -0
      k7.raw
  8. +177
    -0
      k7towav.py
  9. +131
    -0
      k7towav2.py
  10. +15
    -0
      plot.py
  11. +49
    -0
      plot.txt
  12. +1
    -0
      sbin.txt
  13. +59
    -0
      siggen-2.3.10/.siggen.conf
  14. +118
    -0
      siggen-2.3.10/CHANGES
  15. +98
    -0
      siggen-2.3.10/CONFIG.FILES
  16. +112
    -0
      siggen-2.3.10/CONFIG.VALUES
  17. +340
    -0
      siggen-2.3.10/COPYING
  18. +184
    -0
      siggen-2.3.10/DAC.c
  19. BIN
      siggen-2.3.10/DAC.o
  20. +150
    -0
      siggen-2.3.10/Makefile
  21. +21
    -0
      siggen-2.3.10/README
  22. +111
    -0
      siggen-2.3.10/README.tones
  23. +13
    -0
      siggen-2.3.10/TODO
  24. +0
    -0
      siggen-2.3.10/VERSION.2.3.10
  25. +59
    -0
      siggen-2.3.10/adB.c
  26. +249
    -0
      siggen-2.3.10/config.h
  27. +241
    -0
      siggen-2.3.10/config.h.linux
  28. +109
    -0
      siggen-2.3.10/config.h.sunos
  29. +218
    -0
      siggen-2.3.10/configsubs.c
  30. BIN
      siggen-2.3.10/configsubs.o
  31. +52
    -0
      siggen-2.3.10/dB.c
  32. +104
    -0
      siggen-2.3.10/fmtheaders.h
  33. +396
    -0
      siggen-2.3.10/fsynscr.c
  34. BIN
      siggen-2.3.10/fsynscr.o
  35. BIN
      siggen-2.3.10/fsynth
  36. +130
    -0
      siggen-2.3.10/fsynth.1
  37. +253
    -0
      siggen-2.3.10/fsynth.c
  38. +27
    -0
      siggen-2.3.10/fsynth.h
  39. BIN
      siggen-2.3.10/fsynth.o
  40. +638
    -0
      siggen-2.3.10/generator.c
  41. BIN
      siggen-2.3.10/generator.o
  42. +148
    -0
      siggen-2.3.10/misc.c
  43. BIN
      siggen-2.3.10/misc.o
  44. +91
    -0
      siggen-2.3.10/mixer.c
  45. +56
    -0
      siggen-2.3.10/mixer.h
  46. BIN
      siggen-2.3.10/mixer.o
  47. +448
    -0
      siggen-2.3.10/scfio.c
  48. +201
    -0
      siggen-2.3.10/scfio.doc
  49. +181
    -0
      siggen-2.3.10/scfio.h
  50. BIN
      siggen-2.3.10/scfio.o
  51. +265
    -0
      siggen-2.3.10/scrsubs.c
  52. BIN
      siggen-2.3.10/scrsubs.o
  53. BIN
      siggen-2.3.10/sgen
  54. +193
    -0
      siggen-2.3.10/sgen.1
  55. +431
    -0
      siggen-2.3.10/sgen.c
  56. BIN
      siggen-2.3.10/sgen.o
  57. BIN
      siggen-2.3.10/siggen
  58. +247
    -0
      siggen-2.3.10/siggen.1
  59. +153
    -0
      siggen-2.3.10/siggen.aft
  60. +341
    -0
      siggen-2.3.10/siggen.c
  61. +238
    -0
      siggen-2.3.10/siggen.conf.5
  62. +40
    -0
      siggen-2.3.10/siggen.h
  63. +296
    -0
      siggen-2.3.10/siggen.html
  64. BIN
      siggen-2.3.10/siggen.o
  65. +442
    -0
      siggen-2.3.10/sigscr.c
  66. BIN
      siggen-2.3.10/sigscr.o
  67. BIN
      siggen-2.3.10/smix
  68. +172
    -0
      siggen-2.3.10/smix.1
  69. +457
    -0
      siggen-2.3.10/smix.c
  70. BIN
      siggen-2.3.10/smix.o
  71. BIN
      siggen-2.3.10/soundinfo
  72. +58
    -0
      siggen-2.3.10/soundinfo.1
  73. +329
    -0
      siggen-2.3.10/soundinfo.c
  74. BIN
      siggen-2.3.10/soundinfo.o
  75. BIN
      siggen-2.3.10/sweepgen
  76. +206
    -0
      siggen-2.3.10/sweepgen.1
  77. +307
    -0
      siggen-2.3.10/sweepgen.c
  78. +38
    -0
      siggen-2.3.10/sweepgen.h
  79. BIN
      siggen-2.3.10/sweepgen.o
  80. +382
    -0
      siggen-2.3.10/sweepscr.c
  81. BIN
      siggen-2.3.10/sweepscr.o
  82. BIN
      siggen-2.3.10/swgen
  83. +206
    -0
      siggen-2.3.10/swgen.1
  84. +440
    -0
      siggen-2.3.10/swgen.c
  85. BIN
      siggen-2.3.10/swgen.o
  86. BIN
      siggen-2.3.10/tones
  87. +383
    -0
      siggen-2.3.10/tones.1
  88. +393
    -0
      siggen-2.3.10/tones.c
  89. +60
    -0
      siggen-2.3.10/tones.eg/Makefile
  90. +114
    -0
      siggen-2.3.10/tones.eg/README.tones
  91. +62
    -0
      siggen-2.3.10/tones.eg/clementine.notes
  92. +53
    -0
      siggen-2.3.10/tones.eg/dtmf
  93. +49
    -0
      siggen-2.3.10/tones.eg/hole_bucket.notes
  94. +45
    -0
      siggen-2.3.10/tones.eg/ramp.c
  95. +15
    -0
      siggen-2.3.10/tones.eg/ramp.sh
  96. +59
    -0
      siggen-2.3.10/tones.eg/randnote.c
  97. +7
    -0
      siggen-2.3.10/tones.eg/randnote.sh
  98. +43
    -0
      siggen-2.3.10/tones.eg/randtone.c
  99. +7
    -0
      siggen-2.3.10/tones.eg/randtone.sh
  100. +18
    -0
      siggen-2.3.10/tones.eg/samples/Makefile

+ 49
- 0
4500.txt View File

@ -0,0 +1,49 @@
0 0
76 1
122 2
119 3
69 4
-8 5
-82 6
-124 7
-116 8
-62 9
16 10
88 11
125 12
113 13
55 14
-24 15
-94 16
-126 17
-109 18
-47 19
32 20
99 21
127 22
104 23
40 24
-40 25
-104 26
-127 27
-99 28
-32 29
47 30
109 31
126 32
94 33
24 34
-55 35
-113 36
-125 37
-88 38
-16 39
62 40
116 41
124 42
82 43
8 44
-69 45
-119 46
-122 47
-76 48

+ 49
- 0
6300.txt View File

@ -0,0 +1,49 @@
0 0
99 1
124 2
55 3
-55 4
-124 5
-99 6
0 7
99 8
124 9
55 10
-55 11
-124 12
-99 13
0 14
99 15
124 16
55 17
-55 18
-124 19
-99 20
0 21
99 22
124 23
55 24
-55 25
-124 26
-99 27
0 28
99 29
124 30
55 31
-55 32
-124 33
-99 34
0 35
99 36
124 37
55 38
-55 39
-124 40
-99 41
0 42
99 43
124 44
55 45
-55 46
-124 47
-99 48

BIN
arkanoid.k7 View File


BIN
arkanoid.wav View File


+ 37031
- 0
filelist.txt
File diff suppressed because it is too large
View File


+ 35
- 0
freq.sh View File

@ -0,0 +1,35 @@
#!/bin/sh
clear
RAW=k7.raw
WAV=k7.wav
BIN_FILE=sbin.txt
if [ -f $RAW ]
then
echo "Deleting previous $RAW file."
rm $RAW
fi
if [ -f $WAV ]
then
echo "Deleting previous $WAV file."
rm $WAV
fi
A=0
BITS=`wc -w $BIN_FILE | awk -F " " '{print $1}' `
for BIT in `cat $BIN_FILE`
do
if [ $BIT -eq 1 ]
then
sgen -s 48000 -o $RAW -a -t 1m cos 6300 -16
else
sgen -s 48000 -o $RAW -a -t 1m cos 4500 -16
fi
A=$(($A+1))
SIZE=`ls -lh $RAW | awk -F " " '{print $5}'`
printf '\033[1;1H\033[J'"Recording bit $A/$BITS ($RAW : $SIZE)"
done
echo "Converting $RAW to $WAV..."
sox -t raw -L -b 16 -r 48k -e signed-integer $RAW -t wav -b 16 -r 48k -e signed-integer $WAV
echo "Done."

+ 723189
- 0
k7.raw
File diff suppressed because it is too large
View File


+ 177
- 0
k7towav.py View File

@ -0,0 +1,177 @@
#!/usr/bin/env python
#
# Converts TO7 K7 files into wav file.
#
# History:
# 15/01/2010 Original code by Doug Letougth.
# 16/01/2010 Reworked by Samuel Devulder to speed it up and make it work with
# http://nostalgies.thomsonistes.org/archives/k7tools-2.1a-dosexe.zip
# 17/01/2010 Added a 1sec 6.3khz signal at start of blocks.
# Also added 1sec pause at end of header and end of file block
# (to simulate motor start delay). The resulting file works under MESS.
#
import sys
import os
import wave
import math
import struct
# wav freq
freq = 44100
# number of bits per sample (8 or 16)
nbits = 8
# number of channels (1 = mono, 2 = stereo)
nchans = 1
# transmission rate (bits per seconds)
bps = 900
# relative intensity level for each bit (not necessary but helps reading the curves visualy)
vol0 = 0.9
vol1 = 0.6
# Clear screen (avalibale only on posix systems)
if os.name == "posix":
print "\x1b[1;1H\033[J"
# Some ansi escape characters for verbose display
ansi_esc="\x1b[1;1H"
else:
# No ansi for non-POSIX compliant systems
ansi_esc=""
if len( sys.argv ) != 3 :
exit("Usage : k7towav.py <input .k7 file> <output .wav file>")
else:
input_k7 = sys.argv[1]
output_wav = sys.argv[2]
if not os.path.isfile(input_k7) :
exit("File not found : " + input_k7)
if os.path.isfile(output_wav) :
exit("File already exists : " + output_wav)
# TODO : Add some code here for asking for overwrite
# 2pi
two_pi = 2*math.pi
# length of a bit
samples_per_bit = int(freq / bps)
# 4.5khz signal sample
bit0 = [ math.sin( two_pi*5*x/samples_per_bit ) for x in range(samples_per_bit) ]
# 6.3khz signal sample
bit1 = [ math.sin( two_pi*7*x/samples_per_bit ) for x in range(samples_per_bit) ]
# scale
scale = (2**nbits - 1)/2
# build up string representing the frames for bit0 and bit1 (all channels have the same value).
if nbits==8:
fmt = 'B'
elif nbits==16:
fmt = 'H'
else:
exit("Invalid number of bits: " + str(nbits))
sig_0 = ''
for x in bit0:
for y in range(nchans):
sig_0 += struct.pack(fmt, int(scale*max(0,min(2, 1+x*vol0))))
sig_1 = ''
for x in bit1:
for y in range(nchans):
sig_1 += struct.pack(fmt, int(scale*max(0,min(2, 1+x*vol1))))
# build up strings representing various silence length
inactive_level = 0 # should be -1 according to the docs
silence = ''
for x in range(int(1.00 * freq)):
silence += struct.pack(fmt, int(scale*max(0,min(2, 1+inactive_level))))
start6300 = ''
for x in range(int(1.00 * freq)):
start6300 += struct.pack(fmt, int(scale*max(0,min(2, 1+0.4*math.sin(two_pi * x* 6300/freq)))))
# Bit counter (for display purpose)
bitnum=0
# open files
k7 = open(input_k7,"rb")
wav = wave.open(output_wav,"wb")
wav.setparams((nchans, nbits>>3, freq, 0, 'NONE', 'noncompressed'))
# initial separation
wav.writeframesraw(start6300)
# block state-machine parameters
state = 0
blk_len = None
while 1 :
c = k7.read(1)
if not c:
break
byte = ord(c)
# Start bit is 0
wav.writeframesraw(sig_0)
# Byte processing
acc = byte | 256
while acc != 1:
bitnum=bitnum+1
bit = 1 & acc
acc >>= 1
if bit:
wav.writeframesraw(sig_1)
else:
wav.writeframesraw(sig_0)
if bitnum % 5123 == 0:
print ansi_esc+"Processing bit # "+str(bitnum & 7)+" from byte # "+str(bitnum>>3)+" ("+str(bit)+") "+str(wav.tell()/1024)+" Kbytes"
# Ending bits are 1 (2 bits)
wav.writeframesraw(sig_1)
wav.writeframesraw(sig_1)
# block state machine.
if state==0:
# State 0 to 3 looks for specific block starts that matches (ff ff .. ff 01 3c)
if byte==0xff:
state=1
else:
state=0
elif state==1:
if byte==0xff:
state=1
elif byte==0x01:
state=2
else:
state=0
elif state==2:
if byte==0x3c:
state=3
else:
state=0
elif state==3:
# read block type: 00=header, 01=data, ff=end of file
state=4
blk_type = byte
elif state==4:
# read block length
blk_len = byte
state=5
elif state==5:
# within block
blk_len = blk_len-1
if blk_len<0:
state = 0
# add a sep at end of header block or at end of file block
if blk_type==0 or blk_type==0xff:
wav.writeframesraw(silence)
wav.writeframesraw(start6300)
wav.writeframesraw(silence)
k7.close()
wav.close()

+ 131
- 0
k7towav2.py View File

@ -0,0 +1,131 @@
#!/usr/bin/env python
#
# Converts TO7 K7 files into wav file.
#
# History:
# 15/01/2010 Original code by Doug Letougth.
# 16/01/2010 Reworked by Samuel Devulder to speed it up and make it work with http://nostalgies.thomsonistes.org/archives/k7tools-2.1a-dosexe.zip
#
import sys
import os
import wave
import math
import struct
# wav freq
freq = 44100
# number of bits per sample (8 or 16)
nbits = 8
# number of channels (1 = mono, 2 = stereo)
nchans = 1
# transmission rate (bits per seconds)
bps = 900
# relative intensity level for each bit (not necessary but helps reading the curves visualy)
vol0 = 0.6
vol1 = 0.9
# Clear screen (avalibale only on posix systems)
if os.name == "posix":
print "\x1b[1;1H\033[J"
# Some ansi escape characters for verbose display
ansi_esc="\x1b[1;1H"
else:
# No ansi for non-POSIX compliant systems
ansi_esc=""
if len( sys.argv ) != 3 :
exit("Usage : k7towav.py <input .k7 file> <output .wav file>")
else:
input_k7 = sys.argv[1]
output_wav = sys.argv[2]
if not os.path.isfile(input_k7) :
exit("File not found : " + input_k7)
if os.path.isfile(output_wav) :
exit("File already exists : " + output_wav)
# TODO : Add some code here for asking for overwrite
# Return the byte as a list of bits
def bstr(n):
return ''.join([str(n >> x & 1) for x in (0,1,2,3,4,5,6,7)])
# 2pi
two_pi = 2*math.pi
# length of a bit
samples_per_bit = int(freq / bps)
# 4.5khz signal sample
#bit0 = [ math.sin( two_pi*5*x/samples_per_bit ) for x in range(samples_per_bit) ]
# 6.3khz signal sample
#bit1 = [ math.sin( two_pi*7*x/samples_per_bit ) for x in range(samples_per_bit) ]
bit0 = []
bit1 = []
for x in range(samples_per_bit) :
sig0 = math.sin( two_pi*5*x/samples_per_bit )
sig1 = math.sin( two_pi*7*x/samples_per_bit )
if sig0 >= 0:
bit0.append(1)
else :
bit0.append(-1)
if sig1 > 0:
bit1.append(1)
else :
bit1.append(-1)
# scale
scale = (2**nbits - 1)/2
# build up string representing the frames for bit0 and bit1 (all channels have the same value).
sig_0 = ''
for x in bit0:
for y in range(nchans):
sig_0 += struct.pack('B', int(scale*(1+x*vol0)))
sig_1 = ''
for x in bit1:
for y in range(nchans):
sig_1 += struct.pack('B', int(scale*(1+x*vol1)))
# Byte counter (for display purpose)
bytenum=0
k7 = open(input_k7,"rb")
wav = wave.open(output_wav,"wb")
wav.setparams((nchans, nbits>>3, freq, 0, 'NONE', 'noncompressed'))
while 1 :
byte = k7.read(8)
if not byte:
break
bytenum=bytenum+1
# bit counter (for display purpose)
bitnum=0
for c in byte :
bbyte = bstr(ord(c))
bitnum=bitnum+1
# Start bit is 0
wav.writeframesraw(sig_0)
# Byte processing
for bit in bbyte :
if bit == "0" :
wav.writeframesraw(sig_0)
else:
wav.writeframesraw(sig_1)
if (bytenum*8 + bitnum) % 123 ==0:
print ansi_esc+"Processing bit # "+str(bitnum)+" from byte # "+str(bytenum)+" ("+bit+") "+str(wav.tell()/1024*2)+" Kbytes"
# Ending bits are 1 (2 bits)
wav.writeframesraw(sig_1)
wav.writeframesraw(sig_1)
k7.close()
wav.close()

+ 15
- 0
plot.py View File

@ -0,0 +1,15 @@
#!/usr/bin/env python
import sys
import os.path
import math
plot_file = open("plot.txt","w")
two_pi = 2*math.pi
for i in range(49):
data = str(127*(1+math.sin(5*two_pi*i/49)))+"\t"+str(i)+"\n"
print data
plot_file.write(data)
plot_file.close()

+ 49
- 0
plot.txt View File

@ -0,0 +1,49 @@
127.0 0
202.960037372 1
248.750817336 2
246.1854896 3
196.282932454 4
118.863082062 5
44.6749937959 6
3.18415515291 7
10.869596877 8
64.6788708955 9
143.240399534 10
215.351683927 11
252.372086494 12
239.598111909 13
182.103234868 14
102.722854155 15
32.9846943714 16
0.586852655452 17
18.3968690983 18
79.3410903803 19
159.214132157 20
226.292598273 21
253.934749457 22
231.161876334 23
167.018743689 24
86.981256311 25
22.8381236662 26
0.0652505425126 27
27.7074017266 28
94.7858678435 29
174.65890962 30
235.603130902 31
253.413147345 32
221.015305629 33
151.277145845 34
71.8967651321 35
14.4018880906 36
1.62791350636 37
38.6483160734 38
110.759600466 39
189.321129105 40
243.130403123 41
250.815844847 42
209.325006204 43
135.136917938 44
57.7170675463 45
7.81451039968 46
5.24918266434 47
51.0399626276 48

+ 1
- 0
sbin.txt
File diff suppressed because it is too large
View File


+ 59
- 0
siggen-2.3.10/.siggen.conf View File

@ -0,0 +1,59 @@
# default DAC digital analogue converter device name
dacfile /dev/dsp
# default mixer device file....
mixerfile /dev/mixer
# default samplerate
samplerate 22050
# for siggen & sweepgen set a samplerate of ......
siggen:samplerate 32000
sweepgen:samplerate 32000
# default number of channels is 1. i.e. mono output
channels 1
# but for siggen, sweepgen default is stereo.....
siggen:channels 2
sweepgen:channels 2
# and for tones default channels is 8
# No not quadraphonic, but the number of different freqs that be mixed
# and played at once.
tones:channels 8
# and for fsynth default channels is 13
# The number of harmonics that can mixed to make the waveform
fsynth:channels 13
# default samplesize is usually to try for 16 bit and if that fails
# to try 8 bits. If anything is actually specified either on command
# line or in config file then that is attempted only.
#samplesize 16
# default number of audio buffer fragments for interactive programs
# compromise between sufficient buffering for playahead to cover
# time when other programs are scheduled, and time it takes for
# changes in generation parameters to feed thro' to being heard.
# Too low a value and sound will break up.
# Too high a value and programs will feel very unresponsive to changes
fragments 4
# default number of buffers per second required. This is used to calculate
# the buffer fragment size. It is always to nearest power of 2.
bufferspersec 15
# default gain is in dB
gain dB
# number of loadable waveforms allowed........
#loadable_waveforms 10
# default verbosity is 0
verbose 0
# vi_keys by default they are turned off
vi_keys 0
fsynth:vi_keys 0

+ 118
- 0
siggen-2.3.10/CHANGES View File

@ -0,0 +1,118 @@
siggen - a package of waveform generation programs for linux
------------------------------------------------------------
Version 2.3.+
siggen
Tried adding loadable waveforms - came to an impasse. I will revisit
this.
Added a "tracking" feature suggested by Gart Reese. 't' or 'T'
while in the waveform, frequency or gain fields will cause both
similar fields of each channel to track, i.e. have the same value.
A "tracking" message shows which fields are currently tracking.
Repeating 't' or 'T' cancels the tracking of the fields.
fsynth
A curses based "fourier" synthesis program. Allows a mixture of
a fundamental sine wave and varying proportions of it's harmonics
to be mixed to create complex waveforms.
tones
Added loadable waveforms. Tones can load a waveform from a WAV file
that contains exactly one seconds worth of samples, at the same samplerate
as tones is using and same format etc, and it will "play" from the these
samples. The waveform name is the basename of the wav file with directory
and any suffix removed. To work correctly the samples should be for a 1Hz
wave. If its for say a 2Hz wave then the frequencies generated will all
be double for that waveform.
Added recursive command file reading.
Attenuation/gain levels added, thanks to "Mark E. Shoulson"
<mark@kli.org> for a patch, feedback and comments. Fixed faulty mixing
code for more than 2 channels.
All curses progs
The ability to "Lock" input field to freeze values. Locked fields
are skipped while moving around the screen. All locked fields can
be unlocked in one go to reset. '!' or 'L' locks the current field,
'U' unlocks all locked fields. This was the result of misunderstanding
an idea from Garst!
Also added ability to redraw screen by pressing Ctrl-L (^L), useful
if screen gets garbled.
Bug fix in scfio.c, thanks to "Garst R. Reese" <reese@isn.net>
for use egcs and finding the bug - I think gcc was too forgiving.
All progs
Added configuration file(s) support.
Version 2.2
tones, sgen, swgen
Added ability to compile on machines without sound support,
so that WAV and raw data files can be created.
Fixed so can be compiled under SUNOS on sparc machines. This meant
fixing the implicit little endian nature of the raw and wav file writing
code.
New config.h file added with user configurable options gathered together
in one place, for global options.
tones, sgen, swgen
Added the -x10 and -x100 options, which when in use allow the
generation of freq. to the nearest 0.1Hz or 0.01Hz by forcing
the specification of all frequencies to be 10 or 100 times
too big.
e.g. swgen -x10 -2 -v 2 2000 20000
causes stereo samples for a 0.2Hz sawtooth ramp sweeping
a sin wave from 200Hz to 2000Hz.
Version 2.1
Fixed compilation problem of incompatible extern declaration
of sys_errlist . extern wasn't necessary so deleted it.
Version 2
Added swgen - a swept frequency generator.
Added sweepgen - a curses based swept freq. generator
Changed siggen to play continuously - changes to waveform, freq,
gain etc take effect (almost) immediately. Downside is that
this is a lot more processor intensive. Fine, just, on my 486DX2/66.
Extended the tones program, extensively.
Added dtmf program which can be used as tone phone dialer.
Fixed mixed up description of sawtooth/triangle waves in sgen manual.
Version 1.1 released xx March 1997
Fixed a small initialise bug in sgen - reported by
Michael Meifert <mime@dk3hg.hanse.de>
(Michael this email address doesn't work)
Fixed a bug in siggen that prevented PULSE waveforms being generated
Added the tones program following a suggestion by Michael who
wanted a program to generate tones to control a radio repeater (I think).
Version 1 released 6 March 1997
contained programs sgen, siggen, smix, soundinfo

+ 98
- 0
siggen-2.3.10/CONFIG.FILES View File

@ -0,0 +1,98 @@
Siggen's Sound Configuration File scheme Jim Jackson
---------------------------------------- Sep 1998
As from siggen version 2.3 onwards a versatile configuration file scheme has
been introduced. It allows parameters for all the siggen programs to be
specified either across the board, or specifically for particular programs.
The Configuration Files
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.
All the programs are compiled with the names of the config files built in.
The filenames are set in the config.h header file and can be changed. The
LOCAL and GLOBAL config files are specified by the settings of:
LOCAL #define DEF_CONF_FILENAME ".siggen.conf"
GLOBAL #define DEF_GLOBAL_CONF_FILE "/etc/siggen.conf"
And can be set to any file name or to NULL to disable the file. The HOME
config filename is created using the HOME environment variable and the
DEF_CONF_FILENAME together, i.e. using the above, the HOME config file for a
user whose home directory is at /home/jj, would be
HOME /home/jj/.siggen.conf
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.
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.
If no configuration files exist, the programs themselves provide builtin
default values (see config.h etc), and most of these values can be set
by appropriate command line switches and flags.
Configuration Values
A configuration value has a name and a value, and values for all programs
are set by simply entering a line in the appropriate config file where the
first word is the name, followed by arbitrary spaces/tabs, followed by the
value. The value is all the rest of that line. e.g. to set the global
default samplerate of 44100 samples per sec, the following line would be
entered in the GLOBAL config file:
SAMPLERATE 44100
Config value names are case insensitive.
A config value can be set for a specific program, by prefixing the config
value name with the program name and a ':'. e.g. to specify a samplerate of
only 8000 samples per sec for the tones program enter
TONES:SAMPLERATE 8000
in the relevant config file. If both lines above were in the config file,
all programs except tones would use a samplerate of 44100, and tones would
use 8000.
You do not have to specify all configuration values in the config files.
If a particular value is missing, the programs will simply use their builtin
defaults (see config.h etc).
Configuration values set by command line switches or flags take precedence
over values in any of the config files.
Beware: the programs do not have their 'name' built-in, but use the name they
were invoked by. So if you change the name of a program, remember to change
the config file entries. However this does means that by using links to a
program, it can be made to pick up a different set of configuration values,
depending on the name it is invoked by.
Example Configuration File
A sample config file is provided in ".siggen.conf". Any line whose first
non-whitespace character is a '#', is a comment line and is ignored.
What Configuration Values are there?
Please see the seperate file CONFIG.VALUES for details of each config value,
and which programs use them and what the default builtin values are.
The Source and Functions
The source for the config functions is in configsubs.c and independant
of the rest of the source. The functions can easily be used in other
programs to provide configuration facilities.

+ 112
- 0
siggen-2.3.10/CONFIG.VALUES View File

@ -0,0 +1,112 @@
Complete List of Configuration Values used by SIGGEN progams
------------------------------------------------------------
Name sgen swgen tones siggen sweepgen fsynth smix
-------- ---- ----- ----- ------ -------- ------ ----
BUFFSPERSEC N N N Y Y Y N
CHANNELS Y Y Y Y Y Y N
DACFILE Y Y Y Y Y Y N
FRAGMENTS N N N Y Y Y N
LOADABLE_WAVEFORMS
N N Y N N N N
MIXERFILE N N N N N N Y
SAMPLERATE Y Y Y Y Y Y N
SAMPLESIZE Y Y Y Y Y Y N
VERBOSE Y Y Y Y Y Y Y
VI_KEYS N N N Y Y Y N
Configuration Value Details
---------------------------
BUFFSPERSEC The number of sound buffer fragments to play every second.
This is used to calculate the size of the buffer fragments, to
the nearest power of 2. see FRAGMENTS below for a fuller
discussion.
CHANNELS In all programs except tones and fsynth, channels specifies
the number of output channels to use, i.e. 1 for Mono and 2 for
Stereo.
For tones, channels specifies the number of 'voices' on which
tones can generate different waveforms before mixing them into
the one output channel.
For fsynth, channels specifies the numbers of seperately
configurable oscillators used to mix the single output channel.
DACFILE The Digital to Analogue Converter (or PCM of DSP) device on
which to output the generated samples. This must be a real OSS
PCM device, otherwise the ioctls used will fail.
FRAGMENTS The number of Audio Buffer fragments to configure in the driver.
The interactive programs respond to changes made to parameters
from the keyboard immediately, but data will be buffered in
driver in the buffer fragments. If the amount of data buffered
is too much then there will very noticable delays before the
output sound is altered. Against that, insufficient buffering
may mean that there is not enough data buffered for output to
cover the time when other processes are being run by the
scheduler. The programs set the buffer size so that aprox.
BUFFSPERSEC buffers are played every second. Hence there will
be (FRAGMENTS/BUFFSPERSEC) seconds worth of samples buffered.
Hence if FRAGMENTS is set to 3, and BUFFSPERSEC set to 15,
there will be aprox. 3/15 = 0.2 secs worth of sound buffered
for output. On a lightly loaded fast machine this, should be
sufficient. To cover periods of heavy load or on a less
powerful machine set FRAGMENTS to 4 or 5, or set BUFFSPERSEC to
a lower value. But remember the interactive programs will
appear sluggish in responding to the keyboard.
LOADABLE_WAVEFORMS
Number of loadable waveforms allowed.
MIXERFILE The mixer device to control. This must be a real OSS
mixer device, otherwise the ioctls used will fail.
SAMPLERATE The number of samples per second to use. If output is to the DAC
then the DAC device is set to output samples at this rate.
BEWARE: not all cards can support all samplerates. SoundBlasters
are fairly flexible in this respect. Other cheaper cards are
not. Indeed some cards can only handle a very restricted set of
related samplerates e.g. 11025, 22050, 44100 & 8000, 16000,
32000, 48000. When writing to DACFILE all programs will attempt
to set the samplerate given, but use the actual samplerate the
device used. Use the verbose command line flag to check actual
samplerates used.
8000 is the samplerate used in the phone system with 8 bit
samples, and is adequate for voice range frequencies.
44100 is the samplerate used in audio CDs
48000 is the samplerate used in DAT systems, I think.
32000 is also used, but I forget where.
In general, the higher the samplerate the larger the memory
and processing requirement, but the higher the frequency range
and the more accurate the signals generated.
SAMPLESIZE Number of bits per sample. Only two values are allowed currently,
8 or 16.
8 bit samples are unsigned, with decimal value 128 being the
'zero' level.
16 bit samples are signed little endian values, i.e. the least
significant byte comes before the most significant byte either in
a file, or in the byte stream to an output device.
If samplesize if left completely unspecified, then all programs
will attempt to do 16 bit samples to DACFILE, and if that isn't
possible will do 8 bit samples. Or if writing to a file, 16 bit
samples will be written.
VERBOSE sets verbosity level.
0 - is quiet
1 - is be a bit verbose (equiv. to -v switch)
2 - is be very verbose (equiv. to -vv switch)
VI_KEYS if set to a non-zero value, then the VI cursor moving keys
"HJKL" are enabled.

+ 340
- 0
siggen-2.3.10/COPYING View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

+ 184
- 0
siggen-2.3.10/DAC.c View File

@ -0,0 +1,184 @@
/* DAC.c
* miscellaneous routines for handling sound driver /dev/dsp device
* Jim Jackson
*
* Covered by GNU Public license - see file COPYING
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/soundcard.h>
/* DACopen(device,mode,&samplerate,&fmt,&stereo)
* opens device for mode (r/w) at samplerate samples/sec in 8/16 bit fmt
* and in stereo. Sets these params to best match possible.
*
* getfragsize(fd)
* get fragment size of a DSP buffer
*
* getfreeobufs(fd)
* return number of free output fragment buffers free at moment
*
* getfullibufs(fd)
* return number of full input fragment buffers full at moment
*
* setfragsize(fd,N,bfps,S,afmt,stereo)
* set number of buffers to N and size such that we get aprox bfps buffers
* played per second. S samples per sec of mono/stereo, 8/16 bit samples.
*
* is16bit(fd)
* returns true if file fd is a 16 sound device
*
* isstereo(fd)
* returns true if file fd is a stereo sound device (To Be Done)
*/
/* is16bit(fd) return true if fd is a dsp device supporting 16 bit
* sampling. Return false if not.
*/
is16bit(fd)
int fd;
{
int fmts;
if (ioctl(fd, SNDCTL_DSP_GETFMTS , &fmts) < 0) {
return(0);
}
return(fmts&AFMT_S16_LE);
}
/* getfragsize(fd) return fragsize of DSP buufer for fd
* or return -1 on error.
*/
getfragsize(fd)
int fd;
{
int n;
if (ioctl(fd, SNDCTL_DSP_GETBLKSIZE, &n)<0) return(-1);
return(n);
}
/* getfreeobufs(fd) return number of empty output fragment buffers
* available or return -1 on error.
*/
getfreeobufs(fd)
int fd;
{
int n;
audio_buf_info osp;
if (ioctl(fd,SNDCTL_DSP_GETOSPACE, &osp)<0) return(-1);
return(osp.fragments);
}
/* getfullibufs(fd) return number of full input fragment buffers
* available or return -1 on error.
*/
getfullibufs(fd)
int fd;
{
int n;
count_info isp;
if (ioctl(fd,SNDCTL_DSP_GETIPTR, &isp)<0) return(-1);
return(isp.bytes);
}
/* printibufs(fd) print input audio_buf_info
* return -1 on error.
*/
printibufs(fd)
int fd;
{
int n;
count_info isp;
if (ioctl(fd,SNDCTL_DSP_GETIPTR, &isp)<0) return(-1);
printf("Count Info: bytes=%d, blocks=%d, ptr=%0Xx\n",
isp.bytes, isp.blocks, isp.ptr);
return(0);
}
/* setfragsize(fd,N,bfps,S,afmt,stereo)
* calculate buffer size to ensure aproximately
* bfps buffers per second, then set N buffs of this size
* afmt is 8 or 16 bit samples, stereo is true if 2 chans
* return -1 if error - see errno, else return fragsize
* set.
*/
setfragsize(fd,N,bfps,S,afmt,stereo)
int fd,N,bfps,S,afmt,stereo;
{
int fr,n;
if (N<1) {
errno=EINVAL; return(-1);
}
n=S/bfps; /* n is samplerate / buffers/sec */
for (fr=5; (2<<fr) < n ; fr++) { }
/* adjust for stereo and 16 bits */
fr=(N<<16)+fr+((stereo)?1:0)+((afmt==AFMT_S16_LE)?1:0);
if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT , &fr) < 0) return(-1);
if (ioctl(fd, SNDCTL_DSP_GETBLKSIZE , &n) < 0) return(-1);
return(n);
}
/*
* DACopen(char *fnm, char *mode, int *samples, int *fmt, int *stereo)
*
* open dspfile for read "r" or write "w", and set samples per sec
* as sampling rate - note we get pointer for samples so we can
* return the actual samplerate set.
* If stereo mode is unspecified (-1) then set stereo if possible,
* if fmt is unspecified (AFMT_QUERY) then set 16 bit if possible
* otherwise we set mono and/or 8 bit.
* Actual settings are returned in fmt and stereo.
* return file descriptor or -1 on error.
*/
DACopen(fnm,mode,samples,fmt,stereo)
char *fnm;
char *mode;
int *samples,*fmt,*stereo;
{
int fd;
int m,i;
if (*mode=='r') m=O_RDONLY;
else if (*mode=='w') m=O_WRONLY;
else {
errno=EINVAL; return(-1);
}
if ((fd = open (fnm,m,0)) >= 0) { /* params must be set in this order */
if ((*fmt==AFMT_QUERY) && is16bit(fd)) *fmt=AFMT_S16_LE;
if (ioctl(fd, SNDCTL_DSP_SETFMT, fmt)>=0) {
if (*stereo==-1) {
*stereo=1;
if (ioctl(fd, SNDCTL_DSP_STEREO, stereo)<0) *stereo=0;
}
if (ioctl(fd, SNDCTL_DSP_STEREO, stereo)>=0) {
if (ioctl(fd, SNDCTL_DSP_SPEED, samples)>=0) {
return(fd);
}
}
}
}
return(-1);
}

BIN
siggen-2.3.10/DAC.o View File


+ 150
- 0
siggen-2.3.10/Makefile View File

@ -0,0 +1,150 @@
#
# Makefile for jj's siggen .....
SHELL = /bin/sh
# Version of siggen
V = 2.3
# Edit PROGS to make the programs you want. You may wish to omit smix
# if you do not want yet another mixer program.
PROGS = tones sgen swgen siggen sweepgen fsynth soundinfo smix
#
TEXTS = tones.txt sgen.txt swgen.txt siggen.txt sweepgen.txt soundinfo.txt smix.txt fsynth.txt siggen.conf.txt
#
# simple command line programs......
TONES = tones.o tonesgen.o generator.o misc.o wavfile.o wavsubs.o DAC.o configsubs.o
SGEN = sgen.o generator.o misc.o wavfile.o wavsubs.o DAC.o configsubs.o
SWGEN = swgen.o generator.o misc.o wavfile.o wavsubs.o DAC.o configsubs.o
SMIX = smix.o mixer.o configsubs.o
#
# curses based programs......
FSYNTH = fsynth.o fsynscr.o scrsubs.o generator.o misc.o DAC.o scfio.o configsubs.o
SIGGEN = siggen.o sigscr.o scrsubs.o generator.o misc.o DAC.o scfio.o configsubs.o
SWEEPGEN = sweepgen.o sweepscr.o scrsubs.o generator.o misc.o DAC.o scfio.o configsubs.o
#
srcdir = .
includedir = /usr/include/ncurses
INSDIR = /usr/local/bin
MANDIR = /usr/local/man
LOCALINS = $(HOME)/bin
LOCALMAN = $(HOME)/man
CC = gcc
CFLAGS = -O2
CPPFLAGS = -I. -I$(includedir)
CCFLAGS = $(CFLAGS) $(CPPFLAGS)
LINK = $(CC)
LDFLAGS = -lncurses -lm
.c.o: config.h
$(CC) -c $(CCFLAGS) $<
all: $(PROGS) $(TEXTS)
text: $(TEXTS)
%.txt: %.5
nroff -man $< | col -b -x > $@
%.txt: %.1
nroff -man $< | col -b -x > $@
mixer.o: mixer.c mixer.h
smix.o: smix.c mixer.h config.h
scfio.o: scfio.c scfio.h
scrsubs.o: scrsubs.c scfio.h config.h
sigscr.o: sigscr.c scfio.h config.h siggen.h
sigscr-1.o: sigscr-1.c scfio.h config.h
sweepscr.o: sweepscr.c scfio.h config.h sweepgen.h
fsynscr.o: fsynscr.c scfio.h fsynth.h config.h
fsynth.o: fsynth.c fsynth.h config.h
install:
@echo "2 install options :-"
@echo " make sysinstall"
@echo " into $(INSDIR) and $(MANDIR)"
@echo " make localinstall"
@echo " into $(LOCALINS) and $(LOCALMAN)"
localinstall: $(PROGS)
@strip $(PROGS)
@chmod 755 $(PROGS)
@echo "Copying $(PROGS) to $(LOCALINS)"
@cp -p $(PROGS) $(LOCALINS)
@for n in $(PROGS) ; do \
chmod 644 $$n.1 ; \
echo "Copying $$n.1 to $(LOCALMAN)/man1/$$n.1" ; \
cp -p $$n.1 $(LOCALMAN)/man1/$$n.1 ; \
done
@cp -p siggen.conf.5 $(LOCALMAN)/man5
@chmod 644 $(LOCALMAN)/man5/siggen.conf.5
sysinstall: $(PROGS)
@strip $(PROGS)
@chmod 755 $(PROGS)
@echo "Copying $(PROGS) to $(INSDIR)"
@cp -p $(PROGS) $(INSDIR)
@for n in $(PROGS) ; do \
chmod 644 $$n.1 ; \
echo "Copying $$n.1 to $(MANDIR)/man1/$$n.1" ; \
cp -p $$n.1 $(MANDIR)/man1/$$n.1 ; \
done
@cp -p siggen.conf.5 $(MANDIR)/man5
@chmod 644 $(MANDIR)/man5/siggen.conf.5
nodac:
make -f Makefile.NODAC all
vu: $(VU)
$(CC) $(VU) -o $@
soundinfo: soundinfo.o
$(CC) $@.o -o $@
sgen: $(SGEN)
$(CC) $(SGEN) -lm -o $@
swgen: $(SWGEN)
$(CC) $(SWGEN) -lm -o $@
tones: $(TONES)
$(CC) $(TONES) -lm -o $@
fsynth: $(FSYNTH) fsynth.h
$(CC) $(FSYNTH) $(LDFLAGS) -o $@
siggen: $(SIGGEN) siggen.h
$(CC) $(SIGGEN) $(LDFLAGS) -o $@
siggen-1: $(SIGGEN1) siggen.h
$(CC) -DVERSION1 $(SIGGEN1) $(LDFLAGS) -o $@
sweepgen: $(SWEEPGEN) sweepgen.h
$(CC) $(SWEEPGEN) $(LDFLAGS) -o $@
smix: $(SMIX) mixer.h
$(CC) $(SMIX) $(LDFLAGS) -o $@
clean:
rm -rf *.o $(PROGS) $(TEXTS) *~
dist:
make clean
(cd tones.eg; make clean)
(cd contrib; make clean)
(d=`basename $$PWD` ; cd .. ; tar cfz $$d.tgz $$d)

+ 21
- 0
siggen-2.3.10/README View File

@ -0,0 +1,21 @@
SIGGEN
------
See the siggen.aft files for an overview (or the derived file siggen.html).
If you aren't familiar with Almost Free Text (AFT) then, no problem, just
more or less the file. It should be readable as ASCII text.
There are manual pages for each utility. To read try
nroff -man siggen.1 | less
or install man pages into a suitable location and use man.
Finally there is the source.
Oh! There is a README.tones with info about the example directory (tones.eg)
for the tones program.
AFT homepage is http://www.maplefish.com/todd/aft.html

+ 111
- 0
siggen-2.3.10/README.tones View File

@ -0,0 +1,111 @@
Some notes on the 'tones' program. Jim Jackson
---------------------------------- May 1999
The tones program has growed out of a simple sequential tone generator that
I wrote for Michael Meifert <mime@dk3hg.hanse.de> for generating a sequence
of tones for control purposes. Since then I've expanded it to maintain a set
of 'channels', each channel having a seperately configured waveform,
frequency and intensities. All the channels are mixed to provide the output
signal. Mark E. Shoulson <mark@kli.org> provided a base patch for adding
intensity levels. However this showed up bugs in the digital mixer which
have now been fixed and the amplitude handling much expanded - see the
relevant sections in the manual page.
Musical note generation
Also I've added the ability to generate musical notes, by being able to
specify a note + optional sharp + octave digit, e.g. C3 is middle C. The
tuning is based on the standard concert A of 440Hz (A3), and an equally
tempered scale. Thanks to Ivor Dykes for the music lessons! If you want a
different tuning then the frequencies are defined in an array in tonesgen.c,
and can easily be altered to taste. Thanks also to Robert P. Hanssen
<hanssen@nova.org> for pointing out a correction to the freq. numbers used
for generating named notes.
Some examples
tones 2000 sin c3,e3,g3
plays the C Major chord
tones 100 sin 941,1336 0,0 697,1209 0,0 697,1209 0,0 697,1477 0,0
generate the dtmf dial tones for '0' '1' '1' '3'
Here are the frequencies to use.....
1 = 697,1209 2 = 697,1336 3 = 697,1477 4 = 770,1209
5 = 770,1336 6 = 770,1477 7 = 852,1209 8 = 852,1336
9 = 852,1477 0 = 941,1336 * = 941,1209 # = 941,1477
tones -loop :2000 sin 1000 square 1000 tri 1000 saw 1000 0
generate a series of test waveforms repeatedly. The ':' infront
of the default duration setting forces this to be a duration setting
even on the loop - otherwise it would be treated as a freq. spec.
Yeah it's a bug - but I couldn't see an easy fix.
More examples in the tones.eg directory
In sub-directory, tones.eg, there are some examples using the tones program.
Run make in the tones.eg directory to create the programs ramp, randtone,
randnote and shepard-risset, and create some more complex loadable waveforms
in the tones.eg/samples directory. Then try the shell scripts ramp.sh,
randtone.sh, randnote.sh, slide.sh (the shepard-risset sliding scale) and
tune.sh .
ramp.sh generate a slow ramp modulated frequency. Edit the script to
change the parameters. 'ramp' simple generates a suitable series
of incrementing (or decrementing) numbers that tones converts into
successive short tones.
randtone.sh generates random tones of varying duration.
randnote.sh generates random notes
slide.sh creates and plays a sample shepard-risset sliding scale
tt.sh plays "There's a hole in my bucket" using the loadable
waveform given as a parameter to the script.
tune.sh plays a couple of tunes! File hole_bucket.notes contains the
notes for a simple tune. clementine.notes contains the notesi
for a more complex tune with harmony (clementine). Just for fun.
dtmf script to create dtmf dial tones for single digits given
as parameters to the script. e.g. dtmf 0 1 1 3 6 6 6
shepard-risset is a C program to generate tones commands for generating
Shepard-Risset sliding tones - often called elevator sounds
because they appear to be moving up (or down) permanently.
Try this:
% shepard-risset 700 7 1.2 15 -50 > /usr/tmp/slide
% tones -c 7 -v -l :200 /usr/tmp/slide
or just run the slide.sh script. It uses precomputed sequences for
rising and falling elevator sounds.
Read the C code or run shepard-risset with no arguments
to see what the parameters are. See paper
http://www.acm.org/sigchi/chi96/proceedings/shortpap/Beaudoin-Lafon/Mbl_txt.htm
for more some more details on shepard-risset tones.
Installation of the stuff in tones.eg
You can run 'make' in the tones.eg directory and then run the example
shell scripts.
e.g. % cd tones.eg
% make
% ./tune.sh
If you wish, you can copy the scripts into a suitable directory, your
own ~/bin directory or /usr/local/bin. You will have to edit the scripts
to put in the location of the tones program - usually /usr/local/bin.
The only script worth installing really is 'dtmf' - and I'm sure that
can be improved! Feel free - let me know the results.
Jim Jackson jj@franjam.org.uk

+ 13
- 0
siggen-2.3.10/TODO View File

@ -0,0 +1,13 @@
add 0.1 and 0.01 HZ resolution to siggen and sweepgen
Should be possible - add a new configuration param RESOLUTION with
values of 1 10 or 100.
double check. all manual pages - especially siggen, sweepgen and fsynth
I've improved siggen - do similar for sweepgen and fsynth.
Add loading of custom waveforms.
oh boy yes.

+ 0
- 0
siggen-2.3.10/VERSION.2.3.10 View File


+ 59
- 0
siggen-2.3.10/adB.c View File

@ -0,0 +1,59 @@
/* adB.c
* converts gain values given as parameters into dB values
* i.e. 1 will give 0dB
* 0.5 will give -6dB amplitude / -3dB power
* 10 will give 20dB amplitude / 10dB power
*/
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define db(x) pow(10,x/20.0)
#define adb(g) (10*log10(g))
main(argc,argv)
int argc;
char **argv;
{
int i,j,k,n;
double x,y;
char *p;
argc--; argv++;
for ( ; argc; argc--, argv++) {
x=atof(*argv);
if ((p=strchr(*argv,'/'))!=NULL) {
y=atof(++p);
printf("%f/%f = %f = %f dB Ampl. or %f dB power\n",
x,y,x/y,2*adb(x/y),adb(x/y));
} else {
printf("Ratio of %f = %f dB Ampl. or %f dB power\n",
x,2*adb(x),adb(x));
}
}
}
/*
double db(x)
double x;
{
return(pow(10,x/20.0);
}
*/
/*
db(x)
int x;
{
int i;
static int dB_Conv[20]={
100000000, 112201845, 125892541, 141253754, 158489319,
177827941, 199526231, 223872114, 251188643, 281838293,