projectM-visualizer / frontend-qt

:bangbang: CURRENTLY BROKEN :bangbang: - Will be fixed some time after the libprojectM 4.0 release! Help is highly appreciated. Qt-based standalone frontend to projectM. Currently supports Linux with PulseAudio or JACK audio backends.
GNU Lesser General Public License v2.1
12 stars 5 forks source link

build error: projectm_pcm_add_float_2ch_data #10

Closed tari3x closed 1 year ago

tari3x commented 2 years ago
/home/avatar/local/build/projectm/frontend-qt/src/common/qprojectm_mainwindow.cpp: In member function ‘void QProjectM_MainWindow::addPCM(float*, unsigned int)’:
/home/avatar/local/build/projectm/frontend-qt/src/common/qprojectm_mainwindow.cpp:235:5: error: ‘projectm_pcm_add_float_2ch_data’ was not declared in this scope; did you mean ‘projectm_pcm_add_float’?
  235 |     projectm_pcm_add_float_2ch_data(qprojectM()->instance(), buffer, bufferSize);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |     projectm_pcm_add_float
make[2]: *** [src/common/CMakeFiles/projectM-Qt-Common.dir/build.make:181: src/common/CMakeFiles/projectM-Qt-Common.dir/qprojectm_mainwindow.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:151: src/common/CMakeFiles/projectM-Qt-Common.dir/all] Error 2
tari3x commented 2 years ago

Fixed some further errors and a crash (for some reason loading config from file was failing). Here's the diff

git diff | cat 
diff --git a/src/common/qprojectm.hpp b/src/common/qprojectm.hpp
index 9e284c3..ab68b23 100644
--- a/src/common/qprojectm.hpp
+++ b/src/common/qprojectm.hpp
@@ -30,53 +30,83 @@
 class QProjectM : public QObject
 {

-Q_OBJECT
+  Q_OBJECT

 public:
-    explicit QProjectM(const QString& config_file)
-        : _projectM(projectm_create(config_file.toLocal8Bit().data(), projectm_flags::PROJECTM_FLAG_DISABLE_PLAYLIST_LOAD))
+  explicit QProjectM(const QString& config_file) 
+    : _projectM(projectm_create(NULL, PROJECTM_FLAG_DISABLE_PLAYLIST_LOAD))
+  {
+    if (!_projectM)
     {
-        projectm_set_preset_switched_event_callback(_projectM, &QProjectM::presetSwitchedEvent, this);
-        projectm_set_preset_switch_failed_event_callback(_projectM, &QProjectM::presetSwitchFailedEvent, this);
-        projectm_set_preset_rating_changed_event_callback(_projectM, &QProjectM::presetRatingChanged, this);
+      projectm_settings settings{};
+
+      // Window/rendering settings
+      settings.window_width = 1023;
+      settings.window_height = 1024;
+      settings.fps = 60;
+      settings.mesh_x = 220;
+      settings.mesh_y = 125;
+      settings.aspect_correction = true;
+
+      // Preset display settings
+      settings.preset_duration = 30;
+      settings.soft_cut_duration = 3;
+      settings.hard_cut_enabled = false;
+      settings.hard_cut_duration = 20;
+      settings.hard_cut_sensitivity = 1.0;
+      settings.beat_sensitivity = 1.0;
+      settings.shuffle_enabled = false;
+      // settings.preset_url = &presetPath[0];
+
+      // Unsupported settings
+      // settings.soft_cut_ratings_enabled = false;
+      // settings.menu_font_url = nullptr;
+      // settings.title_font_url = nullptr;
+
+      _projectM = projectm_create_settings(&settings, PROJECTM_FLAG_NONE);
     }

-    projectm* instance() const
-    {
-        return _projectM;
-    }
+    projectm_set_preset_switched_event_callback(_projectM, &QProjectM::presetSwitchedEvent, this);
+    projectm_set_preset_switch_failed_event_callback(_projectM, &QProjectM::presetSwitchFailedEvent, this);
+    projectm_set_preset_rating_changed_event_callback(_projectM, &QProjectM::presetRatingChanged, this);
+  }
+
+  projectm* instance() const
+  {
+    return _projectM;
+  }

 signals:

-    void presetSwitchedSignal(bool hardCut, unsigned int index) const;
+  void presetSwitchedSignal(bool hardCut, unsigned int index) const;

-    void presetSwitchFailedSignal(bool hardCut, unsigned int index, const QString& message) const;
+  void presetSwitchFailedSignal(bool hardCut, unsigned int index, const QString& message) const;

-    void presetRatingChangedSignal(unsigned int index, int rating,
-                                   projectm_preset_rating_type ratingType) const;
+  void presetRatingChangedSignal(unsigned int index, int rating,
+                                 projectm_preset_rating_type ratingType) const;

 protected:

-    static void presetSwitchedEvent(bool hardCut, unsigned int index, void* context)
-    {
-        auto qProjectM = reinterpret_cast<QProjectM*>(context);
-        qProjectM->presetSwitchedSignal(hardCut, index);
-    }
-
-    static void presetSwitchFailedEvent(bool hardCut, unsigned int index, const char* message, void* context)
-    {
-        auto qProjectM = reinterpret_cast<QProjectM*>(context);
-        qProjectM->presetSwitchFailedSignal(hardCut, index, QString(message));
-    }
-
-    static void presetRatingChanged(unsigned int index, int rating,
-                                    projectm_preset_rating_type ratingType, void* context)
-    {
-        auto qProjectM = reinterpret_cast<QProjectM*>(context);
-        qProjectM->presetRatingChangedSignal(index, rating, ratingType);
-    }
-
-    projectm* _projectM{ nullptr };
+  static void presetSwitchedEvent(bool hardCut, unsigned int index, void* context)
+  {
+    auto qProjectM = reinterpret_cast<QProjectM*>(context);
+    qProjectM->presetSwitchedSignal(hardCut, index);
+  }
+
+  static void presetSwitchFailedEvent(bool hardCut, unsigned int index, const char* message, void* context)
+  {
+    auto qProjectM = reinterpret_cast<QProjectM*>(context);
+    qProjectM->presetSwitchFailedSignal(hardCut, index, QString(message));
+  }
+
+  static void presetRatingChanged(unsigned int index, int rating,
+                                  projectm_preset_rating_type ratingType, void* context)
+  {
+    auto qProjectM = reinterpret_cast<QProjectM*>(context);
+    qProjectM->presetRatingChangedSignal(index, rating, ratingType);
+  }
+
+  projectm* _projectM{ nullptr };
 };

 #endif
