~ubuntu-branches/ubuntu/vivid/soundscaperenderer/vivid-proposed

« back to all changes in this revision

Viewing changes to src/configuration.cpp

  • Committer: Package Import Robot
  • Author(s): IOhannes m zmölnig (Debian/GNU)
  • Date: 2014-09-01 11:35:32 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140901113532-svjohhyw755nkxef
Tags: 0.4.2~dfsg-1
* Imported Upstream version 0.4.2~dfsg

* Refreshed patches.
* Removed patches applied upstream.
* Install upstream's NEWS as changelog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#ifdef HAVE_CONFIG_H
31
31
#include <config.h> // for ENABLE_*, HAVE_*, WITH_*
32
32
#endif
 
33
#ifdef ENABLE_ISATTY
 
34
#include <unistd.h>
 
35
#endif
33
36
 
34
37
#include <cassert>      // for assert()
35
38
#include <getopt.h>     // for getopt_long()
55
58
  /// show version and compiled-in features
56
59
  void print_version_details()
57
60
  {
58
 
    std::cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
59
 
      " It's ... " << std::flush;
60
 
    if(isatty(1))
61
 
    sleep(3);
62
 
    std::cout <<
63
 
      "the " PACKAGE_NAME
 
61
#ifdef ENABLE_ISATTY
 
62
    if (isatty(1))
 
63
#endif
 
64
    {
 
65
      std::cout << "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
 
66
        "It's ... " << std::flush;
 
67
      sleep(3);
 
68
      std::cout << "the ";
 
69
    }
 
70
    std::cout << PACKAGE_STRING "\n" SSR_COPYRIGHT << std::endl;
 
71
#ifdef ENABLE_ISATTY
 
72
    if (isatty(1))
 
73
    {
 
74
      std::cout << "\nFollowing compile-time features are activated: |"
64
75
#ifndef NDEBUG
65
 
      ", compiled in debug mode!"
 
76
        "debug mode|"
66
77
#endif
67
 
      "\n              version " PACKAGE_VERSION
68
 
      "\n Following compile-time features are activated:\n"
69
 
      " new renderer"
70
78
#ifdef ENABLE_GUI
71
 
      ", GUI"
 
79
        "GUI|"
72
80
#endif
73
81
#ifdef ENABLE_IP_INTERFACE
74
 
      ", IP interface"
 
82
        "IP interface|"
75
83
#endif
76
84
#ifdef ENABLE_INTERSENSE
77
 
      ", InterSense "
 
85
        "InterSense "
78
86
#ifdef HAVE_INTERSENSE_404
79
 
      "(>= v4.04)"
 
87
        "(>= v4.04)|"
80
88
#else
81
 
      "(< v4.04)"
 
89
        "(< v4.04)|"
82
90
#endif
83
91
#endif // ENABLE_INTERSENSE
84
92
#ifdef ENABLE_POLHEMUS
85
 
      ", Polhemus"
 
93
        "Polhemus|"
86
94
#endif
87
95
#ifdef ENABLE_VRPN
88
 
      ", VRPN"
 
96
        "VRPN|"
89
97
#endif
90
98
#ifdef ENABLE_RAZOR
91
 
      ", Razor AHRS"
 
99
        "Razor AHRS|"
92
100
#endif
93
101
#ifdef ENABLE_ECASOUND
94
 
      ", Ecasound"
95
 
#endif
96
 
      "\n\n"
97
 
      SSR_AUTHORS
98
 
      "\n\n";
 
102
        "Ecasound|"
 
103
#endif
 
104
        "\n";
 
105
    }
 
106
#endif
 
107
    std::cout << "\n" SSR_AUTHORS "\n\n";
99
108
  }
100
109
}
101
110
 
114
123
 
115
124
  conf_struct conf;
116
125
 
117
 
  // borrowed from ardour sources: cut path from program name
118
 
  auto exec_name = strrchr(argv[0], '/');
119
 
  if (exec_name == nullptr) exec_name = argv[0]; else exec_name++;
120
 
  conf.exec_name = exec_name;
121
 
 
122
126
#ifndef NDEBUG
123
127
  // Because of this warning, "make check" fails for debug builds (on purpose).
124
 
  WARNING(conf.exec_name << " was compiled for debugging!");
 
128
  WARNING(argv[0] << " was compiled for debugging!");
125
129
#endif
126
130
 
127
131
  // hard coded default values:
128
 
  conf.stand_ampl_ref_dist = 3.0f; // meters
129
132
#ifdef ENABLE_GUI
130
133
  conf.gui = true;
131
134
#else
144
147
      , SSR_DATA_DIR"/default_setup.asd");
145
148
  conf.xml_schema = SSR_DATA_DIR"/asdf.xsd";
146
149
  conf.audio_recorder_file_name = ""; // default: no recording
147
 
  conf.renderer_params.set("threads", 1);  // TODO: obtain reasonable default
148
150
 
149
151
  conf.input_port_prefix = "system:capture_";
150
152
  conf.output_port_prefix = "system:playback_";
151
153
  conf.path_to_gui_images = SSR_DATA_DIR"/images";
