hydrogen-music / hydrogen

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

export to wave adds long dead time ! #1853

Closed fhenryco closed 10 months ago

fhenryco commented 11 months ago

Hydrogen version * :1.2.0 Operating system + version : Mageia 9 Audio driver + version : pipewire on pulseaudio


My distribution (mageia) upgrade came with version 1.2.0 of hydrogen and (apparently) a new bug when exporting to a wave file: it adds a dead time (several measures) at the end so the wave file is not anymore the song i can hear in hydrogen and i cant use it as a loop! For instance it is twice longer than it should in the attached wave file. Got the same behaviour with 1.2.2 Appimage ! Got the issue even with default song opening in Hydrogen (so not mine)

theGreatWhiteShark commented 11 months ago

Hey @fhenryco ,

Hydrogen versions prior to 1.2.0 had a bug due to which samples did not ring out but were cut at the end of the song. This has been fixed and local testing (using the sample you uploaded on SourceForge) did not showed anything strange.

Could it be that you are working with long samples and the dead time you are referring to is your samples fading out?

You can make Hydrogen cut the samples at the end of a pattern yourself by manually setting the length of a note (right click and dragging to the right) to the very end of the pattern.

fhenryco commented 11 months ago

I get exactly the same issue with samples from the default hydrogen drum kit: i can reproduce the problem with just floor tom and Stick from GMRockit. But you are right that this must be related to the sample length even in this case because if i do what you say (make Hydrogen cut the samples at the end of a pattern myself by manually setting the length of the notes) then the wave file generated stops where it should i.e. exactly at the end of the pattern.

so are you saying that i need to do that for the dozen of notes i typically have in a pattern ??!! : see the difference between my two screen shots : only a few notes and it's already getting ugly:

Screenshot_20231002_193018 Screenshot_20231002_195239

In the old version of Hydrogen i did not have to set where the notes was finishing , and the wave i obtained were perfect for a loop, as if somehow the export wave tool was performing a cyclic continuation of the notes at the end to the begining of the pattern : at the end i could hear exactly the samething when playing the pattern in loop within hydrogen and playing the generated wave file in loop.

Or did i miss something ?

theGreatWhiteShark commented 11 months ago

so are you saying that i need to do that for the dozen of notes i typically have in a pattern ??!! : see the difference between my two screen shots : only a few notes and it's already getting ugly:

There are two things you can do here:

  1. check the "Auto-Stop Note" feature in the instrument editor for your instruments. This immediately stops sample rendering as soon as the same sample is triggered again. Now, you only have to set the length of the last note. But this will also affect the sound in a bad way as there are no overlaps anymore
  2. use a stop note. It took me some time to realize how it's done because there is, unfortunately, a bug in the current release rendering the stop notes like regular ones (I'll fix it). But using Shift + left click you can add a note which stops all playback of the associated instrument.

Or did i miss something ?

The previous version did not loop back audio to the beginning of the song but just cut the sample prematurely.

Why is the current export not working properly for loops. Hydrogen tells you the exact time a pattern ends by moving the playhead to the adjacent pattern while playback is stopped. Just click the ruler below the timeline and you will get e.g. 6.486s for four patterns and 148 bpm. This information you can use in an external tool to customize the loop range.

On the other hand, one does not need strange workarounds anymore, like an extra long final pattern containing only the final note at the very beginning.

fhenryco commented 11 months ago

It must be something else because now even after adding stop notes at the end of the pattern: Screenshot_20231002_210811

the wave file has a much longer duration than expected. you can download the wave file here: https://www.grosfichiers.com/pZjVwGXxnvu the pattern is repeated twice in the song that is exported to wave so that you can hear in the wave where it should normally stop, but does not!

fhenryco commented 11 months ago

Thank you , we probably posted almost at the same time as i did not notice your last post before posting myself

theGreatWhiteShark commented 11 months ago

Do the two options I suggested work for your purposes or are there still some open points?

cme commented 11 months ago

I guess it sounds like we need a "Export sample for loop" option that intentionally chops the export at the end of the last pattern?

fhenryco commented 11 months ago

