From a6933029695b4173122a7dccdc6fb4f638f1c112 Mon Sep 17 00:00:00 2001 From: tth Date: Mon, 7 Feb 2022 23:17:22 +0100 Subject: [PATCH] boilerplate in progress --- SoundBrotching/.gitignore | 15 +++++++ SoundBrotching/Makefile | 46 +++++++++++++++++++ SoundBrotching/README.md | 7 +++ SoundBrotching/demos.sh | 8 ++++ SoundBrotching/genwaves.f90 | 15 +++++++ SoundBrotching/panoramix.f90 | 9 ++++ SoundBrotching/soundbrotch.f90 | 18 ++++++++ SoundBrotching/support.c | 31 +++++++++++++ SoundBrotching/support.h | 13 ++++++ SoundBrotching/text2ao.c | 21 +++++++++ SoundBrotching/text2wav.c | 34 ++++++++++++++ SoundBrotching/wav2text.c | 81 ++++++++++++++++++++++++++++++++++ 12 files changed, 298 insertions(+) create mode 100644 SoundBrotching/.gitignore create mode 100755 SoundBrotching/demos.sh create mode 100644 SoundBrotching/genwaves.f90 create mode 100644 SoundBrotching/panoramix.f90 create mode 100644 SoundBrotching/soundbrotch.f90 create mode 100644 SoundBrotching/support.c create mode 100644 SoundBrotching/support.h create mode 100644 SoundBrotching/text2ao.c create mode 100644 SoundBrotching/text2wav.c create mode 100644 SoundBrotching/wav2text.c diff --git a/SoundBrotching/.gitignore b/SoundBrotching/.gitignore new file mode 100644 index 0000000..a0f8649 --- /dev/null +++ b/SoundBrotching/.gitignore @@ -0,0 +1,15 @@ +# +# please ignore those files +# + +*.wav +*.text + +text2wav +wav2text +text2ao + +panoramix +genwaves +soundbrotch + diff --git a/SoundBrotching/Makefile b/SoundBrotching/Makefile index e69de29..604f0aa 100644 --- a/SoundBrotching/Makefile +++ b/SoundBrotching/Makefile @@ -0,0 +1,46 @@ +# +# tth@konrad:~/Devel/Fortraneries/SoundBrotching$ +# + +COPT = -Wall -Wextra -g -DDEBUG_LEVEL=1 + +all: text2wav wav2text text2ao \ + panoramix genwaves + +# ---------------------------------------------------------- +# +# C tools +# +CLIBS = -lsndfile support.o + +support.o: support.c Makefile support.h + gcc $(COPT) -c $< + +text2wav: text2wav.c Makefile support.h support.o + gcc $(COPT) $< $(CLIBS) -o $@ + +wav2text: wav2text.c Makefile support.h support.o + gcc $(COPT) $< $(CLIBS) -o $@ + +text2ao: text2ao.c Makefile support.h support.o + gcc $(COPT) $< $(CLIBS) -o $@ + +# ---------------------------------------------------------- +# +# real softwares +# +FLIBS = soundbrotch.o + +soundbrotch.o: soundbrotch.f90 Makefile + gfortran $(COPT) -c $< + +panoramix: panoramix.f90 Makefile $(FLIBS) + gfortran $(COPT) $< $(FLIBS) -o $@ + +genwaves: genwaves.f90 Makefile $(FLIBS) + gfortran $(COPT) $< $(FLIBS) -o $@ + +# ---------------------------------------------------------- + + +# ---------------------------------------------------------- diff --git a/SoundBrotching/README.md b/SoundBrotching/README.md index 39f6a35..f674cc0 100644 --- a/SoundBrotching/README.md +++ b/SoundBrotching/README.md @@ -2,3 +2,10 @@ Stay tuned, film at 11. +## Cheat Code + +Certains composants de ce sous-projet fortranique sont +(pour le moment) +ecrits en C, pour un accès facile à des bibliothèques tierces +comme `libsndfile`, composant essentiel du SoundBrotching. + diff --git a/SoundBrotching/demos.sh b/SoundBrotching/demos.sh new file mode 100755 index 0000000..9bd11a5 --- /dev/null +++ b/SoundBrotching/demos.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +INWAV="1637.wav" +OUTWAV="foo.wav" + +./wav2text $INWAV | ./panoramix | ./text2wav $OUTWAV + + diff --git a/SoundBrotching/genwaves.f90 b/SoundBrotching/genwaves.f90 new file mode 100644 index 0000000..8ac2017 --- /dev/null +++ b/SoundBrotching/genwaves.f90 @@ -0,0 +1,15 @@ +program genwaves + + use soundbrotch + ! ----------------------------- + + implicit none + + + print *, "genwaves is coming soon..." + + call soundbrotch_version() + + +end program + diff --git a/SoundBrotching/panoramix.f90 b/SoundBrotching/panoramix.f90 new file mode 100644 index 0000000..80fdaad --- /dev/null +++ b/SoundBrotching/panoramix.f90 @@ -0,0 +1,9 @@ + +program panoramix + + implicit none + + print *, "Panoramix coming soon..." + +end program + diff --git a/SoundBrotching/soundbrotch.f90 b/SoundBrotching/soundbrotch.f90 new file mode 100644 index 0000000..726d6d5 --- /dev/null +++ b/SoundBrotching/soundbrotch.f90 @@ -0,0 +1,18 @@ +module soundbrotch + + implicit none + + contains + + ! --------------------------------------------------------- + + subroutine soundbrotch_version () + + write(0, '(A)') "*** this is soundbrotch version alpha" + + end subroutine + + ! --------------------------------------------------------- + +end module + diff --git a/SoundBrotching/support.c b/SoundBrotching/support.c new file mode 100644 index 0000000..b152e03 --- /dev/null +++ b/SoundBrotching/support.c @@ -0,0 +1,31 @@ +/* + * C SUPPORT FUNCTIONS + */ + +#include +#include + +#include + +#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 %d\n", psf->frames); + +return 0; +} +/* --------------------------------------------------------------- */ + +void print_version(char *msg) +{ +fprintf(stderr, "======== %s === compiled %s, %s\n", \ + msg, __DATE__, __TIME__); +} +/* --------------------------------------------------------------- */ diff --git a/SoundBrotching/support.h b/SoundBrotching/support.h new file mode 100644 index 0000000..1c8b568 --- /dev/null +++ b/SoundBrotching/support.h @@ -0,0 +1,13 @@ +/* + * C SUPPORT FUNCTIONS + */ + +#define BUFFER_SIZE 8192 + +/* --------------------------------------------------------- */ + +int display_sf_info(SF_INFO *psf, char *text); + +void print_version(char *title); + +/* --------------------------------------------------------- */ diff --git a/SoundBrotching/text2ao.c b/SoundBrotching/text2ao.c new file mode 100644 index 0000000..38d88a9 --- /dev/null +++ b/SoundBrotching/text2ao.c @@ -0,0 +1,21 @@ +/* + * TEXT TO AUDIO OUTPUT + */ + +#include + +#include + +#include "support.h" + +/* --------------------------------------------------------------- */ + +/* --------------------------------------------------------------- */ +int main(int argc, char *argv[]) +{ + +print_version(argv[0]); + +return 0; +} +/* --------------------------------------------------------------- */ diff --git a/SoundBrotching/text2wav.c b/SoundBrotching/text2wav.c new file mode 100644 index 0000000..007915b --- /dev/null +++ b/SoundBrotching/text2wav.c @@ -0,0 +1,34 @@ +/* + * TEXT TO WAV + */ + +#include +#include +#include + +#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; +} +/* --------------------------------------------------------------- */ diff --git a/SoundBrotching/wav2text.c b/SoundBrotching/wav2text.c new file mode 100644 index 0000000..33946d2 --- /dev/null +++ b/SoundBrotching/wav2text.c @@ -0,0 +1,81 @@ +/* + * WAV TO TEXT + */ + +#include +#include +#include + +#include + +#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; +} +/* --------------------------------------------------------------- */