From 4591b4f5e4d0f3d128baffb77d32616b212d9c88 Mon Sep 17 00:00:00 2001 From: John Glover Date: Thu, 11 Nov 2010 11:00:08 +0000 Subject: Added wrapper around reading in wav files, choosing the right floating point type and scaling values to between -1 and 1 --- audio.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 audio.py (limited to 'audio.py') diff --git a/audio.py b/audio.py new file mode 100644 index 0000000..f35210b --- /dev/null +++ b/audio.py @@ -0,0 +1,25 @@ +# Copyright (c) 2010 John Glover, National University of Ireland, Maynooth +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +import numpy as np +from scipy.io.wavfile import read, write +import simpl + +def read_wav(file): + audio_data = read(file) + # return floating point values between -1 and 1 + return simpl.asarray(audio_data[1]) / 32768.0, audio_data[0] + -- cgit v1.2.3