Export soundfile not working

Post Reply
Carotino
Posts: 28
Joined: 08 Apr 2020 20:40

Export soundfile not working

Post by Carotino »

Hi.
I'm running 7.1.89 compiled from AUR.
When I click on Save in the export soundfile dialog, nothing happens.
I have done a little testing and as far as I can tell save() in Qt_soundfilesaver_widget_callbacks.cpp is not even called.

Thanks
kjetil
Site Admin
Posts: 582
Joined: 20 Jul 2017 20:45

Re: Export soundfile not working

Post by kjetil »

Hi, I can't reproduce this. Can you do the following?

1. Start Radium
2. Select File -> Demo songs -> Demo Song
3. Select File -> Export Soundfile(s)
4. Write "/tmp/test.wav" as filename
5. Click save
6. Select Help -> Program debugging -> Show program log
7. Copy and paste the program log here, or take a screen shot.
Also, was a file named "/tmp/test.wav" created? (and in case is it empty?)
yustin
Posts: 9
Joined: 26 Jan 2023 15:06

Re: Export soundfile not working

Post by yustin »

try to set LC_ALL=C and then start radium :D
Carotino
Posts: 28
Joined: 08 Apr 2020 20:40

Re: Export soundfile not working

Post by Carotino »

Hi.
I found the reason.

In Qt_soundfilesaver_widget_callbacks.cpp there is

Code: Select all

if(button->text().contains(QString("Save"))){
to check if the user pressed the Save button. But in my case, the text on the button is localized (in Italian it's "Salva").
So the check fails.

Running radium with

Code: Select all

export LANG=en_EN.UTF8
the check is succesful and the file is correctly exported.

I've done some tests and it's safe to move the callback into accept(), as documented here: https://doc.qt.io/qt-5/qdialogbuttonbox.html.

Code: Select all

void accept() override{

    #if FULL_VERSION==0

      GFX_Message2(NULL,
                   true,
                   "Soundfile export is only available to subscribers.<p>"
                   "Subscribe <a href=\"http://users.notam02.no/~kjetism/radium/download.php\">here</a>."
                   );

#else // FULL_VERSION==0

      printf("SAVE a\n");

      bool save_multi = many_soundfiles->isChecked();

      if (GFX_OS_get_system_out() == NULL) {
        GFX_Message2(NULL, true, "No \"System Out\" instrument found in the mixer.");
        return;
      }

      printf("SAVE b\n");

      if(filename_edit->text()==QString("")){
        GFX_Message2(NULL,
                     true,
                     "%s was not specified.",
                     save_multi ? "Directory" : "Filename"
                    );
        return;
      }

      printf("SAVE c\n");

      const filepath_t filepath = make_filepath(filename_edit->text());

      printf("SAVE d\n");

      if (!save_multi && DISK_file_exists(filepath)){

        if (SAMPLEREADER_has_file(filepath)){
          GFX_Message2(NULL,
                       true,
                       "Can not save to \"%S\" because the file already exists and is currently used in the program.",
                       filepath.id);
          return;
        }

        vector_t options = {};
        int yes = VECTOR_push_back(&options, "Yes");
        VECTOR_push_back(&options, "No");

        if (GFX_Message2(&options,
                         true,
                         "File \%S\" already exists. Overwrite file?",
                         filepath.id
                         )
            !=yes)
          return;
      }

      delete msgBox;
      msgBox = MyQMessageBox::create(false, g_main_window);  // ensure clickedButton()==NULL.


      msgBox->setStandardButtons(QMessageBox::Cancel);

      ATOMIC_SET(_timer.async_message, NULL);

      plugins_to_save.clear(); // In case we were interrupted earlier.

      if (save_multi){

        printf("SAVE sono in save_multi\n");

        QFileInfo info(filename_edit->text());

        if (info.isFile()){
          GFX_Message2(NULL,
                       true,
                       "Can not save. \"%S\" is a file, and not a directory", filepath.id
                       );
          return;
        }

        QDir dir(filename_edit->text());
        QString dirname = dir.absolutePath();

        if (dir.exists()){
          vector_t options = {};
          VECTOR_push_back(&options, "Yes");
          VECTOR_push_back(&options, "No");

          if (GFX_Message2(&options,
                           true,
                           "Directory \%S\" already exists. Overwrite files in that directory?",
                           STRING_create(dirname.toUtf8().constData())
                           )
              ==1)
            return;
        } else {

          if(QDir::root().mkpath(dirname)==false){ // why on earth isn't mkpath a static function?
            GFX_Message2(NULL, true, "Unable to create directory \"%S\".", STRING_create(dirname));
            return;
          }

        }

        const radium::Vector<SoundProducer*> &sp_all = MIXER_get_all_SoundProducers();
        for (auto sp : sp_all){
          SoundPlugin *plugin = SP_get_plugin(sp);

          if (!SP_has_input_links(sp) && SP_has_output_links(sp) && !SP_is_bus(sp) && strcmp(plugin->type->type_name, "Pipe")){
            bool doit = true;

            if (!strcmp(plugin->type->name, g_click_name) && !strcmp("Sample Player", plugin->type->type_name))
              doit = metronomeEnabled();

            if (doit)
              plugins_to_save.push_back(plugin);
          }
        }

        safeShow(msgBox);

        save_next();

        printf("SAVE fine save multi\n");

      } else {

        printf("SAVE sono save singolo\n");
        safeShow(msgBox);

        printf("SAVE singolo A\n");

        save(filename_edit->text());

        printf("SAVE singolo fine\n");

      }

      close();

#endif //FULL_VERSION==0

  }
 
Carotino
Posts: 28
Joined: 08 Apr 2020 20:40

Re: Export soundfile not working

Post by Carotino »

yustin wrote: 22 Apr 2023 21:13 try to set LC_ALL=C and then start radium :D
You beat me by some minutes, I was preparing the answer ;)
yustin
Posts: 9
Joined: 26 Jan 2023 15:06

Re: Export soundfile not working

Post by yustin »

Create a patch and update the PKGBUILD !
;)
kjetil
Site Admin
Posts: 582
Joined: 20 Jul 2017 20:45

Re: Export soundfile not working

Post by kjetil »

That's strange. QLocale::setDefault(QLocale::C); is called at program startup. I thought that should prevent translations.
yustin
Posts: 9
Joined: 26 Jan 2023 15:06

Re: Export soundfile not working

Post by yustin »

https://doc.qt.io/qt-5/qlocale.html#setDefault
"Warning: In a multithreaded application, the default locale should be set at application startup, before any non-GUI threads are created."
Maybe you have to set it earlier ....
Carotino
Posts: 28
Joined: 08 Apr 2020 20:40

Re: Export soundfile not working

Post by Carotino »

yustin wrote: 22 Apr 2023 22:06 Create a patch and update the PKGBUILD !
;)
That could be done (as soon as I learn how to do it...), but I think this better be fixed upstream
kjetil
Site Admin
Posts: 582
Joined: 20 Jul 2017 20:45

Re: Export soundfile not working

Post by kjetil »

yustin wrote: 23 Apr 2023 08:49 https://doc.qt.io/qt-5/qlocale.html#setDefault
"Warning: In a multithreaded application, the default locale should be set at application startup, before any non-GUI threads are created."
Maybe you have to set it earlier ....
It's set before the QApplication instance is created, so I don't think so, but you never know. There might have been some threads started first, but not threads used by Qt.
Carotino wrote: That could be done (as soon as I learn how to do it...), but I think this better be fixed upstream
Yes, I'll fix it upstream. Thanks for figuring out the problem.
Post Reply