diff --git a/src/common/qprojectm_mainwindow.cpp b/src/common/qprojectm_mainwindow.cpp
index 44cd591..9bf58d6 100644
--- a/src/common/qprojectm_mainwindow.cpp
+++ b/src/common/qprojectm_mainwindow.cpp
@@ -232,7 +232,7 @@ projectm* QProjectM_MainWindow::GetProjectM()

 void QProjectM_MainWindow::addPCM(float * buffer, unsigned int bufferSize)
 {
-    projectm_pcm_add_float_2ch_data(qprojectM()->instance(), buffer, bufferSize);
+  projectm_pcm_add_float(qprojectM()->instance(), buffer, bufferSize, PROJECTM_STEREO);
 }

 void QProjectM_MainWindow::updatePlaylistSelection ( bool hardCut, unsigned int index )
kbader94 commented 2 years ago

I can confirm these bugs exist, and the patch applied remedies the crash as well, although this patch seems to disable using the config file altogether. @tari3x thanks for your work! Do you have any insight to what's causing the segfault when loading the config file? It'd be nice to be able to properly load the config. I don't quite have time to debug this further this weekend, although I might get to it later this week if you don't beat me to it.

tari3x commented 2 years ago

Didn't dig deeper I'm afraid. Seems like the config format changed and the config reading function doesn't fail gracefully when reading it.

howdood commented 2 years ago

Just to note: this bug still exists when attempting to build from 'main' branch. Any help to build a working version greatly appreciated!

tari3x commented 2 years ago

Fwiw, I ended up using the SDK front-end, works well for me.

howdood commented 2 years ago

Thanks! Unfortunately, although I was able to build the SDK front end on Ubuntu, it segfaults every time I launch it with no further debugging info. The 'new' SDK frontend does not compile at all on R-Pi, although I have been able to complete and install the current build of libprojectM. It looks like the decision to take the two frontends into separate repos has meant that changes to libprojectm that break them do not get noticed in the same way they would if they were part of the main build...

alwzfolwd commented 1 year ago

This may sound like a dumb question, but im having exactly the same issue. how do I implement the patch above?

kblaschke commented 1 year ago

I've merged a few changes, these should fix everything to make the PulseAudio app compile against libprojectM's current master state.

While you can still play around with the application, in its current state it's mostly broken as audio capturing doesn't work properly anymore and then there's still the OpenGL rendering issues after the transition to QOpenGLWindow. So expect presets to look totally broken and unresponsive. For the time being, I recommend using the SDL2 application. It doesn't (yet) have the playlist editing features, but it works flawlessly.

That said, while the Qt app is currently not our development focus, don't expect the core team to fix this application anytime soon. If someone else wants to take this task and help fixing the mentioned issues, please go ahead!

I'm closing the issue for now, but expect more breakages as the libprojectM API will change again in the near future.

tari3x commented 1 year ago

If this front-end basically doesn't work, would it make sense to remove the repo until this is fixed, or at least make it very loud (in the README?) that people should be using the SDL front-end instead? This would save a lot of users a couple of hours of stumbling around.

kblaschke commented 1 year ago

You can't "remove" the repo from GitHub without losing all issues and other associated history, and there's also no way of hiding it, so this is not an option.

Adding it to the README would be an option, but such a note is often not removed when the app is working again, also setting a false flag.

I've added a (hopefully) visible note to the repository description.

revmischa commented 1 year ago

it can be archived as well