package goborator

import (
	"encoding/binary"
	"fmt"
	"os"
	"testing"
	"time"
)

func TestGoborator(t *testing.T) {
	ob := NewGaborator(8192, 16000, 85, 110, 7040, 440, 128)
	defer ob.ProcessingFinished()

	file, err := os.Open("sample/test.raw")
	if err != nil {
		t.Error(err)
		return
	}

	channel := make(chan float32)

	go func() {
		defer close(channel)
		defer file.Close()

		var f float32
		for {
			err = binary.Read(file, binary.LittleEndian, &f)
			if err != nil {
				return
			}
			channel <- f
		}
	}()

	var i = 0
	start := time.Now()
	//for c := range ob.GaborTransform(channel) {
	for _ = range ob.GaborTransform(channel) {
		//fmt.Printf("%d: %+F\n", i, c)
		i++
	}

	fmt.Printf("%d, %dms", i, time.Now().Sub(start).Milliseconds())

}
