#! /usr/bin/env python

from Tkinter import *
from tkSnack import *
root = Tkinter.Tk()

initializeSnack(root);


import sys;

path=sys.argv[1];
height=int(sys.argv[2])*2;
persample=float(sys.argv[3]);
startValue=int(sys.argv[4]);
endValue=int(sys.argv[5]);

#print(path);
mysound=Sound(load=path);

#mysound.convert(encoding='Lin16',channels='1');

#resultList=mysound.dBPowerSpectrum(fftlength='64',windowlength='64',start=startValue,end=endValue);
#resultList=mysound.dBPowerSpectrum(fftlength='64',windowlength='64',start=startValue);

v=startValue;
filelength=mysound.length();

if endValue==0:
	endValue=filelength;

prevValue=0;
while v < filelength :
	#print "ok";
	at=int(v);
	resultList=mysound.dBPowerSpectrum(fftlength=height,windowlength=height,start=at);
	for i in resultList:
		intV=int(i);
		print prevValue-intV;
		prevValue=intV;
	v=v+persample;
	#print v;
	if v+height>=endValue:
		break;