Thank you for your effort but as you can see in my last screenshot, i tried the stop notes (which are not blue but rather a little bit smaller black dots) on all instruments and yet the end of the wave file is still much beyond the stop note. I had also the auto-stop activated from the begining. So the most usefull of your proposed solution is the accurate determination of the time at the end of the pattern which i was able to successfully and quite easily apply in my daw (bitwig) to limit the clip in time so that the behaviour of the loop is All right. But for sure the "export sample for loop" option would be great !

theGreatWhiteShark commented 11 months ago

i tried the stop notes (which are not blue but rather a little bit smaller black dots)

oh dear! Seems like I put the wrong default value. The color of the stop notes can be set in Options > Preferences > Appearance > Colors > Pattern Editor > Note Off. You can pick any color to improve their visibility. I just happen to set their default color to black too.

on all instruments and yet the end of the wave file is still much beyond the stop note

Hmm. I can not reproduce this behavior. Could you attach the song?

I guess it sounds like we need a "Export sample for loop" option that intentionally chops the export at the end of the last pattern?

I like that idea. It somewhat reproduces the behavior of former versions and might be quite helpful when working with simple audio players instead of proper DAWs. But then it should work as expected by @fhenryco: the fade out should be added to the beginning of the song. This way looping the export in a media player will sound exactly like looping a song/pattern within Hydrogen.

fhenryco commented 11 months ago

You can download the .h2song here https://www.grosfichiers.com/yJDRTa9kgy3

theGreatWhiteShark commented 11 months ago

You can download the .h2song here https://www.grosfichiers.com/yJDRTa9kgy3

Thanks a lot! NoteOff handling is indeed not working properly (when using it for more than one instrument). I'll address this in a different issue

theGreatWhiteShark commented 11 months ago

You can download the .h2song here https://www.grosfichiers.com/yJDRTa9kgy3

I had a look at your song and it is more or less a rendering issue. Pattern "Tiriba" too short. The NoteOff notes you added at the end are not properly picked up by Hydrogen. Just increase the song a tiny amount, say Size 3.1/4.0, and the song should stop properly

fhenryco commented 11 months ago

Thank you. So i will probably double such patterns in the future : 6/4

theGreatWhiteShark commented 11 months ago

Thank you. So i will probably double such patterns in the future : 6/4

No, you don't have to. The slight increase of the pattern length is just a temporary workaround. The NoteOff notes not being picked up correctly is a bug and we are working on a fix. It will be part of version 1.2.3 of Hydrogen and I post an updated AppImage here as soon as the fixes are ready.

theGreatWhiteShark commented 11 months ago

@fhenryco could you check whether this AppImage fixes your issues with the stop notes?

fhenryco commented 11 months ago

Thought an AppImage was fully portable yet running it i get the message GLIBCXX_3.4.26 not found

theGreatWhiteShark commented 11 months ago

Thought an AppImage was fully portable yet running it i get the message GLIBCXX_3.4.26 not found

No, they aren't. When built on a pretty old Linux distribution they should run on most recent distributions using the same compiler (due to the forward compatibilty of gcc and clang). It's not perfect but it is already a lot.

Hmm. But I thought the 1.2.2 AppImage did run on your system. Then it's quite strange for the one linked above not to work.

I just took a look inside and compared it with the latest release AppImage. Both binaries and their associated libraries seem to require the same GLIBCXX version and 3.4.26 was required by the last release too.

To reproduce

./Hydrogen-1.2.2-x86_64.AppImage --appimage-extract
objdump -x squashfs-root/usr/lib/libhydrogen-core-1.2.2.so | grep GLIBCXX
fhenryco commented 11 months ago

The explanation is that i never run experimental things on my working distro. here i used a debian 9 VM (i already had available) as a sandbox. I'll try on a more recent VM distro as soon as possible.

fhenryco commented 11 months ago

testing it in a newly created VM, it cannot find my samples which are custom wave sounds and not from any library. How can i tell H2 the directory of my wave sounds so it can load them with the .h2song file ? (it was some work to initially load each sound as a new instrument, can i avoid this?)

fhenryco commented 11 months ago

