[beast: 3/9] BSE: move bseinfo to "bsetool dump-info"



commit 7d1360b41f694ea208a7163a95bdcbf8dc05386f
Author: Tim Janik <timj gnu org>
Date:   Thu Sep 17 18:11:51 2015 +0200

    BSE: move bseinfo to "bsetool dump-info"

 bse/Makefile.am |    6 +---
 bse/bseinfo.cc  |   91 -----------------------------------------------------
 bse/bsetool.cc  |   93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 94 insertions(+), 96 deletions(-)
---
diff --git a/bse/Makefile.am b/bse/Makefile.am
index 9cc3728..580ea70 100644
--- a/bse/Makefile.am
+++ b/bse/Makefile.am
@@ -333,7 +333,7 @@ EXTRA_DIST += bseapi.idl
 # == GENERATED targets ==
 CLEANFILES += $(GENERATED)
 $(libbse_la_OBJECTS): $(GENERATED)     # needed dependency to force file generation
-$(bseinfo_OBJECTS) $(bseprocidl_OBJECTS) $(bsequery_OBJECTS) $(bsetool_OBJECTS): $(GENERATED)
+$(bseprocidl_OBJECTS) $(bsequery_OBJECTS) $(bsetool_OBJECTS): $(GENERATED)
 
 #
 # private (birnet) dependancy to make TAGS file after each build
@@ -357,10 +357,6 @@ noinst_PROGRAMS += bsequery
 bsequery_SOURCES = bsequery.cc
 bsequery_LDADD   = $(progs_LDADD)
 
-noinst_PROGRAMS += bseinfo
-bseinfo_SOURCES  = bseinfo.cc
-bseinfo_LDADD    = $(progs_LDADD)
-
 # == bsetool ==
 noinst_PROGRAMS += bsetool
 bsetool_SOURCES  = bsetool.cc
diff --git a/bse/bsetool.cc b/bse/bsetool.cc
index 70429a7..8a30afe 100644
--- a/bse/bsetool.cc
+++ b/bse/bsetool.cc
@@ -1,11 +1,13 @@
 // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
 #include <bse/bsemain.hh>
 #include <bse/bseserver.hh>
+#include <bse/bsemathsignal.hh>
 #include <sys/resource.h>
 #include <unordered_map>
 #include <unistd.h>
 #include <stdio.h>
 
+
 using namespace Bse;
 
 // == arg parsing ==
@@ -136,6 +138,80 @@ crawl (const ArgParser &ap)
   return "";
 }
 
+// == dump-info ==
+static ArgDescription dump_info_options[] = {
+  { "", "", "", "" }, // dummy, no options currently
+};
+
+#define        PREC_SHIFT      16
+#define        FLF             "26.20"
+
+static String
+dump_info (const ArgParser &ap)
+{
+  auto print_int = [] (const char *name, int integer) {
+    g_print ("%s =%-4d\n", name, integer);
+  };
+  auto print_note = [] (const char *note_name, int note) {
+    char *string = bse_note_to_string (note);
+    g_print ("%s =%-4d \tfactor=%" FLF "f [%-5s] (freq=%" FLF "f)\n",
+             note_name, note,
+             bse_transpose_factor (BSE_MUSICAL_TUNING_12_TET, note - BSE_KAMMER_NOTE),
+             string, bse_note_to_freq (BSE_MUSICAL_TUNING_12_TET, note));
+    g_free (string);
+  };
+  auto print_fine_tune = [] (const char *tune_name, int tune) {
+    g_print ("%s =%-4d \tfactor=%" FLF "f\n",
+             tune_name, tune,
+             bse_cent_tune_fast (tune));
+  };
+  printout ("Rate relevant limits:\n");
+  print_int       ("BSE_MIN_OCTAVE   ", BSE_MIN_OCTAVE);
+  print_int       ("BSE_MAX_OCTAVE   ", BSE_MAX_OCTAVE);
+  print_note      ("BSE_MIN_NOTE     ", BSE_MIN_NOTE);
+  print_note      ("BSE_KAMMER_NOTE  ", BSE_KAMMER_NOTE);
+  print_note      ("BSE_MAX_NOTE     ", BSE_MAX_NOTE);
+  print_note      ("BSE_KAMMER_NOTE-1", BSE_KAMMER_NOTE - 1);
+  print_fine_tune ("BSE_MIN_FINE_TUNE", BSE_MIN_FINE_TUNE);
+  print_fine_tune ("bse-mid-fine-tune", (BSE_MIN_FINE_TUNE + BSE_MAX_FINE_TUNE) / 2);
+  print_fine_tune ("BSE_MAX_FINE_TUNE", BSE_MAX_FINE_TUNE);
+  print_note      ("BSE_KAMMER_NOTE+1", BSE_KAMMER_NOTE + 1);
+
+  int j, k;
+  if (0)
+    for (j = BSE_MIN_NOTE; j <= BSE_MAX_NOTE; j += 3)
+      print_note (":", j);
+  if (0)
+    for (j = BSE_MIN_FINE_TUNE; j <= BSE_MAX_FINE_TUNE; j += 10)
+      print_fine_tune (":", j);
+
+  if (0)
+    for (j = BSE_MIN_NOTE; j <= BSE_MAX_NOTE; j += 3)
+      for (k = BSE_MIN_FINE_TUNE / 2; k <= BSE_MAX_FINE_TUNE / 2; k += 10)
+       {
+         double f, freq = bse_note_to_tuned_freq (BSE_MUSICAL_TUNING_12_TET, j, k);
+         int note, fine_tune;
+         printout ("compose  : note=%4d fine_tune=%4d freq=%" FLF "f\n", j, k, freq);
+         f = freq;
+         note = bse_note_from_freq (BSE_MUSICAL_TUNING_12_TET, freq);
+         fine_tune = bse_note_fine_tune_from_note_freq (BSE_MUSICAL_TUNING_12_TET, note, freq);
+         freq = bse_note_to_tuned_freq (BSE_MUSICAL_TUNING_12_TET, note, fine_tune);
+         g_print ("decompose: note=%4d fine_tune=%4d freq=%" FLF "f   (diff=%g)\n", note, fine_tune, freq, 
freq - f);
+       }
+  if (0)
+    for (j = BSE_MIN_NOTE; j <= BSE_MAX_NOTE; j += 1)
+      {
+       int octave = SFI_NOTE_OCTAVE (j);
+       int semitone = SFI_NOTE_SEMITONE (j);
+       int note = BSE_NOTE_GENERIC (octave, semitone);
+       char *name = bse_note_to_string (j);
+
+       g_print ("note[%3d]: name=%-8s octave=%3d semitone=%3d note=%3d match=%u\n",
+                j, name, octave, semitone, note, j == note);
+       g_free (name);
+      }
+  return "";
+}
 
 // == render2wav ==
 static ArgDescription render2wav_options[] = {
@@ -262,6 +338,23 @@ main (int argc_int, char *argv[])
         }
       return 0; // success
     }
+  else if (option_argc < argc && argv[option_argc] == String ("dump-info"))
+    {
+      ArgParser ap (dump_info_options);
+      String error = ap.parse_args (argc - option_argc - 1, argv + option_argc + 1);
+      if (!error.empty())
+        {
+          printerr ("%s: dump-info: %s\n", argv[0], error);
+          return 127;
+        }
+      error = dump_info (ap);
+      if (!error.empty())
+        {
+          printerr ("dump-info: %s\n", error);
+          return 127;
+        }
+      return 0; // success
+    }
   else if (option_argc < argc && argv[option_argc] == String ("crawl"))
     {
       ArgParser ap (crawl_options);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]