]> git.treefish.org Git - seamulator.git/blobdiff - src/seamulator.cpp
Play note on velocity sign change
[seamulator.git] / src / seamulator.cpp
index 5c58ee0f4ab1f40682afc4753abcfabfeaf2ead8..aec8da13377c6053d2a865c84c4b8e31a70a4a89 100644 (file)
@@ -1,3 +1,22 @@
+/**
+ * Copyright (C) 2016  Alexander Schmidt
+ *
+ * This file is part of Seamulator.
+ *
+ * Seamulator is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Seamulator is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Seamulator.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
 #include <ctime>
 #include <cmath>
 #include <iostream>
 #include <ctime>
 #include <cmath>
 #include <iostream>
@@ -8,6 +27,7 @@
 
 #include "sea.h"
 #include "seaview.h"
 
 #include "sea.h"
 #include "seaview.h"
+#include "synthesizer.h"
 #include "watersurface.h"
 
 const int INIT_WINDOW_POS_X{50};
 #include "watersurface.h"
 
 const int INIT_WINDOW_POS_X{50};
@@ -21,6 +41,7 @@ const char WINDOW_TITLE[]{"seamulator"};
 SeaPtr sea;
 WaterSurfacePtr surface;
 std::unique_ptr<SeaView> seaView;
 SeaPtr sea;
 WaterSurfacePtr surface;
 std::unique_ptr<SeaView> seaView;
+std::unique_ptr<Synthesizer> synthesizer;
 
 struct Settings {
   double windSpeed;
 
 struct Settings {
   double windSpeed;
@@ -43,13 +64,14 @@ int main(int argc, char** argv)
 
   std::srand(std::time(0));
   surface = std::make_shared<WaterSurface>(settings.latticeSize,
 
   std::srand(std::time(0));
   surface = std::make_shared<WaterSurface>(settings.latticeSize,
-                                          settings.latticeExtend);
+                                           settings.latticeExtend);
   sea = std::make_shared<Sea>(surface,
   sea = std::make_shared<Sea>(surface,
-                             settings.windSpeed,
-                             settings.amplitudeFactor);
+                              settings.windSpeed,
+                              settings.amplitudeFactor);
   seaView = std::make_unique<SeaView>(settings.latticeExtend * 1.5,
   seaView = std::make_unique<SeaView>(settings.latticeExtend * 1.5,
-                                     INIT_VIEW_AZIMUTH,
-                                     INIT_VIEW_ALTITUDE);
+                                      INIT_VIEW_AZIMUTH,
+                                      INIT_VIEW_ALTITUDE);
+  synthesizer = std::make_unique<Synthesizer>(surface);
 
   glutInit(&argc, argv);
   glutInitDisplayMode(GLUT_DOUBLE);
 
   glutInit(&argc, argv);
   glutInitDisplayMode(GLUT_DOUBLE);
@@ -72,11 +94,11 @@ Settings parseArguments(int argc, char** argv)
 {
   po::options_description desc("Available options");
   desc.add_options()
 {
   po::options_description desc("Available options");
   desc.add_options()
-    ("help,h", "produce help message")
+    ("help,h", "show this help")
     ("windspeed,w", po::value<double>()->default_value(10),
     ("windspeed,w", po::value<double>()->default_value(10),
-     "wind speed given in m/s")
-    ("size,s", po::value<std::string>()->default_value("small"),
-     "lattice size (small/large)")
+     "wind speed (m/s)")
+    ("size,s", po::value<char>()->default_value('s'),
+     "lattice size (s|l)")
     ("amplitude,a", po::value<double>()->default_value(1),
      "amplitude multiplicator")
     ;
     ("amplitude,a", po::value<double>()->default_value(1),
      "amplitude multiplicator")
     ;
@@ -94,7 +116,7 @@ Settings parseArguments(int argc, char** argv)
 
   settings.windSpeed = vm["windspeed"].as<double>();
 
 
   settings.windSpeed = vm["windspeed"].as<double>();
 
-  if (vm["size"].as<std::string>() == "large") {
+  if (vm["size"].as<char>() == 'l') {
     settings.latticeSize = 256;
     settings.latticeExtend = 20;
     settings.amplitudeFactor = vm["amplitude"].as<double>() * 0.00000004;
     settings.latticeSize = 256;
     settings.latticeExtend = 20;
     settings.amplitudeFactor = vm["amplitude"].as<double>() * 0.00000004;
@@ -115,6 +137,7 @@ void glDisplayFunc()
   seaView->setupView();
   sea->update();
   surface->draw();
   seaView->setupView();
   sea->update();
   surface->draw();
+  synthesizer->tick();
 
   glutSwapBuffers();
   glutPostRedisplay();
 
   glutSwapBuffers();
   glutPostRedisplay();