and the new created instruments were not created as part of a drumkit. If now i want to create a drumkit i need to load a new one and this is replacing my own instruments .... so i apparently cant save my instruments as part of a new drumkit

theGreatWhiteShark commented 11 months ago

it cannot find my samples which are custom wave sounds and not from any library. How can i tell H2 the directory of my wave sounds so it can load them with the .h2song file ?

For samples in .h2song files you have basically two options for loading them:

  1. When loading a drumkit or drag/drop instruments from other drumkits into your song the samples are taken from these drumkit folders. They are referenced in the .h2song file using the name and path of the drumkit and the plain filename of the sample.
  2. When loading samples via the instrument editor Hydrogen assumes these are not part of the installed drumkits and stores absolute paths to the sample in the .h2song.

So, you can either put all your freshly added samples into drumkit using Drumkits > Save or Drumkits > Save As or ensure Hydrogen can find them at the same absolute paths.

If now i want to create a drumkit i need to load a new one and this is replacing my own instruments .... so i apparently cant save my instruments as part of a new drumkit

When pressing Drumkits > Save the current instruments of your song replace the once in the last loaded drumkit. When using Drumkits > Save As you can create a fresh kit without overwriting the one you loaded.

fhenryco commented 11 months ago

I tested successfully the Appimage in my sand box: the stop notes now work as expected.

My problem with Drumkits > Save As is that i get the following message :

The drum kit entered in the current song is not on the disc. Please load an existing drum kit first. Current kit: []

but loading an existing drumkit will overwrite my instruments. may be the solution would be to load an almost empty drumkit ...(?)

theGreatWhiteShark commented 11 months ago

I tested successfully the Appimage in my sand box: the stop notes now work as expected.

Great!

My problem with Drumkits > Save As is that i get the following message :

The drum kit entered in the current song is not on the disc. Please load an existing drum kit first. Current kit: []

but loading an existing drumkit will overwrite my instruments. may be the solution would be to load an almost empty drumkit ...(?)

Damn it. Having just the instruments of the loaded kit but not most of its metadata stored in a .h2song already caused a number of issues. A legacy design decision and actually the thing I'm working on right now for the 1.3.0 release (#1849).

Sorry for all the trouble and thanks for reporting back all those bugs!

I prepared you yet another AppImage using which you should be able to save the drumkit.

fhenryco commented 11 months ago

thanks: with the last appimage i could save my drumkit

theGreatWhiteShark commented 11 months ago

Awesome. Are there still open points or can we close here? I would transfer the "export for looping" feature into a dedicated issue

fhenryco commented 11 months ago

Thanks, please let me know if something comes out for the "export for looping" feature. I'm currently looking for a jazz complete song template allowing few adaptations and variations to apply to a Jazz standard using brushes such as https://www.youtube.com/watch?v=iRT8mbRWV9k. I already have loaded a good drumkit with brushes and want to see if i can save time writting myself the complete song...i also had a look at the forum but may be not at the right place...

theGreatWhiteShark commented 10 months ago

Thanks, please let me know if something comes out for the "export for looping" feature.

Alright. How about you create the issue? This way you get email notifications when we start working on it. (But that will probably take quite a while. There is already a long list of stuff we committed to implementing first)

I already have loaded a good drumkit with brushes and want to see if i can save time writing myself the complete song...i also had a look at the forum but may be not at the right place...

When Hydrogen was started over 20 years ago it wasn't designed to allow seamless switching of drumkits. For most kits, whenever you load a them, you have to adjust the patterns in order for the notes of e.g. a kick still belonging to a kit. That's why patterns/songs are somewhat tied to a drumkit and there is no online repo containing various patterns and songs I'm aware of.

But I intend to integrate this seamless switching in version 1.3. So, maybe there will be such an online repo at some point in the future

fhenryco commented 10 months ago

It's not that i already have a song working with a drumkit and want to switch for another drumkit. It's just that i have no song at all. I thought somebody would have already written template songs and made them available in a repo so that others can only modify and adapt them to other similar songs in the same style...

theGreatWhiteShark commented 10 months ago

Maybe this get's you started https://github.com/hydrogen-music/Song-and-pattern-repository