Created
January 17, 2014 23:49
-
-
Save hyperaeolian/8483863 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# <nbformat>3.0</nbformat> | |
# <markdowncell> | |
# Robert Miller | |
# MAT240E - Homework 1 | |
# <codecell> | |
from scipy.io import wavfile | |
import glob | |
from os import * | |
# <codecell> | |
myWavs = glob.glob('/Users/milrober/Desktop/MIR/240E/*.wav') | |
# <codecell> | |
sndlib = [] | |
smpRates = [] | |
for i, title in enumerate(myWavs): | |
sr, temp = wavfile.read(myWavs[i]) | |
sndlib.append(temp) | |
smpRates.append(sr) | |
# <codecell> | |
def getDur(sndFile, sr): | |
frameRate = sr / sndFile.shape[1] | |
totalFrames = sndFile.shape[0] / sndFile.shape[1] | |
return float(totalFrames / frameRate) / 60 | |
# <codecell> | |
durations = [] | |
for i in range(len(sndlib)): | |
durations.append(getDur(sndlib[i], smpRates[i])) | |
# <codecell> | |
hist(durations) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment