Revision: 775dc466fcab
Branch: default
Author: oyvind.ryan
Date: Wed Feb 5 09:13:37 2014 UTC
Log: read now returns sampling rate and the number of channels also
http://code.google.com/p/scitools/source/detail?r=775dc466fcab
Modified:
/lib/scitools/sound.py
=======================================
--- /lib/scitools/sound.py Wed Dec 10 10:01:37 2008 UTC
+++ /lib/scitools/sound.py Wed Feb 5 09:13:37 2014 UTC
@@ -18,7 +18,7 @@
def read(filename):
"""
Read sound data in a file and return the data as an array
- with data type numpy.int16.
+ with data type numpy.int16, together with the sampling rate and number
of channels
"""
ifile = wave.open(filename)
channels = ifile.getnchannels()
@@ -27,7 +27,7 @@
frames = ifile.getnframes()
data = ifile.readframes(frames)
data = numpy.fromstring(data, dtype=numpy.uint16)
- return data.astype(numpy.int16)
+ return data.astype(numpy.int16),sample_rate,channels
def play(soundfile, player=None):
"""