Compare commits

..

No commits in common. "8223cb8e77464da920567f94490b00b3f54625d8" and "b707b784bf90bb1fd6a6b7ca7d6ad7c94732d8af" have entirely different histories.

15 changed files with 40 additions and 95 deletions

View File

@ -4,7 +4,7 @@
# Makefile for the general purpose moduls # Makefile for the general purpose moduls
# #
GFOPT = -Wall -Wextra -time -g GFOPT = -Wall -Wextra -time -g
all: chkpixels all: chkpixels

View File

@ -5,10 +5,6 @@
Write gray level 2d buffer (aka picture) to disk in the NetPNM format. Write gray level 2d buffer (aka picture) to disk in the NetPNM format.
## pixrgb
Write 8 bits RGB pictures to PNM format.
## trials ## trials
Experimental WIPs from hell. Experimental WIPs from hell.

View File

@ -11,8 +11,8 @@ program chkpixels
implicit none implicit none
write(0, *) "------ CHKPIXELS ------" write(0, *) "------ CHKPIXELS ------"
call test_spit_as(3) ! call test_spit_as(3)
call test_spit_rgb(128, 222) call test_spit_rgb(256)
STOP 'BECAUSE NO CPU AVAILABLE' STOP 'BECAUSE NO CPU AVAILABLE'
@ -21,8 +21,8 @@ contains
!- !-
! exerciser for the 'pixrgb' module ! exerciser for the 'pixrgb' module
!- !-
subroutine test_spit_rgb(sz, kg) subroutine test_spit_rgb(sz)
integer, intent(in) :: sz, kg integer, intent(in) :: sz
type(t_pixrgb), allocatable :: pixrgb(:,:) type(t_pixrgb), allocatable :: pixrgb(:,:)
integer :: ix, iy integer :: ix, iy
@ -33,7 +33,7 @@ contains
do ix=1, sz do ix=1, sz
do iy=1, sz do iy=1, sz
pixrgb(ix, iy)%r = ix pixrgb(ix, iy)%r = ix
pixrgb(ix, iy)%g = mod(ix*iy, kg) pixrgb(ix, iy)%g = 0
pixrgb(ix, iy)%b = iy pixrgb(ix, iy)%b = iy
end do end do
end do end do
@ -50,7 +50,6 @@ contains
integer, dimension(SZ, SZ) :: greymap integer, dimension(SZ, SZ) :: greymap
integer :: ix, iy, value integer :: ix, iy, value
print *, "test spit as", sz
value = 0 value = 0
do iy=1, SZ do iy=1, SZ
do ix=1, SZ do ix=1, SZ
@ -58,10 +57,10 @@ contains
value = value + increment value = value + increment
enddo enddo
enddo enddo
call spit_as_pgm_16 (greymap, 'a.pnm') call spit_as_pgm_16 (greymap, 'a.pgm')
call spit_as_pgm_eq (greymap, 'b.pnm') call spit_as_pgm_eq (greymap, 'b.pgm')
call spit_as_pgm_8 (greymap, 'c.pnm') call spit_as_pgm_8 (greymap, 'c.pgm')
call new_spit_a (greymap, 'x.pnm') call new_spit_a (greymap, 'x.pgm')
end subroutine end subroutine
end program end program

View File

