Skip to content

Instantly share code, notes, and snippets.

@hyperaeolian
Created January 17, 2014 23:49
Show Gist options
  • Save hyperaeolian/8483863 to your computer and use it in GitHub Desktop.
Save hyperaeolian/8483863 to your computer and use it in GitHub Desktop.
# -*- 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