annotate Demo/scripts/morse.py @ 79675:c0a2294de787 2.7

Issue #16199: Backport 2to3 typo fix from 3.2.
author Chris Jerdonek <chris.jerdonek@gmail.com>
date Thu, 11 Oct 2012 16:15:46 -0700
parents 3130b7e812b0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
56467
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
1 #! /usr/bin/env python
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
2
1928
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 # DAH should be three DOTs.
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 # Space between DOTs and DAHs should be one DOT.
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 # Space between two letters should be one DAH.
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 # Space between two words should be DOT DAH DAH.
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
7
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 import sys, math, audiodev
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
9
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 DOT = 30
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 DAH = 3 * DOT
32735
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
12 OCTAVE = 2 # 1 == 441 Hz, 2 == 882 Hz, ...
1928
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
13
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 morsetab = {
32735
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
15 'A': '.-', 'a': '.-',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
16 'B': '-...', 'b': '-...',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
17 'C': '-.-.', 'c': '-.-.',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
18 'D': '-..', 'd': '-..',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
19 'E': '.', 'e': '.',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
20 'F': '..-.', 'f': '..-.',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
21 'G': '--.', 'g': '--.',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
22 'H': '....', 'h': '....',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
23 'I': '..', 'i': '..',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
24 'J': '.---', 'j': '.---',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
25 'K': '-.-', 'k': '-.-',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
26 'L': '.-..', 'l': '.-..',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
27 'M': '--', 'm': '--',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
28 'N': '-.', 'n': '-.',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
29 'O': '---', 'o': '---',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
30 'P': '.--.', 'p': '.--.',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
31 'Q': '--.-', 'q': '--.-',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
32 'R': '.-.', 'r': '.-.',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
33 'S': '...', 's': '...',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
34 'T': '-', 't': '-',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
35 'U': '..-', 'u': '..-',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
36 'V': '...-', 'v': '...-',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
37 'W': '.--', 'w': '.--',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
38 'X': '-..-', 'x': '-..-',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
39 'Y': '-.--', 'y': '-.--',
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
40 'Z': '--..', 'z': '--..',
56467
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
41 '0': '-----', ',': '--..--',
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
42 '1': '.----', '.': '.-.-.-',
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
43 '2': '..---', '?': '..--..',
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
44 '3': '...--', ';': '-.-.-.',
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
45 '4': '....-', ':': '---...',
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
46 '5': '.....', "'": '.----.',
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
47 '6': '-....', '-': '-....-',
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
48 '7': '--...', '/': '-..-.',
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
49 '8': '---..', '(': '-.--.-',
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
50 '9': '----.', ')': '-.--.-',
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
51 ' ': ' ', '_': '..--.-',
1928
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 }
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
53
56467
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
54 nowave = '\0' * 200
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
55
1928
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
56 # If we play at 44.1 kHz (which we do), then if we produce one sine
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 # wave in 100 samples, we get a tone of 441 Hz. If we produce two
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
58 # sine waves in these 100 samples, we get a tone of 882 Hz. 882 Hz
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
59 # appears to be a nice one for playing morse code.
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 def mkwave(octave):
32735
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
61 sinewave = ''
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
62 for i in range(100):
56467
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
63 val = int(math.sin(math.pi * i * octave / 50.0) * 30000)
56469
3130b7e812b0 Update markov demo.
Georg Brandl <georg@python.org>
parents: 56467
diff changeset
64 sinewave += chr((val >> 8) & 255) + chr(val & 255)
56467
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
65 return sinewave
1928
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
66
56467
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
67 defaultwave = mkwave(OCTAVE)
1928
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
68
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 def main():
56467
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
70 import getopt
32735
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
71 try:
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
72 opts, args = getopt.getopt(sys.argv[1:], 'o:p:')
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
73 except getopt.error:
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
74 sys.stderr.write('Usage ' + sys.argv[0] +
56467
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
75 ' [ -o outfile ] [ -p octave ] [ words ] ...\n')
32735
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
76 sys.exit(1)
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
77 dev = None
56467
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
78 wave = defaultwave
32735
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
79 for o, a in opts:
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
80 if o == '-o':
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
81 import aifc
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
82 dev = aifc.open(a, 'w')
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
83 dev.setframerate(44100)
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
84 dev.setsampwidth(2)
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
85 dev.setnchannels(1)
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
86 if o == '-p':
56467
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
87 wave = mkwave(int(a))
32735
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
88 if not dev:
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
89 import audiodev
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
90 dev = audiodev.AudioDev()
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
91 dev.setoutrate(44100)
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
92 dev.setsampwidth(2)
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
93 dev.setnchannels(1)
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
94 dev.close = dev.stop
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
95 dev.writeframesraw = dev.writeframes
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
96 if args:
56467
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
97 source = [' '.join(args)]
32735
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
98 else:
56467
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
99 source = iter(sys.stdin.readline, '')
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
100 for line in source:
32735
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
101 mline = morse(line)
56467
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
102 play(mline, dev, wave)
32735
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
103 if hasattr(dev, 'wait'):
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
104 dev.wait()
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
105 dev.close()
1928
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
106
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
107 # Convert a string to morse code with \001 between the characters in
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
108 # the string.
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
109 def morse(line):
32735
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
110 res = ''
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
111 for c in line:
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
112 try:
56467
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
113 res += morsetab[c] + '\001'
32735
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
114 except KeyError:
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
115 pass
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
116 return res
1928
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
117
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
118 # Play a line of morse code.
56467
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
119 def play(line, dev, wave):
32735
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
120 for c in line:
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
121 if c == '.':
56467
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
122 sine(dev, DOT, wave)
32735
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
123 elif c == '-':
56467
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
124 sine(dev, DAH, wave)
32735
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
125 else: # space
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
126 pause(dev, DAH + DOT)
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
127 pause(dev, DOT)
1928
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
128
56467
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
129 def sine(dev, length, wave):
32735
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
130 for i in range(length):
56467
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
131 dev.writeframesraw(wave)
1928
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
132
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
133 def pause(dev, length):
32735
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
134 for i in range(length):
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
135 dev.writeframesraw(nowave)
1928
a8b7ee0e572d Get rid of freeze (now its own directory).
Guido van Rossum <guido@python.org>
parents:
diff changeset
136
56467
6194fd754323 Update morse script, avoid globals, use iterators.
Georg Brandl <georg@python.org>
parents: 32735
diff changeset
137 if __name__ == '__main__':
32735
2bc66f1df7cc Whitespace normalization. Ran reindent.py over the entire source tree.
Tim Peters <tim.peters@gmail.com>
parents: 1928
diff changeset
138 main()