Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Restore frame properties after zero padding

  • Loading branch information...
commit bb4fa09f15bf593033754f2f8d01658cdb862fff 1 parent 954c78a
@jsawruk authored
Showing with 36 additions and 0 deletions.
  1. +27 −0 examples/test.py
  2. +9 −0 pymir/Frame.py
View
27 examples/test.py
@@ -0,0 +1,27 @@
+"""
+Tests of different onset detection methods
+Currently under development
+Last updated: 9 December 2012
+"""
+import sys
+sys.path.append('..')
+
+from pymir import AudioFile
+from pymir import Energy
+from pymir import Onsets
+
+import matplotlib.pyplot as plt
+
+import numpy
+
+filename = "../audio_files/drum_loop_01.wav"
+
+print "Opening File: " + filename
+audiofile = AudioFile.open(filename)
+
+#plt.plot(audiofile)
+#plt.show()
+
+frames = audiofile.frames(2048, numpy.hamming)
+
+print len(frames)
View
9 pymir/Frame.py
@@ -122,6 +122,10 @@ def frames(self, frameSize, windowFunction = None):
# Zero pad
frameType = frame.__class__.__name__
+ sampleRate = frame.sampleRate
+ channels = frame.channels
+ format = frame.format
+
diff = len(window) - len(frame)
frame = numpy.append(frame, [0] * diff)
@@ -129,6 +133,11 @@ def frames(self, frameSize, windowFunction = None):
frame = frame.view(pymir.AudioFile)
else:
frame = frame.view(Frame)
+
+ # Restore frame properties
+ frame.sampleRate = sampleRate
+ frame.channels = channels
+ frame.format = format
windowedFrame = frame * window
frames.append(windowedFrame)
Please sign in to comment.
Something went wrong with that request. Please try again.