add a new effect

This commit is contained in:
tTh 2024-01-05 16:50:25 +01:00
parent 0fb6b03698
commit 7ee4fefaa4
4 changed files with 114 additions and 51 deletions

View File

@ -23,14 +23,19 @@ doublegauss: doublegauss.f90 Makefile utils_ga.o
trigofest: trigofest.f90 Makefile vue3axes.o utils_ga.o trigofest: trigofest.f90 Makefile vue3axes.o utils_ga.o
gfortran $(GFOPT) $< $(MYLIB) utils_ga.o -o $@ gfortran $(GFOPT) $< $(MYLIB) utils_ga.o -o $@
soundscope: soundscope.f90 Makefile utils_ga.o
gfortran $(GFOPT) $< $(MYLIB) utils_ga.o -o $@
noisepic: noisepic.f90 Makefile noisepic: noisepic.f90 Makefile
gfortran $(GFOPT) $< $(MYLIB) \ gfortran $(GFOPT) $< $(MYLIB) \
-o $@ -o $@
# ---- modules locaux # ---- bienvenue dans le monde applicatif
wavmetrics.o: wavmetrics.f90 Makefile
gfortran $(GFOPT) -c $<
soundscope: soundscope.f90 Makefile utils_ga.o
gfortran $(GFOPT) $< $(MYLIB) utils_ga.o -o $@
# ---- modules locaux ----
usegenplot.o: usegenplot.f90 Makefile usegenplot.o: usegenplot.f90 Makefile
gfortran $(GFOPT) -c $< gfortran $(GFOPT) -c $<

View File

