Module: Chawk::Quantizer

Defined in:
lib/quantizer.rb

Overview

This is not implimented yet.

Instance Method Summary collapse

Instance Method Details

#ending_step(x, step_width) ⇒ Object

This is not implimented yet.



14
15
16
17
18
19
20
# File 'lib/quantizer.rb', line 14

def ending_step(x,step_width)
	if (x % step_width) == 0
		step = x
	else
		step = x - (x % step_width)
	end
end

#quantize(ary, step_width, steps = nil) ⇒ Object

This is not implimented yet.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/quantizer.rb', line 23

def quantize(ary,step_width,steps=nil)
	# TODO: Needs lots more testing, then faster implementation
	# with caching (probaby at data add point)
	#puts "#{ary.length}"
	step = starting_step(ary[0][1],step_width)
	end_step = ending_step(ary[-1][1], step_width)
	out = [ary[0]]
	while (step > end_step) do
		step -= step_width
		next_step = step - step_width
		data = ary[0]
		data = ary.reverse.detect{|a|a[1] > next_step} || data#(ary[-1])
		out << [data[0],step]
	end
	out
end

#starting_step(x, step_width) ⇒ Object

This is not implimented yet.



5
6
7
8
9
10
11
# File 'lib/quantizer.rb', line 5

def starting_step(x,step_width)
	if (x % step_width) == 0
		step = x
	else
		step = x - (x % step_width) + step_width
	end
end