152
154
  conf.path_to_scene_menu = "./scene_menu.conf";
153
155
 
 
156
  conf.renderer_params.set("amplitude_reference_distance", 3);  // meters
 
157
 
154
158
  // for WFS renderer
155
159
  conf.renderer_params.set("prefilter_file"
156
160
      , SSR_DATA_DIR"/default_wfs_prefilter.wav");
185
189
  load_config_file(filename.c_str(),conf);
186
190
 
187
191
  const std::string usage_string =
188
 
"\nUSAGE: " + conf.exec_name + " [OPTIONS] <scene-file>"
189
 
#ifdef ENABLE_GUI
190
 
//" [-- <GUI options>]"
191
 
#endif
192
 
"\n";
 
192
"Usage: " + std::string(argv[0]) + " [OPTIONS] <scene-file>\n";
193
193
 
194
194
  const std::string help_string =
195
195
"\nThe SoundScape Renderer (SSR) is a tool for real-time "
196
196
"spatial audio reproduction\n"
197
197
"providing a variety of rendering algorithms.\n"
198
198
"\n"
199
 
"OPTIONS:\n"
200
 
"\n"
 
199
"Options:\n\n"
201
200
"Renderer-specific options:\n"
202
 
"    --hrirs=FILE       Load the HRIRs for binaural renderer from FILE\n"
203
 
"    --hrir-size=VALUE  Maximum IR length (binaural and BRS renderer)\n"
204
 
"    --prefilter=FILE   Load WFS prefilter from FILE\n"
205
 
"-o, --ambisonics-order=VALUE Ambisonics order to use (default: maximum)\n"
206
 
"    --in-phase-rendering     Use in-phase rendering for Ambisonics\n"
 
201
"      --hrirs=FILE    Load HRIRs for binaural renderer from FILE\n"
 
202
"      --hrir-size=N   Truncate HRIRs to length N\n"
 
203
"      --prefilter=FILE\n"
 
204
"                      Load WFS prefilter from FILE\n"
 
205
"  -o, --ambisonics-order=VALUE\n"
 
206
"                      Ambisonics order to use for AAP (default: maximum)\n"
 
207
"      --in-phase-rendering\n"
 
208
"                      Use in-phase rendering for AAP renderer\n"
207
209
"\n"
208
210
"JACK options:\n"
209
 
"-n, --name=NAME        Set JACK client name to NAME\n"
210
 
"    --input-prefix=PREFIX    Input  port prefix "
211
 
                                              "(default: \"system:capture_\")\n"
212
 
"    --output-prefix=PREFIX   Output port prefix "
213
 
                                             "(default: \"system:playback_\")\n"
214
 
"-f, --freewheel        Use JACK in freewheeling mode\n"
 
211
"  -n, --name=NAME     Set JACK client name to NAME\n"
 
212
"      --input-prefix=PREFIX\n"
 
213
"                      Input port prefix (default: \"system:capture_\")\n"
 
214
"      --output-prefix=PREFIX\n"
 
215
"                      Output port prefix (default: \"system:playback_\")\n"
 
216
"  -f, --freewheel     Use JACK in freewheeling mode\n"
215
217
"\n"
216
218
"General options:\n"
217
 
"-c, --config=FILE      Read configuration from FILE\n"
218
 
"-s, --setup=FILE       Load reproduction setup from FILE\n"
219
 
"    --threads=N        Number of audio threads (default N=1)\n"
220
 
"-r, --record=FILE      Record the audio output of the renderer to FILE\n"
 
219
"  -c, --config=FILE   Read configuration from FILE\n"
 
220
"  -s, --setup=FILE    Load reproduction setup from FILE\n"
 
221
"      --threads=N     Number of audio threads (default: auto)\n"
 
222
"  -r, --record=FILE   Record the audio output of the renderer to FILE\n"
221
223
#ifndef ENABLE_ECASOUND
222
 
"                       (disabled at compile time!)\n"
 
224
"                      (disabled at compile time!)\n"
223
225
#endif
224
226
// TODO: --loop is a temporary option, should rather be done in scene file
225
 
"    --loop             Loop all audio files\n"
226
 
"    --master-volume-correction=VALUE\n"
227
 
"                       Correction of the master volume in dB "
 
227
"      --loop          Loop all audio files\n"
 
228
"      --master-volume-correction=VALUE\n"
 
229
"                      Correction of the master volume in dB "
228
230
                                                         "(default: 0 dB)\n"
229
231
#ifdef ENABLE_IP_INTERFACE
230
 
"-i, --ip-server[=PORT] Start IP server (default on)\n"
231
 
"                       A port can be specified: --ip-server=5555\n"
232
 
"-I, --no-ip-server     Don't start IP server\n"
 
232
"  -i, --ip-server[=PORT]\n"
 
233
"                      Start IP server (default on),\n"
 
234
"                      a port number can be specified (default 4711)\n"
 
235
"  -I, --no-ip-server  Don't start IP server\n"
233
236
#else
234
 
"-i, --ip-server        Start IP server (not enabled at compile time!)\n"
235
 
