view sequences/windowparams.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents 672052bd81f8
children
line wrap: on
line source
function [span,jump]=windowparams(sz,frame,hop,width,opts)
% windowparams - compute windowing parameters to get buffers of a certain size
%
% windowparams :: 
%    [[1,2]]     ~ 'size of signal [channels,length]',
%    natural	 ~ 'desired frame length',
%    natural    ~ 'desired hop per frame',
%    natural|[] ~ 'desired number of frames per buffer or [] for all',
%    options {
%       natural : jump/[] ~'override window jump'
%    }
% -> natural    ~ 'recommended window span',
%    natural    ~ 'recommended window jump'.

	channels = sz(1);
	length   = sz(2);

	if isempty(width) 
		width=channels*(floor((length-frame)/hop)+1); 
	end

	span = (hop*(width-1)+frame)/channels;	
	jump = (hop*width)/channels;

	if nargin>4 && isfield(opts,'jump'), jump = channels*hop*opts.jump; end