hydrogen-music / hydrogen

The advanced drum machine for Linux, macOS, and Windows
http://www.hydrogen-music.org
GNU General Public License v2.0
1.05k stars 173 forks source link

"Export song" makes 0 byte OGG or FLAC, 44 byte empty WAV #1709

Closed goatygoatgoats closed 1 year ago

goatygoatgoats commented 1 year ago

Hydrogen version * : 1.1.1- [April 12 2022] Operating system + version : Ubuntu 22.04.1 LTS Audio driver + version : Pipewire 0.3.48


When I export my song as OGG or FLAC, I get a 0 byte file. When I try WAV, I get a 44 byte file that doesn't play. When I export, verbose mode says:

(E) ::void H2Core::diskWriterDriver_thread(void) Error during sf_write_float

theGreatWhiteShark commented 1 year ago

Hmm. I can't reproduce it. Maybe there is some audio driver misconfiguration. Are able to hear sound when playing back your patterns?

Also, could you attach the full debug log?

goatygoatgoats commented 1 year ago

Yeah, I hear sound when I play back patterns and songs.

hydrogen.log

theGreatWhiteShark commented 1 year ago

Could you set the verbosity level to Debug? E.g. by starting the application using hydrogen -VDebug > hydrogen.log

goatygoatgoats commented 1 year ago

Hopefully this is right?

hydrogen.log

theGreatWhiteShark commented 1 year ago

Hopefully this is right?

hydrogen.log

Yes, thanks. But nothing suspicious in there.

(E) ::void H2Core::diskWriterDriver_thread(void) Error during sf_write_float

Hmm. I can reproduce this error message when attempting to export the song into a folder I do not have write permissions for. Any chance this is what happens at your end too?

If not, does this error also appear when exporting a blank new song (using the GMRockKit)?

goatygoatgoats commented 1 year ago

No, I'm just trying to export it to my "Documents" folder. Same thing happens with my "Downloads" folder (figured I'd try a different one just in case).

Looks like it does also appear when exporting a blank new song with GMRockKit.

theGreatWhiteShark commented 1 year ago

Hmm. Very strange.

Would be willing to build a debugging version of the application from source? I would patch you one with more debug messages in this part of the code so we hopefully will be able to figure out what is going on

goatygoatgoats commented 1 year ago

Sure, absolutely!

theGreatWhiteShark commented 1 year ago

I put the patch in branch phil-debug-1709

# In the root folder of the cloned repo
git fetch
git checkout phil-debug-1709
./build.sh c mm t
cd build
sudo make install
hydrogen -VDebug > h2.log
goatygoatgoats commented 1 year ago

Okay, after installing a few packages, I've ended up with this error message:

CMake Error at /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message): Could NOT find LIBARCHIVE (missing: LIBARCHIVE_LIBRARIES LIBARCHIVE_INCLUDE_DIRS) Call Stack (most recent call first): /usr/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE) cmake/FindHelper.cmake:47 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) CMakeLists.txt:223 (FIND_HELPER)

I'm not sure if there's something else I need to install? I got by with just looking up the error messages until this point, now I'm not sure where to go next.

I've attached a couple logs in case you need them. CMakeError.log CMakeOutput.log

cme commented 1 year ago

You should be able to get all the prerequisites you need with these lines (from .appveyor.yml)

sudo apt-get update
sudo apt-get install -y clang qt5-default qttools5-dev qttools5-dev-tools libqt5xmlpatterns5-dev libarchive-dev libsndfile1-dev libasound2-dev libjack-jackd2-dev libqt5svg5-dev
sudo apt-get install -y liblo-dev libpulse-dev libportmidi-dev portaudio19-dev libcppunit-dev liblrdf-dev librubberband-dev ladspa-sdk ccache
goatygoatgoats commented 1 year ago

Ok, so I ran into some failures while building:

!!!FAILURES!!! Test Results: Run: 76 Failures: 4 Errors: 0

1) test: FunctionalTest::testExportAudio (F) line: 162 /home/goaty/hydrogen/src/tests/FunctionalTests.cpp Can't open reference file [/home/goaty/hydrogen/src/tests/data//functional/test.ref.flac]

  • File contains data in an unimplemented format.

2) test: FunctionalTest::testExportVelocityAutomationAudio (F) line: 231 /home/goaty/hydrogen/src/tests/FunctionalTests.cpp Can't open reference file [/home/goaty/hydrogen/src/tests/data//functional/velocityautomation.ref.flac]

  • File contains data in an unimplemented format.

3) test: TransportTest::testPlaybackTrack (F) line: 220 /home/goaty/hydrogen/src/tests/TransportTest.cpp Can't open reference file [/home/goaty/hydrogen/src/tests/data//song/res/playbackTrack.flac]

  • File contains data in an unimplemented format.

4) test: TransportTest::testSampleConsistency (F) line: 246 /home/goaty/hydrogen/src/tests/TransportTest.cpp Can't open reference file [/home/goaty/hydrogen/src/tests/data//drumkits/sampleKit/longSample.flac]

  • File contains data in an unimplemented format.

