Compare commits

...

5 Commits

Author SHA1 Message Date
tth
595c6901c9 begin of a new era, maybe 2022-03-31 22:14:11 +02:00
tth
c47bcfe298 Molly guard 2022-03-31 22:05:30 +02:00
tth
756ef965fd pickover evolutif 2022-03-30 08:42:39 +02:00
tth
f89860afe0 can now write points3d to a text file 2022-03-27 04:37:14 +02:00
tth
d5ff30a545 evolution du pickover (premier essai) 2022-03-27 04:36:25 +02:00
27 changed files with 400 additions and 301 deletions

View File

@ -6,6 +6,7 @@ nbimg.inc
*.blbs
*.mp4
*.lst
*.wav
frames/*
log.*

View File

@ -2,6 +2,11 @@
julia
pickover
lorentz
voxelize
evolvopick
WS/*.dat
WS/*.txt
*.pgm
*.gif

View File

@ -1,23 +1,28 @@
GFOPT = -Wall -Wextra -time -g -Imods/
GFOPT = -Wall -Wextra -time -O -Imods/
# ---------------------------------------------
mods/spitpgm.o: mods/spitpgm.f90 Makefile
gfortran $(GFOPT) -c $< -o $@
mods/points3d.o: mods/points3d.f90 Makefile
gfortran $(GFOPT) -c $< -o $@
fraktals.o: fraktals.f90 Makefile
gfortran $(GFOPT) -c $<
OBJS = mods/spitpgm.o fraktals.o
DOT_O = mods/points3d.o
OBJS = mods/spitpgm.o mods/points3d.o fraktals.o
# ---------------------------------------------
julia: julia.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) -o $@
pickover: pickover.f90 Makefile $(OBJS) $(DOT_O)
pickover: pickover.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) -o $@
evolvopick: evolvopick.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) $(DOT_O) -o $@
voxelize: voxelize.f90 Makefile $(OBJS)

View File

@ -33,5 +33,5 @@ Generally writen as a *sequencial unformated* file.
- Voir de près le calcul du cadrage
- Rajouter des formules
- Ne pas procastiner
- Ne pas procastiner sur le reste

15
Fraktalism/encode.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
DDIR="frames/pick3d"
echo "Encoding from " $DDIR
ffmpeg -nostdin \
-loglevel warning \
-y -r 25 -f image2 -i $DDIR/%05d.png \
-metadata artist='---[ tTh ]---' \
-metadata title='---[ experiment ]---' \
-c:v libx264 -pix_fmt yuv420p \
clifford-evolv-0.mp4

79
Fraktalism/evolvopick.f90 Normal file
View File

@ -0,0 +1,79 @@
program evolvopick
use spitpgm
use points3d
use fraktals
!-----------------------------------------------------
implicit none
double precision, dimension(4) :: KA, KB, KI
integer :: tick, nbsteps
double precision :: dptick
type(t_point3d), dimension(:), allocatable :: points
integer :: nbpoints
integer :: fd, errcode
character (len=200) :: command
KA(1) = -1.42 ; KA(2) = 1.62
KA(3) = 1.08 ; KA(4) = -2.43
KB(1) = 1.51 ; KB(2) = -1.89
KB(3) = 1.69 ; KB(4) = 0.79
nbsteps = 1800
nbpoints = 70000
allocate(points(nbpoints), stat=errcode)
if (0 .NE. errcode) then
STOP " : EVOLVOPICK, NO ENOUGH MEMORY"
endif
do tick = 0, nbsteps-1
dptick = DBLE(tick) / DBLE(nbsteps)
! print *, tick, " ", dptick
call interp4dp(KA, KB, KI, dptick)
! print *, KI(1), KI(2), KI(3), KI(4)
write(0, '(1X, I8, 3X, 4F11.6)') tick, KI
! mmmm, not optimal
open (newunit=fd, file='WS/k-pick.txt', &
status='unknown', position='append', &
action='write', iostat=errcode)
if (0 .NE. errcode) then
STOP ' : FUBAR ON OUTPUT FILE'
endif
write(fd, '(I5, 4X, 4F8.4)') tick, KI
close(fd)
!
call compute_pickover(points, KI)
call write_points3d(points, 27, 69900, 'WS/pick.dat')
write(command, '(A, I6)') './tracepick.sh ', tick
call execute_command_line (command, exitstat=errcode)
if (0 .NE. errcode) then
STOP ' : ERR RUN TRACE COMMAND !'
endif
enddo
!-----------------------------------------------------
contains
subroutine interp4dp (ina, inb, out, dpk)
double precision, dimension(4), intent(in) :: ina, inb
double precision, dimension(4), intent(out) :: out
double precision, intent(in) :: dpk
integer :: foo
do foo=1, 4
out(foo) = (ina(foo) * (1.0-dpk)) + (inb(foo) * (dpk))
enddo
end subroutine
end program evolvopick

View File

@ -27,6 +27,9 @@ subroutine simple_julia(pic, cx, cy, maxiter)
C = complex(cx, cy)
print *, "Const = ", C
! ready ? ok, clear the picture
pic = 0
do ix = 1, width
fx = (float(ix) / (float(width)/4.0) - 2.0)
do iy = 1, height
@ -50,11 +53,10 @@ subroutine simple_julia(pic, cx, cy, maxiter)
if (over_iter) then
pic(ix, iy) = 0
else
pic(ix, iy) = iter
pic(ix, iy) = iter*12
endif
enddo
enddo
enddo ! iy
enddo ! ix
end subroutine simple_julia
!-----------------------------------------------------
@ -70,25 +72,19 @@ subroutine compute_pickover(array, coefs)
integer :: i
! print *, "coefs ", coefs
write(0, '(1X, A18, I9)') "compute pickover ", ubound(array, 1)
! write(0, '(1X, A18, I9)') "compute pickover ", ubound(array, 1)
xa = 0.00 ; ya = 0.00 ; za = 0.0
xa = 1.0 ; ya = 1.0 ; za = 1.0
do i=1, ubound(array, 1)
xb = sin(coefs(1)*ya) - za*cos(coefs(2)*xa)
yb = za*sin(coefs(3)*xa) - cos(coefs(4)*ya)
zb = sin(xa)
array(i)%x = xb
array(i)%y = yb
array(i)%z = zb
array(i)%seq = i
xa = xb ; ya = yb ; za = zb
! print *, xb, yb, zb
enddo
end subroutine
@ -114,6 +110,9 @@ subroutine plot_pickover(pic, count)
STOP " : NO ENOUGH MEMORY"
endif
! Clear the picture
pic = 0
coefs(1) = 2.24 ; coefs(2) = 0.43
coefs(3) = -0.65 ; coefs(4) = -2.43
call compute_pickover(points, coefs)
@ -122,11 +121,9 @@ subroutine plot_pickover(pic, count)
h = ubound(pic, 2)
do i=1, ubound(points, 1)
px = (points(i)%x * (w/4.09)) + (w / 2)
py = (points(i)%y * (h/4.09)) + (h / 2)
pic(px, py) = 255 ! WARNING COREDUMP
px = int((points(i)%x * (w/4.09)) + (w / 2))
py = int((points(i)%y * (h/4.09)) + (h / 2))
pic(px, py) = 255 ! WARNING COREDUMP ?
enddo
deallocate(points)

View File

@ -1,6 +1,7 @@
!
! this is the main programm
!
!-----------------------------------------------------
! JULIA
! =====
! this is the main program
!-----------------------------------------------------
program julia
@ -24,7 +25,7 @@ program julia
call getarg(2, string) ; read (string, *) cx
call getarg(3, string) ; read (string, *) cy
call simple_julia(picz, cx, cy, 250)
call simple_julia(picz, cx, cy, 2500)
call spit_as_pgm_8(picz, trim(filename))
end program

View File

@ -14,13 +14,13 @@ fi
#
# run the prog
#
for foo in $(seq 0 39)
for foo in $(seq 0 99)
do
img=$(printf "frames/%05d.pgm" $foo)
img=$(printf "frames/julia/%05d.pgm" $foo)
bar=$(echo "$foo / 247.0" | bc -l)
cx=$(echo "0.4 * c($foo)" | bc -l)
cy=$(echo "0.4 * s($foo*2)" | bc -l)
cx=$(echo "0.3 * c($foo/3)" | bc -l)
cy=$(echo "0.3 * s($foo/2)" | bc -l)
./julia $img $cx $cy
@ -28,5 +28,6 @@ done
echo ; echo "Encoding, please wait..."
convert -delay 10 frames/*.pgm foo.gif
convert -delay 10 frames/julia/*.pgm foo.gif
animate foo.gif &

View File

@ -10,24 +10,51 @@ module points3d
!-----------------------------------------------------
contains
!-----------------------------------------------------
subroutine list_points3d(array, start, length)
type(t_point3d), dimension(:), intent(in) :: array
integer, intent(in) :: start, length
integer :: sz, i
integer :: sz, i, j
write(0, '(1X, A15, 2I9)') "list pt3d ", start, length
sz = ubound(array, 1)
if ((start+length) .GT. sz) then
STOP ' : OUT OF BOUND'
STOP ' : LIST P3D, OUT OF BOUND'
endif
! send oi to stdout.
do i = start, start+length-1
print *, array(i)%x, array(i)%y, array(i)%z, array(i)%seq
! send values to stdout.
do i = 1, length
j = i + start
print *, array(j)%x, array(j)%y, array(j)%z, array(j)%seq
enddo
end subroutine list_points3d
!-----------------------------------------------------
subroutine write_points3d(array, start, length, fname)
type(t_point3d), dimension(:), intent(in) :: array
integer, intent(in) :: start, length
character(*), intent(in) :: fname
integer :: sz, i, j, io
! write(0, '(1X, A15, 2I9)') "write pt3d ", start, length
sz = ubound(array, 1)
if ((start+length) .GT. sz) then
STOP ' : WRITE P3D, OUT OF BOUND'
endif
open(newunit=io, file=fname)
do i = 1, length
j = i + start
write(io, '(3F12.6)') array(j)%x, array(j)%y, array(j)%z
enddo
close(io)
end subroutine write_points3d
!-----------------------------------------------------
end module points3d

View File

@ -24,11 +24,12 @@ union {
// --------------------------------------------------------------
#declare TS = 0.017;
#declare TS = 0.025;
#declare Truc = object
{
box { <-TS, -TS, -TS>, <TS, TS, TS> }
// box { <-TS, -TS, -TS>, <TS, TS, TS> }
sphere { <0, 0, 0>, TS*0.83 }
}
#include "WS/pickover.inc"
@ -57,7 +58,7 @@ object {
plane {
<0, 1, 0>, 0
texture {
pigment { color srgb <0.133, 0.155, 0.111> }
pigment { color srgb <0.233, 0.155, 0.191> }
finish { phong 0.18 metallic 0.55 }
}
}
@ -65,18 +66,18 @@ plane {
// ----------------------------------------------------------
light_source { <-12, 17, -11> color Gray90 }
light_source { <-11, 11, 9> color Gray60 }
light_source { <-12, 15, -11> color Gray90 }
light_source { < 11, 11, 13> color Gray60 }
#declare XCAM = -3.8;
#declare XCAM = -3.1;
#declare YCAM = 3;
#declare ZCAM = 2.1;
#declare ZCAM = 1.9;
camera {
location <XCAM, YCAM, ZCAM>
look_at <0, 2.09, 0>
right x*image_width/image_height
angle 92
angle 82
}
// ----------------------------------------------------------

View File

@ -1,12 +1,20 @@
#!/bin/bash
POVOPT=" -d +q9 +a +W1920 +H1080 -v +WT4"
PASS=600
POVOPT=" -d +q9 +a +W1280 +H1024 -v +WT2"
PASS=999
ERR="/tmp/pov.error"
POVINC="WS/pickover.inc"
TMPF="/dev/shm/pickover.png"
make pickover
if [ $? -ne 0 ] ; then
echo
echo "Make error " $?
exit 1
fi
./pickover foo.pgm | awk -f pick2pov.awk > $POVINC
head $POVINC
# head $POVINC
for pass in $(seq 0 $(( PASS-1 )) )
do
@ -16,18 +24,24 @@ do
povray -ipick3d.pov -K${pass} \
Declare=NBPASS=${PASS} \
$POVOPT -O${dstname} 2> $ERR
$POVOPT -O${TMPF} 2> $ERR
if [ $? -ne 0 ]
then
tail $ERR
tail -20 $ERR
exit
fi
sleep 16
convert ${TMPF} \
-fill Gray50 \
-gravity South-West \
-pointsize 24 \
-annotate +20+10 "tTh" \
$dstname
sleep 10
done
ffmpeg -nostdin \
-loglevel warning \
-y -r 25 -f image2 -i frames/pick3d/%05d.png \

View File

@ -37,7 +37,7 @@ program pickover
coefs(3) = -0.65 ; coefs(4) = -2.43
call compute_pickover(points, coefs)
call list_points3d(points, 2, 42000)
call list_points3d(points, 200, 15000)
end program

View File

@ -1,73 +0,0 @@
module spitpgm
implicit none
contains
!-----------------------------------------------------
subroutine spit_as_pgm(pic, fname)
integer, intent(in), dimension (:,:) :: pic
character (len=*), intent(in) :: fname
integer :: io, foo
integer :: ix, iy
real :: fk, fpix
write(0, '(1X, A)') "> spit_as_pgm to " // trim(fname)
open(newunit=io, file=fname)
write (io, '(a2)') "P2"
write (io, '(i0," ",i0)') size(pic, 1), size(pic, 2)
write (io, '(i0)') 65535
foo = MAXVAL(pic)
if (foo .EQ. 0) then
print *, " IS SOMETHING WRONG GOING TO HAPPEN ?"
do ix = 1, size(pic)
write (io, "(i0)") 0
enddo
else
fk = float(foo) / 65535.0
print *, " max pix value", foo, " fk = ", fk
do iy = 1, ubound(pic, 2)
do ix = 1, ubound(pic, 1)
fpix = float(pic(ix, iy)) / fk
write (io, "(i0)") int(fpix)
end do
end do
endif
close(io)
end subroutine
!-----------------------------------------------------
subroutine spit_as_pgm_8(pic, fname)
integer, intent(in), dimension (:,:) :: pic
character (len=*), intent(in) :: fname
integer :: io, foo
integer :: ix, iy
! XXX print *, "> spit_as_pgm_8 to ", fname
foo = MAXVAL(pic)
! XXX print *, " max = ", foo
open(newunit=io, file=fname)
write (io, '(a2)') "P2"
write (io, '(i0," ",i0)') size(pic, 1), size(pic, 2)
write (io, '(i0)') 255
do iy=1,ubound(pic, 2)
do ix=1, ubound(pic, 1)
foo = pic(ix, iy)
if (foo .GT. 255) foo = 255
write(io, "(i3)") foo
enddo
enddo
close(io)
end subroutine
!-----------------------------------------------------
end module spitpgm

36
Fraktalism/tracepick.sh Executable file
View File

@ -0,0 +1,36 @@
#!/bin/bash
POVOPT=" -d +q9 +a +W1280 +H1024 -v +WT4"
TMPNG="/dev/shm/evolv.png"
outfile=$(printf "frames/pick3d/%05d.png" $1)
# echo $outfile
awk -f pick2pov.awk < WS/pick.dat > WS/pickover.inc
PASS=2222
povray -ipick3d.pov -K120 ${POVOPT} \
Declare=NBPASS=${PASS} \
-O${TMPNG} 2> WS/err-tracepick.txt
title="Clifford Pickover strange attractor"
tdate=$(date +'%F %R:%S')
# echo $tdate
coefs=$(tail -1 WS/k-pick.txt)
# echo $coefs
txt=$(printf '%s %s' "$tdate" "$coefs")
convert ${TMPNG} \
-fill Orange \
-font Courier-Bold \
-pointsize 32 \
-gravity North-West \
-annotate +30+30 "${title}" \
-pointsize 22 \
-gravity South-West \
-annotate +30+30 "${txt}" \
$outfile
sleep 2

47
Fraktalism/voxelize.f90 Normal file
View File

@ -0,0 +1,47 @@
!-----------------------------------------------------
! VOXELIZE
! ========
! this is the main program
!-----------------------------------------------------
program voxelize
use fraktals
integer, parameter :: DIM = 500
integer, dimension(:,:,:), allocatable :: cube
type(t_point3d), dimension(:), allocatable :: points
integer :: errcode, foo
integer :: ix, iy, iz
double precision, dimension(4) :: coefs
foo = (DIM*DIM*DIM) / (1024)
PRINT *, "memory request for cube (in Kwords) ", foo
allocate (cube(DIM,DIM,DIM), stat=errcode)
if (0 .NE. errcode) then
STOP " : NO ENOUGH MEMORY FOR CUBE"
endif
nbr_points = 99999
allocate(points(nbr_points), stat=errcode)
if (0 .NE. errcode) then
STOP " : NO ENOUGH MEMORY FOR POINTS"
endif
coefs(1) = 2.24 ; coefs(2) = 0.43
coefs(3) = -0.65 ; coefs(4) = -2.43
call compute_pickover(points, coefs)
call clear_cube(cube)
do foo=1, nbr_points
ix = nint(points(foo)%x * dble(DIM))
iy = nint(points(foo)%y * dble(DIM))
iz = nint(points(foo)%z * dble(DIM))
enddo
!-----------------------------------------------------
contains
!-----------------------------------------------------
!-----------------------------------------------------
end program voxelize
!-----------------------------------------------------

View File

@ -2,3 +2,8 @@
Warning, non-sense inside !
## Utilities
## Debug tools

View File

@ -0,0 +1,16 @@
# C tools
Support utilities for SoundBrotching.
### wav2text
Conversion d'un fichier son en text machinable.
### text2wav
Conversion d'un fichier texte en fichier son.
### text2ao
Envoi d'un fichier texte vers une sortie audio.

View File

@ -0,0 +1,60 @@
/*
* TEXT TO AUDIO OUTPUT
*/
#include <stdio.h>
#include <string.h>
#include <sndfile.h>
#include <ao/ao.h> /* for the sound output */
#include "support.h"
/* --------------------------------------------------------------- */
int sound_blasting(FILE *input)
{
int driver;
ao_sample_format format;
ao_device * device;
fprintf(stderr, ">>> %s ( %p )\n", __func__, input);
ao_initialize();
driver = ao_default_driver_id();
fprintf(stderr, " driver is #%d\n", driver);
memset(&format, 0, sizeof(ao_sample_format)); /* indispensable */
format.bits = 16;
format.channels = 2;
format.rate = 44100;
format.byte_format = AO_FMT_LITTLE; /* XXX ??? */
device = ao_open_live(driver, &format, NULL);
if (device == NULL)
{
fprintf(stderr, "\n%s: Error open device\n", __func__);
/*
* comment connaitre la cause de l'erreur ?
*/
return -2;
}
fprintf(stderr, "sound device open at %p\n", device);
return -1;
}
/* --------------------------------------------------------------- */
int main(int argc, char *argv[])
{
int foo;
print_version(argv[0]);
if (argc < 2) {
fprintf(stderr, "%s uh?\n", argv[0]);
}
foo = sound_blasting(stdin);
fprintf(stderr, "sound blasting -> %d\n", foo);
return 0;
}
/* --------------------------------------------------------------- */

