Fossil SCM
Add two new small WAV files, perhaps useful as audiable alert sounds, but not yet used for anything.
Commit
2146a13df1b27aafdab5ea599d33bc8332a44b6961c92c4421d9488eb4bebd67
Parent
e5d30a7c34db7c2…
3 files changed
+66
Binary file
Binary file
+66
| --- a/src/sounds/mkwav.c | ||
| +++ b/src/sounds/mkwav.c | ||
| @@ -0,0 +1,66 @@ | ||
| 1 | +/* | |
| 2 | +** This C program was used to generate the "g-minor-triad.wav" file. | |
| 3 | +** A small modification generated the "b-flat.wav" file. | |
| 4 | +** | |
| 5 | +** This code is saved as an historical reference. It is not part | |
| 6 | +** of Fossil. | |
| 7 | +*/ | |
| 8 | +#include <stdio.h> | |
| 9 | +#include <math.h> | |
| 10 | +#include <stdlib.h> | |
| 11 | + | |
| 12 | +/* | |
| 13 | +** Write a four-byte little-endian integer value to out. | |
| 14 | +*/ | |
| 15 | +void write_int4(FILE *out, unsigned int i){ | |
| 16 | + unsigned char z[4]; | |
| 17 | + z[0] = i&0xff; | |
| 18 | + z[1] = (i>>8)&0xff; | |
| 19 | + z[2] = (i>>16)&0xff; | |
| 20 | + z[3] = (i>>24)&0xff; | |
| 21 | + fwrite(z, 4, 1, out); | |
| 22 | +} | |
| 23 | + | |
| 24 | +/* | |
| 25 | +** Write out the WAV file | |
| 26 | +*/ | |
| 27 | +void write_wave( | |
| 28 | + const char *zFilename, /* The file to write */ | |
| 29 | + unsigned int nData, /* Bytes of data */ | |
| 30 | + unsigned char *aData /* 8000 samples/sec, 8 bit samples */ | |
| 31 | +){ | |
| 32 | + const unsigned char aWavFmt[] = { | |
| 33 | + 0x57, 0x41, 0x56, 0x45, /* "WAVE" */ | |
| 34 | + 0x66, 0x6d, 0x74, 0x20, /* "fmt " */ | |
| 35 | + 0x10, 0x00, 0x00, 0x00, /* 16 bytes in the "fmt " section */ | |
| 36 | + 0x01, 0x00, /* FormatTag: WAVE_FORMAT_PCM */ | |
| 37 | + 0x01, 0x00, /* 1 channel */ | |
| 38 | + 0x40, 0x1f, 0x00, 0x00, /* 8000 samples/second */ | |
| 39 | + 0x40, 0x1f, 0x00, 0x00, /* 8000 bytes/second */ | |
| 40 | + 0x01, 0x00, /* Block alignment */ | |
| 41 | + 0x08, 0x00, /* bits/sample */ | |
| 42 | + 0x64, 0x61, 0x74, 0x61, /* "data" */ | |
| 43 | + }; | |
| 44 | + FILE *out = fopen(zFilename,"wb"); | |
| 45 | + if( out==0 ){ | |
| 46 | + fprintf(stderr, "cannot open \"%s\" for writing\n", zFilename); | |
| 47 | + exit(1); | |
| 48 | + } | |
| 49 | + fwrite("RIFF", 4, 1, out); | |
| 50 | + write_int4(out, nData+4+20+8); | |
| 51 | + fwrite(aWavFmt, sizeof(aWavFmt), 1, out); | |
| 52 | + write_int4(out, nData); | |
| 53 | + fwrite(aData, nData, 1, out); | |
| 54 | + fclose(out); | |
| 55 | +} | |
| 56 | + | |
| 57 | +int main(int argc, char **argv){ | |
| 58 | + int i = 0; | |
| 59 | + unsigned char aBuf[800]; | |
| 60 | +# define N sizeof(aBuf) | |
| 61 | +# define pitch1 195.9977*2 /* G */ | |
| 62 | +# define pitch2 233.0819*2 /* B-flat */ | |
| 63 | +# define pitch3 293.6648*2 /* D */ | |
| 64 | + while( i<N ){ | |
| 65 | + double v; | |
| 66 | + v = 33v += 33.0*sin((2*M_PI*p |
| --- a/src/sounds/mkwav.c | |
| +++ b/src/sounds/mkwav.c | |
| @@ -0,0 +1,66 @@ | |
| --- a/src/sounds/mkwav.c | |
| +++ b/src/sounds/mkwav.c | |
| @@ -0,0 +1,66 @@ | |
| 1 | /* |
| 2 | ** This C program was used to generate the "g-minor-triad.wav" file. |
| 3 | ** A small modification generated the "b-flat.wav" file. |
| 4 | ** |
| 5 | ** This code is saved as an historical reference. It is not part |
| 6 | ** of Fossil. |
| 7 | */ |
| 8 | #include <stdio.h> |
| 9 | #include <math.h> |
| 10 | #include <stdlib.h> |
| 11 | |
| 12 | /* |
| 13 | ** Write a four-byte little-endian integer value to out. |
| 14 | */ |
| 15 | void write_int4(FILE *out, unsigned int i){ |
| 16 | unsigned char z[4]; |
| 17 | z[0] = i&0xff; |
| 18 | z[1] = (i>>8)&0xff; |
| 19 | z[2] = (i>>16)&0xff; |
| 20 | z[3] = (i>>24)&0xff; |
| 21 | fwrite(z, 4, 1, out); |
| 22 | } |
| 23 | |
| 24 | /* |
| 25 | ** Write out the WAV file |
| 26 | */ |
| 27 | void write_wave( |
| 28 | const char *zFilename, /* The file to write */ |
| 29 | unsigned int nData, /* Bytes of data */ |
| 30 | unsigned char *aData /* 8000 samples/sec, 8 bit samples */ |
| 31 | ){ |
| 32 | const unsigned char aWavFmt[] = { |
| 33 | 0x57, 0x41, 0x56, 0x45, /* "WAVE" */ |
| 34 | 0x66, 0x6d, 0x74, 0x20, /* "fmt " */ |
| 35 | 0x10, 0x00, 0x00, 0x00, /* 16 bytes in the "fmt " section */ |
| 36 | 0x01, 0x00, /* FormatTag: WAVE_FORMAT_PCM */ |
| 37 | 0x01, 0x00, /* 1 channel */ |
| 38 | 0x40, 0x1f, 0x00, 0x00, /* 8000 samples/second */ |
| 39 | 0x40, 0x1f, 0x00, 0x00, /* 8000 bytes/second */ |
| 40 | 0x01, 0x00, /* Block alignment */ |
| 41 | 0x08, 0x00, /* bits/sample */ |
| 42 | 0x64, 0x61, 0x74, 0x61, /* "data" */ |
| 43 | }; |
| 44 | FILE *out = fopen(zFilename,"wb"); |
| 45 | if( out==0 ){ |
| 46 | fprintf(stderr, "cannot open \"%s\" for writing\n", zFilename); |
| 47 | exit(1); |
| 48 | } |
| 49 | fwrite("RIFF", 4, 1, out); |
| 50 | write_int4(out, nData+4+20+8); |
| 51 | fwrite(aWavFmt, sizeof(aWavFmt), 1, out); |
| 52 | write_int4(out, nData); |
| 53 | fwrite(aData, nData, 1, out); |
| 54 | fclose(out); |
| 55 | } |
| 56 | |
| 57 | int main(int argc, char **argv){ |
| 58 | int i = 0; |
| 59 | unsigned char aBuf[800]; |
| 60 | # define N sizeof(aBuf) |
| 61 | # define pitch1 195.9977*2 /* G */ |
| 62 | # define pitch2 233.0819*2 /* B-flat */ |
| 63 | # define pitch3 293.6648*2 /* D */ |
| 64 | while( i<N ){ |
| 65 | double v; |
| 66 | v = 33v += 33.0*sin((2*M_PI*p |