diff --git a/Modules/.gitignore b/Modules/.gitignore index 2ebf16d..9c70321 100644 --- a/Modules/.gitignore +++ b/Modules/.gitignore @@ -3,6 +3,8 @@ chkpixels twavm trnd +datas/ + *.pgm *.pnm *.png diff --git a/Modules/Makefile b/Modules/Makefile index 70af2ea..f320092 100644 --- a/Modules/Makefile +++ b/Modules/Makefile @@ -6,7 +6,7 @@ GFOPT = -Wall -Wextra -g -I. -all: chkpixels trnd +all: chkpixels trnd twavm # --------------------------------------------------------- diff --git a/Modules/twavm.f90 b/Modules/twavm.f90 index 40a47e2..1169e40 100644 --- a/Modules/twavm.f90 +++ b/Modules/twavm.f90 @@ -1,4 +1,4 @@ -program essai +program twavm ! new: Wed Feb 7 01:27:48 UTC 2024 @@ -6,9 +6,9 @@ program essai use wavmetrics implicit none - write(0, *) "----------------- essai -------------------" + write(0, *) "----------------- twavm -------------------" - call run_first_test(44100/30) + call run_second_test(44100/30) contains !----------------------------------------------------------------------- @@ -35,5 +35,33 @@ subroutine run_first_test(nbs) end subroutine !----------------------------------------------------------------------- +!----------------------------------------------------------------------- +!- +!- we read the datas from stdin +!- +subroutine run_second_test(nbs) + integer, intent(in) :: nbs ! nombre d'echantillons + type(intsample), allocatable :: samples(:) + type(wavmetric) :: metrics + integer :: foo, bar + integer :: vl, vr + + write(0, '(1X, "second test on ", I0, " samples.")') nbs + +! create the buffer, and fill it with stdin + allocate(samples(nbs)) + do foo=1, nbs + read(5, *) vl, vr + ! print '(1X, 2I16)', vl, vr + samples(foo)%left = vl + samples(foo)%right = vr + enddo + +! compute and display the metrics (gi-go) + call compute_wavmetric(samples, nbs, metrics) + call display_wavmetrics(metrics) + +end subroutine +!----------------------------------------------------------------------- end program diff --git a/Modules/wavmetrics.f90 b/Modules/wavmetrics.f90 index a81359a..5ca988e 100644 --- a/Modules/wavmetrics.f90 +++ b/Modules/wavmetrics.f90 @@ -48,7 +48,7 @@ subroutine compute_wavmetric(samples, size, metrics) if (idx .GT. 1) then if (diff_sign(samples(idx-1)%left, Lval)) Lfreq = Lfreq + 1 - if (diff_sign(samples(idx-1)%right, Lval)) Rfreq = Rfreq + 1 + if (diff_sign(samples(idx-1)%right, Rval)) Rfreq = Rfreq + 1 endif Lsum = Lsum + Lval @@ -56,7 +56,7 @@ subroutine compute_wavmetric(samples, size, metrics) enddo - metrics%num = size + metrics%nbre = size metrics%maxl = Lmax ; metrics%maxr = Rmax metrics%freql = 1.0 / (Lfreq / real(size)) metrics%freqr = 1.0 / (Rfreq / real(size)) @@ -72,7 +72,7 @@ subroutine display_wavmetrics(metrics) ! print '(1X, "metrics are :")' - print '(1X, " | num ", I0)', metrics%num + print '(1X, " | nbre ", I0)', metrics%nbre print '(1X, " | freq ", 2F12.2)', metrics%freql, metrics%freqr print '(1X, " | mean ", 2F12.2)', metrics%meanl, metrics%meanr print '(1X, " | maxi ", 2I8)', metrics%maxl, metrics%maxr