]> git.sesse.net Git - ffmpeg/blobdiff - tests/audiogen.c
output example: convert audio to the format supported by the encoder
[ffmpeg] / tests / audiogen.c
index 8d27dc26320def67eb2153a9cab11b38c7092090..ce6f7854eada55200bad754ccca4578d587238a0 100644 (file)
@@ -48,7 +48,7 @@ static unsigned int myrnd(unsigned int *seed_ptr, int n)
 
 #define COS_TABLE_BITS 7
 
-/* integer cosinus */
+/* integer cosine */
 static const unsigned short cos_table[(1 << COS_TABLE_BITS) + 2] = {
     0x8000, 0x7ffe, 0x7ff6, 0x7fea, 0x7fd9, 0x7fc2, 0x7fa7, 0x7f87,
     0x7f62, 0x7f38, 0x7f0a, 0x7ed6, 0x7e9d, 0x7e60, 0x7e1e, 0x7dd6,
@@ -144,8 +144,8 @@ int main(int argc, char **argv)
     int nb_channels = 2;
     char *ext;
 
-    if (argc < 2 || argc > 4) {
-        printf("usage: %s file [<sample rate> [<channels>]]\n"
+    if (argc < 2 || argc > 5) {
+        printf("usage: %s file [<sample rate> [<channels>] [<random seed>]]\n"
                "generate a test raw 16 bit audio stream\n"
                "If the file extension is .wav a WAVE header will be added.\n"
                "default: 44100 Hz stereo\n", argv[0]);
@@ -168,6 +168,9 @@ int main(int argc, char **argv)
         }
     }
 
+    if (argc > 4)
+        seed = atoi(argv[4]);
+
     outfile = fopen(argv[1], "wb");
     if (!outfile) {
         perror(argv[1]);
@@ -177,7 +180,7 @@ int main(int argc, char **argv)
     if ((ext = strrchr(argv[1], '.')) != NULL && !strcmp(ext, ".wav"))
         put_wav_header(sample_rate, nb_channels, 6 * sample_rate);
 
-    /* 1 second of single freq sinus at 1000 Hz */
+    /* 1 second of single freq sine at 1000 Hz */
     a = 0;
     for (i = 0; i < 1 * sample_rate; i++) {
         v = (int_cos(a) * 10000) >> FRAC_BITS;
@@ -186,7 +189,7 @@ int main(int argc, char **argv)
         a += (1000 * FRAC_ONE) / sample_rate;
     }
 
-    /* 1 second of varing frequency between 100 and 10000 Hz */
+    /* 1 second of varying frequency between 100 and 10000 Hz */
     a = 0;
     for (i = 0; i < 1 * sample_rate; i++) {
         v = (int_cos(a) * 10000) >> FRAC_BITS;