"-I, --no-ip-server     Don't start IP server (default)\n"
 
237
"  -i, --ip-server     Start IP server (not enabled at compile time!)\n"
 
238
"  -I, --no-ip-server  Don't start IP server (default)\n"
236
239
#endif
237
 
#ifdef ENABLE_GUI       
238
 
"-g, --gui              Start GUI (default)\n"
239
 
"-G, --no-gui           Don't start GUI\n"
 
240
#ifdef ENABLE_GUI      
 
241
"  -g, --gui           Start GUI (default)\n"
 
242
"  -G, --no-gui        Don't start GUI\n"
240
243
#else
241
 
"-g, --gui              Start GUI (not enabled at compile time!)\n"
242
 
"-G, --no-gui           Don't start GUI (default)\n"
 
244
"  -g, --gui           Start GUI (not enabled at compile time!)\n"
 
245
"  -G, --no-gui        Don't start GUI (default)\n"
243
246
#endif
244
247
#if defined(ENABLE_INTERSENSE) || defined(ENABLE_POLHEMUS) || defined(ENABLE_VRPN) || defined(ENABLE_RAZOR)
245
 
"-t, --tracker=TYPE     Start tracker, possible value(s):"
 
248
"  -t, --tracker=TYPE  Select head tracker, possible value(s):\n"
 
249
"                     "
246
250
#if defined(ENABLE_POLHEMUS)
247
251
" polhemus"
248
252
#endif
256
260
" razor"
257
261
#endif
258
262
"\n"
259
 
"    --tracker-port=PORT\n"
260
 
"                       A serial port can be specified, e.g. /dev/ttyS1\n"
 
263
"      --tracker-port=PORT\n"
 
264
"                      Port name/number of head tracker, e.g. /dev/ttyS1\n"
261
265
#else
262
 
"-t, --tracker          Start tracker (not enabled at compile time!)\n"
 
266
"  -t, --tracker       Select tracker (not enabled at compile time!)\n"
263
267
#endif
264
 
"-T, --no-tracker       Don't start tracker (default)\n"
265
 
"\n"
266
 
"-h, --help             Show this very help information. "
267
 
                                                     "You just typed that!\n"
268
 
"-v, --verbose          Increase verbosity level (up to -vvv)\n"
269
 
"-V, --version          Show version information and exit\n"
270
 
"\n"
 
268
"  -T, --no-tracker    Don't use a head tracker (default)\n"
 
269
"\n"
 
270
"  -h, --help          Show help and exit\n"
 
271
"  -v, --verbose       Increase verbosity level (up to -vvv)\n"
 
272
"  -V, --version       Show version information and exit\n"
271
273
 
272
274
#ifdef ENABLE_GUI
273
275
//"\n"
276
278
//"\n"
277
279
//" --               All arguments after \"--\" are ignored.\n"
278
280
#endif
 
281
"\n"
 
282
"Report bugs to: <" PACKAGE_BUGREPORT ">\n"
 
283
"SSR home page: <" PACKAGE_URL ">\n"
279
284
;
280
285
 
281
286
  // the special argument "--" forces the end of option scanning
469
474
        // here we deal with unknown/invalid options
470
475
        // getopt() already prints an error message for unknown options
471
476
        std::cout << usage_string;
472
 
        std::cout << "Type '" << conf.exec_name << " --help' "
 
477
        std::cout << "Type '" << argv[0] << " --help' "
473
478
          "for more information.\n\n";
474
479
        exit(EXIT_FAILURE);
475
480
        break;
495
500
    conf.renderer_params.set("system_output_prefix", conf.output_port_prefix);
496
501
  }
497
502
 
 
503
  VERBOSE2("Requested renderer settings:");
 
504
  for (const auto& entry: conf.renderer_params)
 
505
  {
 
506
    VERBOSE2(entry.first << " = " << entry.second);
 
507
  }
 
508
 
498
509
  return conf;
499
510
}
500
511
 
631
642
    {
632
643
      conf.renderer_params.set("name", value);
633
644
    }
634
 
    else if (!strcmp(key, "NUMBER_OF_THREADS"))
 
645
    else if (!strcmp(key, "NUMBER_OF_THREADS") || !strcmp(key, "THREADS"))
635
646
    {
636
647
      conf.renderer_params.set("threads", value);
637
648
    }
641
652
    }
642
653
    else if (!strcmp(key, "STANDARD_AMPLITUDE_REFERENCE_DISTANCE"))
643
654
    {
644
 
      conf.stand_ampl_ref_dist = atof(value);
 
655
      conf.renderer_params.set("amplitude_reference_distance", value);
645
656
    }
646
657
    else if (!strcmp(key, "SCENE_FILE_NAME"))
647
658
    {
756
767
    {
757
768
      conf.tracker_ports = value;
758
769
    }
 
770
    else if (!strcmp(key, "LOOP"))
 
771
    {
 
772
      if (!strcasecmp(value, "yes")) conf.loop = true;
 
773
      else conf.loop = false;
 
774
    }
759
775
    else
760
776
    {
761
777
      printf("%s:%u unknown option \"%s\"\n",filename, line_number, key);