Compare commits

..

No commits in common. "595c6901c9a6b922935c4619dea5ba567f677132" and "362121740226e50be6b000c1c0fa268a3fc2a693" have entirely different histories.

27 changed files with 301 additions and 400 deletions

View File

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

View File

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

View File

@ -1,28 +1,23 @@
GFOPT = -Wall -Wextra -time -O -Imods/ GFOPT = -Wall -Wextra -time -g -Imods/
# --------------------------------------------- # ---------------------------------------------
mods/spitpgm.o: mods/spitpgm.f90 Makefile mods/spitpgm.o: mods/spitpgm.f90 Makefile
gfortran $(GFOPT) -c $< -o $@
mods/points3d.o: mods/points3d.f90 Makefile
gfortran $(GFOPT) -c $< -o $@ gfortran $(GFOPT) -c $< -o $@
fraktals.o: fraktals.f90 Makefile fraktals.o: fraktals.f90 Makefile
gfortran $(GFOPT) -c $< gfortran $(GFOPT) -c $<
OBJS = mods/spitpgm.o mods/points3d.o fraktals.o OBJS = mods/spitpgm.o fraktals.o
DOT_O = mods/points3d.o
# --------------------------------------------- # ---------------------------------------------
julia: julia.f90 Makefile $(OBJS) julia: julia.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) -o $@ gfortran $(GFOPT) $< $(OBJS) -o $@
pickover: pickover.f90 Makefile $(OBJS) pickover: pickover.f90 Makefile $(OBJS) $(DOT_O)
gfortran $(GFOPT) $< $(OBJS) -o $@
evolvopick: evolvopick.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) $(DOT_O) -o $@ gfortran $(GFOPT) $< $(OBJS) $(DOT_O) -o $@
voxelize: voxelize.f90 Makefile $(OBJS) 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 - Voir de près le calcul du cadrage
- Rajouter des formules - Rajouter des formules
- Ne pas procastiner sur le reste - Ne pas procastiner

View File

@ -1,15 +0,0 @@
#!/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

View File

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

View File

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

View File

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

View File

@ -10,51 +10,24 @@ module points3d
!----------------------------------------------------- !-----------------------------------------------------
contains contains
!-----------------------------------------------------
subroutine list_points3d(array, start, length) subroutine list_points3d(array, start, length)
type(t_point3d), dimension(:), intent(in) :: array type(t_point3d), dimension(:), intent(in) :: array
integer, intent(in) :: start, length integer, intent(in) :: start, length
integer :: sz, i, j integer :: sz, i
write(0, '(1X, A15, 2I9)') "list pt3d ", start, length
sz = ubound(array, 1) sz = ubound(array, 1)
if ((start+length) .GT. sz) then if ((start+length) .GT. sz) then
STOP ' : LIST P3D, OUT OF BOUND' STOP ' : OUT OF BOUND'
endif endif
! send values to stdout. ! send oi to stdout.
do i = 1, length do i = start, start+length-1
j = i + start print *, array(i)%x, array(i)%y, array(i)%z, array(i)%seq
print *, array(j)%x, array(j)%y, array(j)%z, array(j)%seq
enddo enddo
end subroutine list_points3d 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 end module points3d

View File

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

View File

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

View File

@ -33,11 +33,11 @@ program pickover
STOP " : NO ENOUGH MEMORY" STOP " : NO ENOUGH MEMORY"
endif endif
coefs(1) = 2.24 ; coefs(2) = 0.43 coefs(1) = 2.24 ; coefs(2) = 0.43
coefs(3) = -0.65 ; coefs(4) = -2.43 coefs(3) = -0.65 ; coefs(4) = -2.43
call compute_pickover(points, coefs) call compute_pickover(points, coefs)
call list_points3d(points, 200, 15000) call list_points3d(points, 2, 42000)
end program end program

73
Fraktalism/spitpgm.f90 Normal file
View File

@ -0,0 +1,73 @@
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

View File

@ -1,36 +0,0 @@
#!/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

View File

@ -1,47 +0,0 @@
!-----------------------------------------------------
! 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,8 +2,3 @@
Warning, non-sense inside ! Warning, non-sense inside !
## Utilities
## Debug tools

View File

@ -1,16 +0,0 @@
# 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

@ -1,60 +0,0 @@
/*
* 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,8 +2,12 @@ program genwaves
use soundbrotch use soundbrotch
! ----------------------------- ! -----------------------------
implicit none implicit none
print *, "genwaves is coming soon..."
call soundbrotch_version() call soundbrotch_version()

View File

@ -1,35 +1,9 @@
program panoramix program panoramix
use soundbrotch
! ------------------------------------------------------
implicit none implicit none
integer :: left, right
integer :: errcode
integer :: nblus
real :: value, phi, ka
call soundbrotch_version() print *, "Panoramix coming soon..."
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 end program

View File

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

31
SoundBrotching/support.c Normal file
View File

@ -0,0 +1,31 @@
/*
* 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__);
}
/* --------------------------------------------------------------- */

21
SoundBrotching/text2ao.c Normal file
View File

@ -0,0 +1,21 @@
/*
* 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;
}
/* --------------------------------------------------------------- */

34
SoundBrotching/text2wav.c Normal file
View File

@ -0,0 +1,34 @@
/*
* 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;
}
/* --------------------------------------------------------------- */

81
SoundBrotching/wav2text.c Normal file
View File

@ -0,0 +1,81 @@
/*
* 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;
}
/* --------------------------------------------------------------- */