@ -1,5 +1,5 @@
!- !-
! This module try to write PNM complient RGB files ! This module try to write PGM complient gray level files
!- !-
module pixrgb module pixrgb
implicit none implicit none
@ -28,23 +28,6 @@ subroutine rgbpix_set_to_zero(pic)
end subroutine end subroutine
!------------------------------------------------------------------- !-------------------------------------------------------------------
!- !-
! NOT TESTED !!!
!-
subroutine rgb_pix_clamp_at_8(pic)
type(t_pixrgb), intent(inout) :: pic(:,:)
integer :: ix, iy
do iy=1, ubound(pic, 2)
do ix=1, ubound(pic, 1)
pic(ix, iy)%r = max(0, min(pic(ix, iy)%r, 255))
pic(ix, iy)%g = max(0, min(pic(ix, iy)%g, 255))
pic(ix, iy)%b = max(0, min(pic(ix, iy)%b, 255))
enddo
enddo
end subroutine
!-------------------------------------------------------------------
!-
! CAUTION: there was NO out-of-bounds check !
!-
subroutine rgbpix_spit_as_pnm_8(pic, fname) subroutine rgbpix_spit_as_pnm_8(pic, fname)
type(t_pixrgb), intent(in) :: pic(:,:) type(t_pixrgb), intent(in) :: pic(:,:)
character (len=*), intent(in) :: fname character (len=*), intent(in) :: fname
@ -59,7 +42,7 @@ subroutine rgbpix_spit_as_pnm_8(pic, fname)
do iy=1, ubound(pic, 2) do iy=1, ubound(pic, 2)
do ix=1, ubound(pic, 1) do ix=1, ubound(pic, 1)
write(io, "(3I5)") pic(ix, iy)%r, pic(ix, iy)%g, pic(ix, iy)%b write(io, "(3I12)") pic(ix, iy)%r, pic(ix, iy)%g, pic(ix, iy)%b
enddo enddo
enddo enddo
close(unit=io) close(unit=io)
@ -67,8 +50,6 @@ subroutine rgbpix_spit_as_pnm_8(pic, fname)
end subroutine end subroutine
!------------------------------------------------------------------- !-------------------------------------------------------------------
!- !-
! CAUTION: there was NO out-of-bounds check !
!-
subroutine rgbpix_spit_as_pnm_16(pic, fname) subroutine rgbpix_spit_as_pnm_16(pic, fname)
type(t_pixrgb), intent(in) :: pic(:,:) type(t_pixrgb), intent(in) :: pic(:,:)

View File

@ -60,8 +60,7 @@ subroutine spit_as_pgm_16(pic, fname)
open(newunit=io, file=fname) open(newunit=io, file=fname)
write (io, '(a2)') "P2" write (io, '(a2)') "P2"
write (io, '(A)') "# spit_as_pgm_16" write (io, '("# size:", I9)') size(pic)
! write (io, '("# size:", I9)') size(pic)
write (io, '(i0," ",i0)') size(pic, 1), size(pic, 2) write (io, '(i0," ",i0)') size(pic, 1), size(pic, 2)
write (io, '(i0)') 65535 write (io, '(i0)') 65535

View File

@ -9,9 +9,9 @@
text2wav text2wav
wav2text wav2text
text2ao text2ao
essai
panoramix panoramix
genwaves genwaves
soundbrotch soundbrotch
essai

View File

@ -1,6 +1,6 @@
# SoundBrotching # SoundBrotching
Stay tuned, film at 440. Stay tuned, film at 11.
## Cheat Code ## Cheat Code
@ -10,9 +10,9 @@ de ce sous-projet fortranique sont
ecrits en C, pour un accès facile à des bibliothèques tierces ecrits en C, pour un accès facile à des bibliothèques tierces
comme `libsndfile` ou `libao`, composants essentiels du SoundBrotching. comme `libsndfile` ou `libao`, composants essentiels du SoundBrotching.
## Not so serious game ## Serious game
Quelques exemples simple, mais bruyants... `runme.sh` Quelques exemples simple, mais bruyants...
### genwaves ### genwaves
@ -20,5 +20,5 @@ Génération de sons qui arrachent les oreilles.
### panoramix ### panoramix
Conversion de l'entrée en mono, et déplacement en sinusoïdale d'un Conversion de l'entrée en mono, et dépacement en sinus d'un
coté de l'univers à l'autre. coté à l'autre.

View File

@ -24,17 +24,7 @@ return 0;
/* --------------------------------------------------------------- */ /* --------------------------------------------------------------- */
void print_version(char *msg) void print_version(char *msg)
{ {
fprintf(stderr, "=== %s, support compiled %s, %s\n", \ fprintf(stderr, "=== %s compiled %s, %s\n", \
msg, __DATE__, __TIME__); msg, __DATE__, __TIME__);
} }
/* --------------------------------------------------------------- */ /* --------------------------------------------------------------- */
int check_textfile_validity(char *filename, int what)
{
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, filename, what);
#endif
return -1;
}
/* --------------------------------------------------------------- */

View File

@ -10,6 +10,4 @@ int display_sf_info(SF_INFO *psf, char *text);
void print_version(char *title); void print_version(char *title);
int check_textfile_validity(char *filename, int what);
/* --------------------------------------------------------- */ /* --------------------------------------------------------- */

View File

