S
Shane Geiger
"""
I just used the following Google search to look for some random .aiff
files which I could use to test the code I once found for the audiodev
module. Unfortunately, the writeframes() call gives me the traceback
below. Does anyone know what the problem is? (I would, quite frankly
rather know how to play mp3 or ogg files, but I was wondering whether
there's a problem here that needs to be fixed.)
http://www.google.com/search?q=inti...s=org.mozilla:en-US:official&client=firefox-a
player.writeframes(data) # this line is causing this problem with
every .aiff file I try:
Traceback (most recent call last):
File "/tmp/foo.py", line 39, in <module>
player.writeframes(data) # this line is causing this problem with
every .aiff file I try:
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac/Audio_mac.py",
line 67, in writeframes
nframes)
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/struct.py",
line 63, in pack
return o.pack(*args)
struct.error: byte format requires -128 <= number <= 127
---------
THE AUDIODEV MODULE
[contents]
(Unix only) This module provides sound playing support for Sun and SGI
computers.
Example: Using the audiodev module
# File: audiodev-example-1.py
"""
import audiodev
import aifc
# THIS IS THE ERROR I GET: struct.error: byte format requires -128 <=
number <= 127
#sound = aifc.open("/Users/shanegeiger/bring.aiff", "r")
#sound = aifc.open("/Users/shanegeiger/gates01.aif", "r")
sound = aifc.open("/Users/shanegeiger/c2.aiff", "r")
player = audiodev.AudioDev()
player.setoutrate(sound.getframerate())
player.setsampwidth(sound.getsampwidth())
player.setnchannels(sound.getnchannels())
bytes_per_frame = sound.getsampwidth() * sound.getnchannels()
bytes_per_second = sound.getframerate() * bytes_per_frame
#print "bytes_per_frame:",bytes_per_frame
#print "bytes_per_second:",bytes_per_second
i = 0
while 1:
print str(i) + " COMPLETED" # debug
data = sound.readframes(bytes_per_second)
if not data:
break
#print data # debug
player.writeframes(data) # this line is causing this problem with
every .aiff file I try:
i += 1
#import sys; sys.exit()
player.wait()
--
Shane Geiger
IT Director
National Council on Economic Education
(e-mail address removed) | 402-438-8958 | http://www.ncee.net
Leading the Campaign for Economic and Financial Literacy
I just used the following Google search to look for some random .aiff
files which I could use to test the code I once found for the audiodev
module. Unfortunately, the writeframes() call gives me the traceback
below. Does anyone know what the problem is? (I would, quite frankly
rather know how to play mp3 or ogg files, but I was wondering whether
there's a problem here that needs to be fixed.)
http://www.google.com/search?q=inti...s=org.mozilla:en-US:official&client=firefox-a
player.writeframes(data) # this line is causing this problem with
every .aiff file I try:
Traceback (most recent call last):
File "/tmp/foo.py", line 39, in <module>
player.writeframes(data) # this line is causing this problem with
every .aiff file I try:
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac/Audio_mac.py",
line 67, in writeframes
nframes)
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/struct.py",
line 63, in pack
return o.pack(*args)
struct.error: byte format requires -128 <= number <= 127
---------
THE AUDIODEV MODULE
[contents]
(Unix only) This module provides sound playing support for Sun and SGI
computers.
Example: Using the audiodev module
# File: audiodev-example-1.py
"""
import audiodev
import aifc
# THIS IS THE ERROR I GET: struct.error: byte format requires -128 <=
number <= 127
#sound = aifc.open("/Users/shanegeiger/bring.aiff", "r")
#sound = aifc.open("/Users/shanegeiger/gates01.aif", "r")
sound = aifc.open("/Users/shanegeiger/c2.aiff", "r")
player = audiodev.AudioDev()
player.setoutrate(sound.getframerate())
player.setsampwidth(sound.getsampwidth())
player.setnchannels(sound.getnchannels())
bytes_per_frame = sound.getsampwidth() * sound.getnchannels()
bytes_per_second = sound.getframerate() * bytes_per_frame
#print "bytes_per_frame:",bytes_per_frame
#print "bytes_per_second:",bytes_per_second
i = 0
while 1:
print str(i) + " COMPLETED" # debug
data = sound.readframes(bytes_per_second)
if not data:
break
#print data # debug
player.writeframes(data) # this line is causing this problem with
every .aiff file I try:
i += 1
#import sys; sys.exit()
player.wait()
--
Shane Geiger
IT Director
National Council on Economic Education
(e-mail address removed) | 402-438-8958 | http://www.ncee.net
Leading the Campaign for Economic and Financial Literacy