View File

@ -2,12 +2,8 @@ program genwaves
use soundbrotch
! -----------------------------
implicit none
print *, "genwaves is coming soon..."
call soundbrotch_version()

View File

@ -1,9 +1,35 @@
program panoramix
use soundbrotch
! ------------------------------------------------------
implicit none
integer :: left, right
integer :: errcode
integer :: nblus
real :: value, phi, ka
print *, "Panoramix coming soon..."
call soundbrotch_version()
nblus = 0
do
read (*, *, iostat=errcode) left, right
if (errcode .NE. 0) then
write(0, *) 'EOF ? ', errcode
exit
endif
! *** NON WORKING CODE ***
phi = real(nblus) / 20000.0
ka = sin(phi)
value = (real(left)+real(right)) / 2.05
left = int(value*ka)
right = int(value*(1.0-ka))
print *, left, right
nblus = nblus + 1
enddo
end program

View File

@ -1,6 +1,13 @@
module soundbrotch
implicit none
! ---------------------------------------------------------
type t_sample
integer :: left
integer :: right
end type
! ---------------------------------------------------------
contains
@ -8,7 +15,7 @@ module soundbrotch
subroutine soundbrotch_version ()
write(0, '(A)') "*** this is soundbrotch version alpha"
write(0, '(A)') "*** this is soundbrotch version alpha 666"
end subroutine

View File

@ -1,31 +0,0 @@
/*
* C SUPPORT FUNCTIONS
*/
#include <stdio.h>
#include <stdlib.h>
#include <sndfile.h>
#include "support.h"
/* --------------------------------------------------------------- */
int display_sf_info(SF_INFO *psf, char *text)
{
fprintf(stderr, " +-- sf info [%s] %p\n", text, psf);
fprintf(stderr, " | samplerate %d\n", psf->samplerate);
fprintf(stderr, " | channels %d\n", psf->channels);
fprintf(stderr, " | frames %ld\n", psf->frames);
return 0;
}
/* --------------------------------------------------------------- */
void print_version(char *msg)
{
fprintf(stderr, "======== %s === compiled %s, %s\n", \
msg, __DATE__, __TIME__);
}
/* --------------------------------------------------------------- */

View File

@ -1,21 +0,0 @@
/*
* TEXT TO AUDIO OUTPUT
*/
#include <stdio.h>
#include <sndfile.h>
#include "support.h"
/* --------------------------------------------------------------- */
/* --------------------------------------------------------------- */
int main(int argc, char *argv[])
{
print_version(argv[0]);
return 0;
}
/* --------------------------------------------------------------- */

View File

@ -1,34 +0,0 @@
/*
* TEXT TO WAV
*/
#include <stdio.h>
#include <stdlib.h>
#include <sndfile.h>
#include "support.h"
/* --------------------------------------------------------------- */
int convert_text_to_wav(char *outfname)
{
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, outfname);
#endif
return -1;
}
/* --------------------------------------------------------------- */
int main(int argc, char *argv[])
{
print_version(argv[0]);
if (2 != argc) {
fprintf(stderr, "fubar\n");
exit(1);
}
return 0;
}
/* --------------------------------------------------------------- */

View File

@ -1,81 +0,0 @@
/*
* WAV TO TEXT
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sndfile.h>
#include "support.h"
/* --------------------------------------------------------------- */
int convert_wav_to_text(char *infname)
{
SNDFILE * sndf;
SF_INFO sfinfo;
int foo, lu;
short * samples;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, infname);
#endif
memset(&sfinfo, 0, sizeof(sfinfo)); /* be clean */
sndf = sf_open(infname, SFM_READ, &sfinfo);
if (sndf==NULL)
{
/*catch the snfile errmsg here XXX */
fprintf(stderr, "error sf_opening %s\n", infname);
exit(1);
}
foo = display_sf_info(&sfinfo, "why not ?");
if (foo) {
fprintf(stderr, "%s: corrupted sf_info ?\n", __func__);
abort();
}
/* get memory for bufferins read from sound file */
if ( NULL == (samples = malloc(BUFFER_SIZE*sizeof(short))) )
{
perror("\n no memory in converter");
abort();
}
while ( (lu=sf_read_short(sndf, samples, BUFFER_SIZE)) > 0 )
{
fprintf(stderr, " LU = %5lu\n", lu);
}
/*
* job done, some cleanup
*/
free(samples);
return -1;
}
/* --------------------------------------------------------------- */
void usage(void)
{
printf("usage:\n\twav2txt 1337.wav\n");
exit(0);
}
/* --------------------------------------------------------------- */
int main(int argc, char *argv[])
{
int foo;
print_version(argv[0]);
if (2 != argc) usage();
foo = convert_wav_to_text(argv[1]);
fprintf(stderr, "got a %d from converter\n", foo);
return 0;
}
/* --------------------------------------------------------------- */