@ -2,8 +2,8 @@
Quelques essais approximatifs pour faire des graphiques inutiles, Quelques essais approximatifs pour faire des graphiques inutiles,
dans une démarche mettant en avant la dans une démarche mettant en avant la
[techno-futilité](https://wiki.interhacker.space/index.php?title=Techno-futilit%C3%A9), une notion [techno-futilité](https://wiki.interhacker.space/index.php?title=Techno-futilit%C3%A9),
bien définie par le collectif Interhack. une notion bien définie par le collectif Interhack.
Actuellement, certains des logiciels que vous voyez ici utilisent un backend Actuellement, certains des logiciels que vous voyez ici utilisent un backend
graphique brassé à la maison et nommé `genplot2`. Hélas, celui-ci est graphique brassé à la maison et nommé `genplot2`. Hélas, celui-ci est
@ -27,5 +27,10 @@ Un module assez spécialisé.
## soundscope ## soundscope
Retranscription en image de type oscilloscope d'un fichier son. Retranscription en image de type oscilloscope d'un fichier son.
Le code source ([soundscope.f90](soundscope.f90)) est encore
bien gore.
Pour convertir le son en données exploitables, il faut utiliser ce [bout de code](../SoundBrotching/c-tools/text2wav.c). Certaines fonctions utilisée par ce logiciel sont dans [utils_ga.f90](utils_ga.f90)
pour la partie dessin.

View File

@ -11,7 +11,7 @@ program soundscope
integer :: width = 720 integer :: width = 720
integer :: height = 576 integer :: height = 576
integer :: marge = 20 integer :: marge = 32
integer :: samplerate = 44100 integer :: samplerate = 44100
integer :: framerate = 30 integer :: framerate = 30
@ -25,14 +25,14 @@ program soundscope
smppf = samplerate / framerate smppf = samplerate / framerate
allocate(pix(width, height)) allocate(pix(width, height))
call preparation(pix, 65000) call fill_random_gauss(pix, 65000, marge)
iter = 0 iter = 0
do do
write(0, *) "----- iteration", iter, " -----" write(0, *) "----- iteration", iter, " -----"
iter = iter + 1 iter = iter + 1
do foo=0, 500 do foo=0, 100
tx = (marge/2) + fair_random_gauss(width-marge) tx = (marge/2) + fair_random_gauss(width-marge)
ty = (marge/2) + fair_random_gauss(height-marge) ty = (marge/2) + fair_random_gauss(height-marge)
if (is_pixel_inside(tx, ty)) then if (is_pixel_inside(tx, ty)) then
@ -45,9 +45,14 @@ program soundscope
endif endif
enddo enddo
call dim_pix_rgb_sub(pix, 2200) call dim_pix_rgb_mul(pix, 0.86)
call make_a_frame(pix, smppf, flagdone) if (mod(iter, 180) .LT. 90) then
call dessine_cadre(pix, 65000, 65000, 65000) call make_a_frame_dplot(pix, smppf, flagdone)
else
call make_a_frame_xy(pix, smppf, flagdone)
endif
call dessine_cadre(pix, 65000, 65000, 65000, marge)
write (filename, "(a,i5.5,a)") "./F/np/", iter, ".pnm" write (filename, "(a,i5.5,a)") "./F/np/", iter, ".pnm"
call rgbpix_spit_as_pnm_16(pix, filename) call rgbpix_spit_as_pnm_16(pix, filename)
@ -63,7 +68,7 @@ contains
!-- ------------------------------------------------------------------ !-- ------------------------------------------------------------------
!-- !--
subroutine make_a_frame(image, nbdata, jobdone) subroutine make_a_frame_xy(image, nbdata, jobdone)
type(t_pixrgb), intent(inout) :: image(:,:) type(t_pixrgb), intent(inout) :: image(:,:)
integer, intent(in) :: nbdata integer, intent(in) :: nbdata
logical, intent(out) :: jobdone logical, intent(out) :: jobdone
@ -82,20 +87,16 @@ subroutine make_a_frame(image, nbdata, jobdone)
exit exit
endif endif
if ( (idx .LT. 160) .AND. & ! add flash !
if ( (idx .LT. 100) .AND. &
((abs(vl).GT.21000).OR.(abs(vr).GT.21000)) ) then ((abs(vl).GT.21000).OR.(abs(vr).GT.21000)) ) then
!-
! add flash !
write(0,*) "overshoot!" write(0,*) "overshoot!"
call preparation(image, 65000) call fill_random_gauss(image, 65000, marge)
endif endif
! scale it to the window ! scale it to the window
ix = (2 * int(vl / 111.111)) + 400 ix = width - ((2 * int(vl / 111.111)) + 400)
iy = (2 * int(vr / 166.666)) + 300 iy = (2 * int(vr / 166.666)) + 300
ix = width - ix
! write(6, *) vl, ix, " | ", vr, iy
if (is_pixel_inside(ix, iy)) then if (is_pixel_inside(ix, iy)) then
call make_big_dot(image, ix, iy) call make_big_dot(image, ix, iy)
endif endif
@ -104,15 +105,63 @@ subroutine make_a_frame(image, nbdata, jobdone)
end subroutine end subroutine
!-- ------------------------------------------------------------------ !-- ------------------------------------------------------------------
!-- ------------------------------------------------------------------
!--
subroutine dessine_cadre(image, R, G, B) subroutine make_a_frame_dplot(image, nbdata, jobdone)
type(t_pixrgb), intent(inout) :: image(:,:) type(t_pixrgb), intent(inout) :: image(:,:)
integer,intent(in) :: R, G, B integer, intent(in) :: nbdata
logical, intent(out) :: jobdone
integer :: idx, errcode
real :: vl, vr
integer :: il, ir, xpos
jobdone = .FALSE.
xpos = 1
do idx=0, nbdata
! get a sample
read(5, *, iostat=errcode) vl, vr
if (0 .NE. errcode) then
write(0, *) "iostat", errcode
jobdone = .TRUE.
exit
endif
! add flash !
if ( (idx .LT. 100) .AND. &
((abs(vl).GT.21000).OR.(abs(vr).GT.21000)) ) then
write(0,*) "overshoot!"
call fill_random_gauss(image, 65000, marge)
endif
if (xpos .LT. width) then
! scale it to the window
il = int((vl/65536.9) * real(height)) + height/2
ir = int((vr/65536.9) * real(height)) + height/2
! print *, vl, il, " | ", vr, ir
if (is_pixel_inside(xpos, il)) then
call make_big_dot(image, xpos, il)
endif
if (is_pixel_inside(xpos, ir)) then
call make_big_dot(image, xpos, ir)
endif
xpos = xpos + 1
endif
enddo
end subroutine
!-- ------------------------------------------------------------------
subroutine dessine_cadre(image, R, G, B, border)
type(t_pixrgb), intent(inout) :: image(:,:)
integer,intent(in) :: R, G, B, border
integer :: ix, iy, foo integer :: ix, iy, foo
foo = ubound(image, 2) - marge foo = ubound(image, 2) - border
do ix=1+marge, ubound(image, 1) - marge do ix=1+marge, ubound(image, 1) - border
image(ix, marge)%r = R image(ix, marge)%r = R
image(ix, marge)%g = G image(ix, marge)%g = G
image(ix, marge)%b = B image(ix, marge)%b = B
@ -121,8 +170,8 @@ subroutine dessine_cadre(image, R, G, B)
image(ix, foo)%b = B image(ix, foo)%b = B
enddo enddo
foo = ubound(image, 1) - marge foo = ubound(image, 1) - border
do iy=1+marge, ubound(image, 2)-marge do iy=1+marge, ubound(image, 2)-border
image(marge, iy)%r = R image(marge, iy)%r = R
image(marge, iy)%g = G image(marge, iy)%g = G
image(marge, iy)%b = B image(marge, iy)%b = B
@ -153,25 +202,6 @@ end function
!-- ------------------------------------------------------------------ !-- ------------------------------------------------------------------
subroutine preparation(image, mval)
type(t_pixrgb), intent(inout) :: image(:,:)
integer,intent(in) :: mval
integer :: ix, iy
write(0, *) "dim 1 =", ubound(image, 1)
write(0, *) "dim 2 =", ubound(image, 2)
do ix=1, ubound(image, 1)
do iy=1, ubound(image, 2)
image(ix, iy)%r = fair_random_gauss(mval)
image(ix, iy)%g = fair_random_gauss(mval)
image(ix, iy)%b = fair_random_gauss(mval)
enddo
enddo
end subroutine
!-- ------------------------------------------------------------------
!-- ------------------------------------------------------------------ !-- ------------------------------------------------------------------

View File

@ -41,11 +41,11 @@ subroutine make_red_dot(image, ix, iy)
type(t_pixrgb), intent(inout) :: image(:,:) type(t_pixrgb), intent(inout) :: image(:,:)
integer, intent(in) :: ix, iy integer, intent(in) :: ix, iy
image(ix, iy)%r = 65000 image(ix, iy)%r = 55000
image(ix+1, iy)%r = 65000 image(ix+1, iy)%r = 55000
image(ix-1, iy)%r = 65000 image(ix-1, iy)%r = 55000
image(ix+2, iy)%r = 65000 image(ix+2, iy)%r = 55000
image(ix-2, iy)%r = 65000 image(ix-2, iy)%r = 55000
end subroutine end subroutine
!-- ------------------------------------------------------------------ !-- ------------------------------------------------------------------
@ -118,10 +118,33 @@ subroutine dim_pix_rgb_mul(pix, fk)
do ix=1, ubound(pix, 1) do ix=1, ubound(pix, 1)
do iy=1, ubound(pix, 2) do iy=1, ubound(pix, 2)
pix(ix,iy)%r = int(float(pix(ix,iy)%r)*fk)
pix(ix,iy)%g = int(float(pix(ix,iy)%g)*fk)
pix(ix,iy)%b = int(float(pix(ix,iy)%b)*fk)
enddo enddo
enddo enddo
end subroutine end subroutine
! ------------------------------------------------------------------- ! -------------------------------------------------------------------
subroutine fill_random_gauss(image, mval, marge)
type(t_pixrgb), intent(inout) :: image(:,:)
integer,intent(in) :: mval, marge
integer :: ix, iy
! write(0, *) "dim 1 =", ubound(image, 1)
! write(0, *) "dim 2 =", ubound(image, 2)
do ix=1+marge, ubound(image, 1)-marge
do iy=1+marge, ubound(image, 2)-marge
image(ix, iy)%r = fair_random_gauss(mval)
image(ix, iy)%g = fair_random_gauss(mval)
image(ix, iy)%b = fair_random_gauss(mval)
enddo
enddo
end subroutine
!-- ------------------------------------------------------------------
end module end module