begin of a new era, maybe

This commit is contained in:
tth 2022-03-31 22:14:11 +02:00
parent c47bcfe298
commit 595c6901c9
19 changed files with 208 additions and 274 deletions

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

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

@ -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

@ -33,11 +33,11 @@ program pickover
STOP " : NO ENOUGH MEMORY"
endif
coefs(1) = 2.24 ; coefs(2) = 0.43
coefs(3) = -0.65 ; coefs(4) = -2.43
coefs(1) = 2.24 ; coefs(2) = 0.43
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

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;
}
/* --------------------------------------------------------------- */