Tests required 18.731s to complete

When I ignore that and try anyway, I still get a 0 byte OGG. I'm not sure what to do to resolve these failures.

hydrogen.log (Hopefully this is the right verbosity?)

Thank you both for your help and patience with this! I'm still fairly new to Linux but I liked Hydrogen a lot on Mac when I used that, so I'm hopeful to get it working.

cme commented 1 year ago

Hmm, libsndfile claims it's failing to open the output file. But it has created some output file for you, so it's failing internally in libsndfile.

So libsndfile should tell us something more useful if you apply this:

diff --git a/src/core/IO/DiskWriterDriver.cpp b/src/core/IO/DiskWriterDriver.cpp
index 3d0344eaa..4f7c44e13 100644
--- a/src/core/IO/DiskWriterDriver.cpp
+++ b/src/core/IO/DiskWriterDriver.cpp
@@ -146,6 +146,7 @@ void* diskWriterDriver_thread( void* param )
                __DEBUGLOG( QString( "File %1 opened" ).arg( pDriver->m_sFilename ) );
        } else {
                __ERRORLOG( QString( "Unable to open file %1" ).arg( pDriver->m_sFilename ) );
+               __ERRORLOG( QString( sf_strerror( nullptr ) ) );
        }

        float *pData = new float[ pDriver->m_nBufferSize * 2 ]; // always stereo