@ -1,5 +1,5 @@
/* /*
* TEXT TO WAV - a klugeware from tTh 2023 * TEXT TO WAV
*/ */
#include <stdio.h> #include <stdio.h>
@ -27,7 +27,7 @@ int left, right;
int nb_lus, idx; int nb_lus, idx;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' %d %d )\n", __func__, outf, sr, format); fprintf(stderr, ">>> %s ( '%s' )\n", __func__, outf);
#endif #endif
if (format) { if (format) {
@ -78,16 +78,11 @@ while (2==fscanf(input, "%d %d", &left, &right)) {
sf_write_short(sndf, buffer, idx); sf_write_short(sndf, buffer, idx);
sf_close(sndf); sf_close(sndf);
free(buffer); fprintf(stderr, "%s: %d buffers written\n", __func__, nb_lus);
fprintf(stderr, "%s: %d samples written\n", __func__, nb_lus);
return 0; return 0;
} }
/* --------------------------------------------------------------- */ /* --------------------------------------------------------------- */
/*
* this is a preview software, so no args parsiong yet...
*/
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int foo; int foo;

View File

@ -59,7 +59,10 @@ if ( NULL == (samples = malloc(BUFFER_SIZE*sizeof(short))) )
abort(); abort();
} }
while ( (lu=sf_read_short(sndf, samples, BUFFER_SIZE)) > 0 ) { while ( (lu=sf_read_short(sndf, samples, BUFFER_SIZE)) > 0 )
{
// fprintf(stderr, " LU = %5u\n", lu);
for (foo=0; foo<lu; foo+=2) { for (foo=0; foo<lu; foo+=2) {
printf("%d %d\n", samples[foo], samples[foo+1]); printf("%d %d\n", samples[foo], samples[foo+1]);
} }

View File

@ -11,11 +11,11 @@ program essai
call soundbrotch_version() call soundbrotch_version()
do n = 40, 85 do n = 20, 85
freq = midi2freq(n) freq = midi2freq(n)
write(0, '(" midi", I5, " -> ", F9.3, " Hz")') n, freq write(0, '(12X, I5, 5X, F9.3)') n, freq
call sinw_burst2i(6, 44100, freq, freq, 0.9) call sinw_burst2i(6, 22000, freq, freq, 0.9)
call silence_burst2i(2900) call silence_burst2i(800)
end do end do
end program end program

View File

@ -1,6 +1,4 @@
!-
! JUST A SMALL EXPERIMENT
!-
program panoramix program panoramix
use soundbrotch use soundbrotch
@ -22,8 +20,9 @@ program panoramix
exit exit
endif endif
phi = real(nblus) / 9500.0 ! *** NON WORKING CODE ***
ka = 0.500 + (sin(phi) * 0.4999) phi = real(nblus) / 44100.0
ka = sin(phi)
value = (real(left)+real(right)) / 2.05 value = (real(left)+real(right)) / 2.05
left = int(value * ka) left = int(value * ka)
right = int(value * (1.0-ka)) right = int(value * (1.0-ka))

View File

@ -1,16 +0,0 @@
#!/bin/bash
set -e # trap on error
DATAFILE="essai.text"
OUTWAV="essai.wav"
make essai
./essai | tee $DATAFILE | c-tools/text2wav $OUTWAV
sndfile-spectrogram \
--min-freq=30 --max-freq=2000 \
--hann \
$OUTWAV \
1200 600 \
spectrogram.png

View File

@ -11,14 +11,16 @@ module soundbrotch
integer, private :: samplerate = 48000 integer, private :: samplerate = 48000
real, private :: diapason = 440.0 real, private :: diapason = 440.0
contains contains
! --------------------------------------------------------- ! ---------------------------------------------------------
subroutine soundbrotch_version () subroutine soundbrotch_version ()
write(0, '(1X,A)') "--- this is soundbrotch version alpha 667" write(0, '(1X,A)') "--- this is soundbrotch version alpha 666"
write(0, *) "--- samplerate", samplerate write(0, *) "--- samplerate", samplerate
write(0, *) "--- diapason ", diapason write(0, *) "--- diapason ", diapason
end subroutine end subroutine
! --------------------------------------------------------- ! ---------------------------------------------------------
! ---------------------------------------------------------
! --------------------------------------------------------- ! ---------------------------------------------------------
! premier essai, le prototype peut changer ! ! premier essai, le prototype peut changer !
@ -31,9 +33,8 @@ contains
integer :: idx, left, right integer :: idx, left, right
real :: coef real :: coef
! XXX temporary dirty hack
if (dst .NE. 6) then if (dst .NE. 6) then
STOP ' OUPS, NOT ON STDOUT!' STOP ' OUPS!'
endif endif
coef = (3.141592654 * 2.0) / real(samplerate) coef = (3.141592654 * 2.0) / real(samplerate)