Mercurial > cpython-lru_cache-weakref
annotate Lib/whatsound.py @ 5817:48b94de85bf3 legacy-trunk
Extensive changes by AMK.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 17 Jul 1997 16:29:42 +0000 |
| parents | 2f3f293ef5f1 |
| children | 37ff71cd941e |
| rev | line source |
|---|---|
|
1297
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 # This module contains several routines that help recognizing sound |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
2 # files. |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 # |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 # Function whathdr() recognizes various types of sound file headers. |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 # It understands almost all headers that SOX can decode. |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 # |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 # The return tuple contains the following items, in this order: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 # - file type (as SOX understands it) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 # - sampling rate (0 if unknown or hard to decode) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 # - number of channels (0 if unknown or hard to decode) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 # - number of frames in the file (-1 if unknown or hard to decode) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 # - number of bits/sample, or 'U' for U-LAW, or 'A' for A-LAW |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 # |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 # If the file doesn't have a recognizable type, it returns None. |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 # If the file can't be opened, IOError is raised. |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 # |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 # To compute the total time, divide the number of frames by the |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 # sampling rate (a frame contains a sample for each channel). |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 # |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 # Function whatraw() calls the "whatsound" program and interprets its |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 # output. You'll have to guess the sampling rate by listening though! |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 # |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 # Function what() calls whathdr() and if it doesn't recognize the file |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
24 # then calls whatraw(). |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
25 # |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
26 # Finally, the function test() is a simple main program that calls |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
27 # what() for all files mentioned on the argument list. For directory |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 # arguments it calls what() for all files in that directory. Default |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 # argument is "." (testing all files in the current directory). The |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 # option -r tells it to recurse down directories found inside |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 # explicitly given directories. |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
32 # |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 # The file structure is top-down except that the test program and its |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 # subroutine come last. |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
36 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
37 #------------------------------------------------------# |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 # Guess the type of any sound file, raw or with header # |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
39 #------------------------------------------------------# |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
40 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 def what(filename): |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
42 res = whathdr(filename) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
43 if not res: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
44 res = whatraw(filename) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
45 return res |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
46 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
47 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
48 #-----------------------------# |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
49 # Guess the type of raw sound # |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
50 #-----------------------------# |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
51 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
52 def whatraw(filename): |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 # Assume it's always 1 channel, byte-sized samples |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
54 # Don't assume anything about the rate |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
55 import os |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
56 from stat import ST_SIZE |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
57 # XXX "whatsound" should be part of the distribution somehow... |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 cmd = 'whatsound ' + filename + ' 2>/dev/null' |
|
1316
2f3f293ef5f1
* calendar.py: all libC functionality now moved to built-in time module
Guido van Rossum <guido@python.org>
parents:
1297
diff
changeset
|
59 cmd = 'PATH=$PATH:/ufs/guido/bin/sgi\n' + cmd |
|
1297
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
60 pipe = os.popen(cmd, 'r') |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
61 data = pipe.read() |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
62 sts = pipe.close() |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
63 if sts: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
64 return None |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
65 if data[:13] == '-t raw -b -s ': |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
66 type = 'sb' |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
67 sample_size = 8 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
68 elif data[:13] == '-t raw -b -u ': |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
69 type = 'ub' |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
70 sample_size = 8 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
71 elif data[:13] == '-t raw -b -U ': |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
72 type = 'ul' |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
73 sample_size = 'U' |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
74 else: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
75 return None |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
76 try: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
77 frame_count = os.stat(filename)[ST_SIZE] |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
78 except IOError: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
79 frame_count = -1 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
80 return type, 0, 1, frame_count, sample_size |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
81 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
82 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
83 #-------------------------# |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
84 # Recognize sound headers # |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
85 #-------------------------# |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
86 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
87 def whathdr(filename): |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
88 f = open(filename, 'r') |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
89 h = f.read(512) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
90 for tf in tests: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
91 res = tf(h, f) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
92 if res: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
93 return res |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
94 return None |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
95 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
96 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
97 #-----------------------------------# |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
98 # Subroutines per sound header type # |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
99 #-----------------------------------# |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
100 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
101 tests = [] |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
102 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
103 def test_aifc(h, f): |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
104 import aifc |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
105 if h[:4] <> 'FORM': |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
106 return None |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
107 if h[8:12] == 'AIFC': |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
108 fmt = 'aifc' |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
109 elif h[8:12] == 'AIFF': |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
110 fmt = 'aiff' |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
111 else: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
112 return None |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
113 f.seek(0) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
114 try: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
115 a = aifc.openfp(f, 'r') |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
116 except (EOFError, aifc.Error): |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
117 return None |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
118 return (fmt, a.getframerate(), a.getnchannels(), \ |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
119 a.getnframes(), 8*a.getsampwidth()) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
120 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
121 tests.append(test_aifc) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
122 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
123 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
124 def test_au(h, f): |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
125 if h[:4] == '.snd': |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
126 f = get_long_be |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
127 elif h[:4] in ('\0ds.', 'dns.'): |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
128 f = get_long_le |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
129 else: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
130 return None |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
131 type = 'au' |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
132 hdr_size = f(h[4:8]) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
133 data_size = f(h[8:12]) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
134 encoding = f(h[12:16]) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
135 rate = f(h[16:20]) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
136 nchannels = f(h[20:24]) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
137 sample_size = 1 # default |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
138 if encoding == 1: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
139 sample_bits = 'U' |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
140 elif encoding == 2: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
141 sample_bits = 8 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
142 elif encoding == 3: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
143 sample_bits = 16 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
144 sample_size = 2 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
145 else: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
146 sample_bits = '?' |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
147 frame_size = sample_size * nchannels |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
148 return type, rate, nchannels, data_size/frame_size, sample_bits |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
149 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
150 tests.append(test_au) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
151 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
152 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
153 def test_hcom(h, f): |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
154 if h[65:69] <> 'FSSD' or h[128:132] <> 'HCOM': |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
155 return None |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
156 divisor = get_long_be(h[128+16:128+20]) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
157 return 'hcom', 22050/divisor, 1, -1, 8 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
158 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
159 tests.append(test_hcom) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
160 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
161 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
162 def test_voc(h, f): |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
163 if h[:20] <> 'Creative Voice File\032': |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
164 return None |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
165 sbseek = get_short_le(h[20:22]) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
166 rate = 0 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
167 if 0 <= sbseek < 500 and h[sbseek] == '\1': |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
168 ratecode = ord(h[sbseek+4]) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
169 rate = int(1000000.0 / (256 - ratecode)) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
170 return 'voc', rate, 1, -1, 8 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
171 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
172 tests.append(test_voc) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
173 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
174 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
175 def test_wav(h, f): |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
176 # 'RIFF' <len> 'WAVE' 'fmt ' <len> |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
177 if h[:4] <> 'RIFF' or h[8:12] <> 'WAVE' or h[12:16] <> 'fmt ': |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
178 return None |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
179 style = get_short_le(h[20:22]) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
180 nchannels = get_short_le(h[22:24]) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
181 rate = get_long_le(h[24:28]) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
182 sample_bits = get_short_le(h[34:36]) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
183 return 'wav', rate, nchannels, -1, sample_bits |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
184 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
185 tests.append(test_wav) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
186 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
187 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
188 def test_8svx(h, f): |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
189 if h[:4] <> 'FORM' or h[8:12] <> '8SVX': |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
190 return None |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
191 # Should decode it to get #channels -- assume always 1 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
192 return '8svx', 0, 1, 0, 8 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
193 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
194 tests.append(test_8svx) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
195 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
196 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
197 def test_sndt(h, f): |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
198 if h[:5] == 'SOUND': |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
199 nsamples = get_long_le(h[8:12]) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
200 rate = get_short_le(h[20:22]) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
201 return 'sndt', rate, 1, nsamples, 8 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
202 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
203 tests.append(test_sndt) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
204 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
205 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
206 def test_sndr(h, f): |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
207 if h[:2] == '\0\0': |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
208 rate = get_short_le(h[2:4]) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
209 if 4000 <= rate <= 25000: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
210 return 'sndr', rate, 1, -1, 8 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
211 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
212 tests.append(test_sndr) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
213 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
214 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
215 #---------------------------------------------# |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
216 # Subroutines to extract numbers from strings # |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
217 #---------------------------------------------# |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
218 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
219 def get_long_be(s): |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
220 return (ord(s[0])<<24) | (ord(s[1])<<16) | (ord(s[2])<<8) | ord(s[3]) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
221 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
222 def get_long_le(s): |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
223 return (ord(s[3])<<24) | (ord(s[2])<<16) | (ord(s[1])<<8) | ord(s[0]) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
224 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
225 def get_short_be(s): |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
226 return (ord(s[0])<<8) | ord(s[1]) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
227 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
228 def get_short_le(s): |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
229 return (ord(s[1])<<8) | ord(s[0]) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
230 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
231 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
232 #--------------------# |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
233 # Small test program # |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
234 #--------------------# |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
235 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
236 def test(): |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
237 import sys |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
238 recursive = 0 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
239 if sys.argv[1:] and sys.argv[1] == '-r': |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
240 del sys.argv[1:2] |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
241 recursive = 1 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
242 try: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
243 if sys.argv[1:]: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
244 testall(sys.argv[1:], recursive, 1) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
245 else: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
246 testall(['.'], recursive, 1) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
247 except KeyboardInterrupt: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
248 sys.stderr.write('\n[Interrupted]\n') |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
249 sys.exit(1) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
250 |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
251 def testall(list, recursive, toplevel): |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
252 import sys |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
253 import os |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
254 for filename in list: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
255 if os.path.isdir(filename): |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
256 print filename + '/:', |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
257 if recursive or toplevel: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
258 print 'recursing down:' |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
259 import glob |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
260 names = glob.glob(os.path.join(filename, '*')) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
261 testall(names, recursive, 0) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
262 else: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
263 print '*** directory (use -r) ***' |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
264 else: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
265 print filename + ':', |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
266 sys.stdout.flush() |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
267 try: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
268 print what(filename) |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
269 except IOError: |
|
9234c961ec43
* toaiff.py: import whatsound instead of sndhdr
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
270 print '*** not found ***' |
