From 0f92d09d5ef8dda141e8ed2e1043da770abf46cd Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 5 May 2022 06:58:45 +0200 Subject: [PATCH] bad or not bad ? --- SoundBrotching/.gitignore | 1 + SoundBrotching/Makefile | 2 +- SoundBrotching/demos.sh | 19 ++++++++++++++- SoundBrotching/genwaves.f90 | 11 +++++++++ SoundBrotching/panoramix.f90 | 5 ++-- SoundBrotching/soundbrotch.f90 | 44 ++++++++++++++++++++++++++++------ 6 files changed, 71 insertions(+), 11 deletions(-) diff --git a/SoundBrotching/.gitignore b/SoundBrotching/.gitignore index a0f8649..4cc5eb5 100644 --- a/SoundBrotching/.gitignore +++ b/SoundBrotching/.gitignore @@ -4,6 +4,7 @@ *.wav *.text +*.png text2wav wav2text diff --git a/SoundBrotching/Makefile b/SoundBrotching/Makefile index 20eb8aa..ec1e544 100644 --- a/SoundBrotching/Makefile +++ b/SoundBrotching/Makefile @@ -2,7 +2,7 @@ # tth@konrad:~/Devel/Fortraneries/SoundBrotching$ # -GOPT = -Wall -Wextra -g +GOPT = -Wall -Wextra -time -g all: panoramix genwaves diff --git a/SoundBrotching/demos.sh b/SoundBrotching/demos.sh index 9bd11a5..c611180 100755 --- a/SoundBrotching/demos.sh +++ b/SoundBrotching/demos.sh @@ -2,7 +2,24 @@ INWAV="1637.wav" OUTWAV="foo.wav" +DATAFILE="waves.text" -./wav2text $INWAV | ./panoramix | ./text2wav $OUTWAV +# XXX ./wav2text $INWAV | ./panoramix | ./text2wav $OUTWAV +OUTWAV="quux.wav" +./genwaves | ./panoramix | tee $DATAFILE | c-tools/text2wav $OUTWAV + +sndfile-spectrogram \ + --min-freq=30 --max-freq=4000 \ + --hann \ + $OUTWAV \ + 1200 600 \ + spectrogram.png + +sndfile-waveform \ + -c -2 \ + -g 1200x600 \ + $OUTWAV waveform.png + +# echo " HEAD OF DATAS" ; head $DATAFILE diff --git a/SoundBrotching/genwaves.f90 b/SoundBrotching/genwaves.f90 index 92b1565..40be546 100644 --- a/SoundBrotching/genwaves.f90 +++ b/SoundBrotching/genwaves.f90 @@ -4,8 +4,19 @@ program genwaves ! ----------------------------- implicit none + integer :: clock + ! type(t_sample2i) :: sample + real :: fleft, fright ! frequencies + + write(0, *) "*** Genwaves ***" call soundbrotch_version() + do clock = 1, 8 + fleft = real(100 * clock) + fright = real(150 * clock) + write(0, '(1X,I8, 9X, F8.2, 6X, F8.2)') clock, fleft, fright + call sinw_burst2i(6, 4800, fleft, fright, 0.7) + enddo end program diff --git a/SoundBrotching/panoramix.f90 b/SoundBrotching/panoramix.f90 index 957dc6d..baab225 100644 --- a/SoundBrotching/panoramix.f90 +++ b/SoundBrotching/panoramix.f90 @@ -9,18 +9,19 @@ program panoramix integer :: nblus real :: value, phi, ka + write(0, *) "*** Panoramix ***" call soundbrotch_version() nblus = 0 do read (*, *, iostat=errcode) left, right if (errcode .NE. 0) then - write(0, *) 'EOF ? ', errcode + ! write(0, *) 'EOF ? ', errcode exit endif ! *** NON WORKING CODE *** - phi = real(nblus) / 20000.0 + phi = real(nblus) / 60000.0 ka = sin(phi) value = (real(left)+real(right)) / 2.05 left = int(value*ka) diff --git a/SoundBrotching/soundbrotch.f90 b/SoundBrotching/soundbrotch.f90 index b44392e..48bf994 100644 --- a/SoundBrotching/soundbrotch.f90 +++ b/SoundBrotching/soundbrotch.f90 @@ -2,24 +2,54 @@ module soundbrotch implicit none ! --------------------------------------------------------- - type t_sample + type t_sample2i integer :: left integer :: right end type - ! --------------------------------------------------------- - contains - ! --------------------------------------------------------- subroutine soundbrotch_version () - - write(0, '(A)') "*** this is soundbrotch version alpha 666" - + write(0, '(1X,A)') "--- this is soundbrotch version alpha 666" end subroutine ! --------------------------------------------------------- + ! premier essai, le prototype peut changer ! + + subroutine sinw_burst2i (dst, numbs, fra, frb, level) + integer, intent(in) :: dst ! output unit number + integer, intent(in) :: numbs ! number of sample to be made + real, intent(in) :: fra, frb ! left and right frequency + real, intent(in) :: level ! amplitude in [0..1] + + integer :: idx, left, right + real :: coef + integer, save :: oldl=0, oldr=0 + + coef = (3.141592654 * 2.0) / 44.1e3 + do idx=0, numbs + left = INT(32e3 * level * sin(coef*real(idx)*fra)) + left = (left + oldl) / 2 + right = INT(32e3 * level * sin(coef*real(idx)*frb)) + right = (right + oldr) / 2 + print *, left, right + oldl = left + oldr = right + enddo + ! add silence at the end of the burst + left = 0 + right = 0 + do idx=0, numbs/3 + left = (left + oldl) / 2 + right = (right + oldr) / 2 + print *, 0, 0 + oldl = left + oldr = right + enddo + + end subroutine + ! --------------------------------------------------------- end module