(Sorry, @theGreatWhiteShark , don't mean to step on your toes here!)

goatygoatgoats commented 1 year ago

Sorry, do I just paste that into my terminal while in /hydrogen? Want to make sure I do it right!

theGreatWhiteShark commented 1 year ago

Sorry, do I just paste that into my terminal while in /hydrogen? Want to make sure I do it right!

I patched it for you. You just have to pull the latest code and compile it again.

git pull origin phil-debug-1709
./build.sh mm x

I ran into some failures while building:

That's great. The failures did not happen in the build process itself but in the unit tests executed afterwards. This indicates the bug is caused by something on system-level and not you custom song, drumkit, and preferences.

Could you run the following commands and print their output?

sndinfo --version
find /usr/ -name "libsndfile.so*"

(Hopefully this is the right verbosity?)

Ideally, you could use -VDebug as I added most of the additional log messages on debug level.

Thank you both for your help and patience with this! I'm still fairly new to Linux but I liked Hydrogen a lot on Mac when I used that, so I'm hopeful to get it working.

You are welcome. Thank's for being so responsive and helping use to improve Hydrogen!

Sorry, theGreatWhiteShark , don't mean to step on your toes here!

Don't worry ;)

goatygoatgoats commented 1 year ago

sndinfo --version gives me:

--Csound version 6.17 (double samples) 2022-04-08
[commit: none]
libsndfile-1.0.28
util sndinfo:
--version:
    could not find
end of score.          overall amps:      0.0
       overall samples out of range:        0
0 errors in performance
Elapsed time at end of performance: real: 0.000s, CPU: 0.000s

and find /usr/ -name "libsndfile.so*" gives me:

/usr/local/lib/libsndfile.so
/usr/local/lib/libsndfile.so.1
/usr/lib/i386-linux-gnu/libsndfile.so.1
/usr/lib/i386-linux-gnu/libsndfile.so.1.0.31
/usr/lib/x86_64-linux-gnu/libsndfile.so
/usr/lib/x86_64-linux-gnu/libsndfile.so.1
/usr/lib/x86_64-linux-gnu/libsndfile.so.1.0.31

Here is the debug log (I used -VDebug this time): hydrogen.log

theGreatWhiteShark commented 1 year ago

Hmm. That looks strange. sndinfo - as part of csound-utils - was compiled with version 1.0.28 of libsndfile while 1.0.31 is installed on your system. I would have thought package maintainers of your system would keep them aligned.

In addition, there is a second libsndfile for an older processor architecture. What hardware are you running your linux on? As well as a third libsndfile which seems to be manually installed. Did you do so? Why?

Could you attach the output of the configuration step?

mkdir build2
cd build2
cmake ..

This will tell us which version of libsndfile is used while compiling hydrogen.

goatygoatgoats commented 1 year ago

I'm running on a Lenovo Yoga 920-13IKB laptop, which has an Intel Core i7-8550U and 16 gigs of ram.

Here's the output of cmake: cmake output.txt

I don't really know what I'm looking at here, but this section leads me to believe it's not finding any of the versions I have installed for some reason?

libsndfile : + used  ( /usr/local/lib/libsndfile.so )
libsndfile version must be greater than 1.0.17 to support FLAC and OGG sound file formats. Found version: 

As for why I have multiple versions showing, no clue! I don't remember manually installing it at any point, but it's possible I did and just forgot.

I do see in /usr/local/lib/ that I have these: libsndfile.so, libsndfile.so.1, libsndfile.so.1.0.28

The first two are just links to the third, though, and I don't know why they are set up like that. Not something I did myself, at least knowingly/on purpose. There's also a libsndfile.a and libsndfile.la in there if those are important.

theGreatWhiteShark commented 1 year ago

I'm running on a Lenovo Yoga 920-13IKB laptop, which has an Intel Core i7-8550U and 16 gigs of ram.

Hmm. Quite strange that you have i386 libraries installed. I guess you don't do cross-compiling for such platforms. Maybe there's something mixed up in your repo settings.

Anyway, a possible culprit is the libsndfile.so in /usr/local/lib. Everything that goes in /usr/local/lib is installed by the user herself and takes precedence over things installed by your package manager which ends up in /usr/lib. This alone does not resolve anything as - according to the cmake settings - Hydrogen should work well with libsndfile > 1.0.17. And I just compiled 1.0.28 on my machine and everything works fine.

But maybe your custom/manually installed one is somehow bricked. Could you move all the instances of libsndfile from /usr/local/lib into another folder, like your home, remove the build folder in the hydrogen directory, and compile and run it anew? (and post the output) Maybe things will work once it get's linked to the system's libsndfile. But be warned: some manually installed applications might depend on the files you moved and stop working. So, be sure to just move and not loose them.

goatygoatgoats commented 1 year ago

Here's what I've got: hydrogen build.txt

After building and installing, when I try to run it, I get this:

hydrogen: error while loading shared libraries: libhydrogen-core-1.2.0.so: cannot open shared object file: No such file or directory

I'm worried I've gotten everything all messed up now. Should I delete the hydrogen directory and start over from cloning?

theGreatWhiteShark commented 1 year ago

Hmm... I'm a little bit puzzled about your system's libsndfile as well.

Previously you reported

/usr/lib/x86_64-linux-gnu/libsndfile.so /usr/lib/x86_64-linux-gnu/libsndfile.so.1 /usr/lib/x86_64-linux-gnu/libsndfile.so.1.0.31

Usually, this is all one and the same file and the first two are just links to the third one in order to provide well-known file paths when updating the libsndfile version. But the configuration step finds /usr/lib/x86_64-linux-gnu/libsndfile.so to be of version 1.0.28. That's very odd.

Did you upgrade your Ubuntu system from one major version e.g. 20 to your current one? Unfortunately, this is a very common source of trouble in this Linux flavor.

Could you provide the output of

apt search ^libsndfile

and run

sudo apt-get reinstall libsndfile1-dev

before compiling Hydrogen again?

I'm worried I've gotten everything all messed up now. Should I delete the hydrogen directory and start over from cloning?

Just the build directory

rm -r ./build
./build.sh c mm
cd build
sudo make install
cd ..
./build.sh t x
goatygoatgoats commented 1 year ago

Yeah, I believe I did upgrade from 20 at some point. I followed your steps and it works now! It exports my song just fine!

Here's the output of apt search ^libsndfile if you still need it:

Sorting... Done
Full Text Search... Done
libsndfile1/jammy,now 1.0.31-2build1 amd64 [installed,automatic]
  Library for reading/writing audio files

libsndfile1-dev/jammy,now 1.0.31-2build1 amd64 [installed]
  Development files for libsndfile; a library for reading/writing audio files

Thank you so much for helping me get this working!! I like Hydrogen a lot so I was bummed out at the prospect of not being able to export my stuff, but now it works like a charm!

Edit:

Or, well, it did… Until I closed it and tried to open it again, and now I get the same message as before: hydrogen: error while loading shared libraries: libhydrogen-core-1.2.0.so: cannot open shared object file: No such file or directory

I'll try rebooting and report back.

Edit 2:

Ok, when I run Hydrogen from the hydrogen directory directly (i.e. double click or right click & run) it works just fine. I can hear everything, it exports, etc. When I try to run it from the terminal it doesn't open and I get the same message as before about libhydrogen-core-1.2.0.so. It also doesn't open if I try to run it from my program menu.

Maybe I'm missing a step to make Linux see it? I'm glad it's working either way, though!

theGreatWhiteShark commented 1 year ago

hydrogen: error while loading shared libraries: libhydrogen-core-1.2.0.so: cannot open shared object file: No such file or directory

Looks like your system is confused about different versions of Hydrogen installed. You can clean it up using

sudo apt-get remove hydrogen
sudo rm -f /usr/local/share/hydrogen
sudo rm /usr/local/lib/libhydrogen-core*
sudo rm /usr/local/bin/hydrogen
sudo rm /usr/local/bin/h2cli
sudo rm /usr/local/bin/h2player

Afterwards you can decide whether to use the hydrogen version from you distributions package repos using apt (and get updates for free) or to install the most recent version by building and running sudo make install as before. In case of the second option you have to take care of updating to newer releases yourself.

Either way should work as the problem was with the libsndfile library.

goatygoatgoats commented 1 year ago

Awesome, thank you so much for helping me get this working!! Everything's just fine now! This is why I love FOSS :grin: