Author Topic: Play inserted silence between tracks?  (Read 5343 times)

Dowlphin

  • Posts: 28
Play inserted silence between tracks?
« on: 7 Nov '21 - 05:54 »
I cannot find such an option, but it would be really useful. Can XMPlay not insert a certain amount of silence between tracks when playing them?
Ideally even a fixed total one that incorporates any silence that might exist in the tracks themselves.
AFAIR this has even been an integral feature of CD players back then, and/or maybe the CDs themselves.
The closest functionality I found is "Trim ending silence" in the MOD playback settings, so that is an ability to detect silence in tracks. Something to build on for what I am looking for.

Ian @ un4seen

  • Administrator
  • Posts: 26172
Re: Play inserted silence between tracks?
« Reply #1 on: 8 Nov '21 - 17:58 »
XMPlay doesn't currently have that option. It may be possible to add it but finding a suitable space for it in the options window could be an issue. If you don't mind it always being applied (at least until XMPlay is restarted) then it could perhaps be added as just an XMPLAY.INI file setting.

Dowlphin

  • Posts: 28
Re: Play inserted silence between tracks?
« Reply #2 on: 8 Nov '21 - 20:53 »
I guess with making the ini read-only that could work. Although that could cause other issues if I forget about that and want to change settings.
I think I can manage for now. It was just one new track I added that made me aware of this and I made a version with added silence now.

Ian @ un4seen

  • Administrator
  • Posts: 26172
Re: Play inserted silence between tracks?
« Reply #3 on: 9 Nov '21 - 16:18 »
Just to clarify, when I said "If you don't mind it always being applied (at least until XMPlay is restarted)", I meant that you wouldn't be able to change the setting until restarting XMPlay because that's when the XMPLAY.INI file is read. The setting wouldn't change by itself, so you wouldn't need to write-protect the XMPLAY.INI file.

Dowlphin

  • Posts: 28
Re: Play inserted silence between tracks?
« Reply #4 on: 9 Nov '21 - 21:31 »
Ah, that sounds good then.
No hurry, though. Just if you, too, think it is a good feature to add.

Because I also just thought that this could open up further questions: How to handle this for loop play? Should it always assume seamless loops like for MODs? Or offer options specifically for such behavior?

brycco

  • Posts: 41
Re: Play inserted silence between tracks?
« Reply #5 on: 19 Nov '21 - 09:15 »
Why do you want silence? Nostalgia? Do you want vinyl noise as well? ;D

Genuinely curious. XMPlay already has fading and crossfading, so gentle transitions can be done.

It was originally a technical limitation in the first CD players, intended for being able to differentiate between tracks. And on vinyl, it was just there to make it clear when moving the needle, to place it before a new song started.

Dowlphin

  • Posts: 28
Re: Play inserted silence between tracks?
« Reply #6 on: 19 Nov '21 - 09:54 »
It was originally a technical limitation in the first CD players, intended for being able to differentiate between tracks. And on vinyl, it was just there to make it clear when moving the needle, to place it before a new song started.
That seems to make little sense. It is a digital medium. The player can read a TOC and start/end marks if needed.
I mean, I remember issues with old methods of audio extraction in regards to bit accuracy, but that was due to PC drives and their speed reading limitations and the fact that audio extraction used a sped up play mode or such.

And why is the desire for inter-track silence so hard to understand? It is the norm, because having seamless transitions between unrelated tracks is very weird. And there is no norm for how much silence to include in the tracks themselves.

In one practical example that prompted me to look for such a feature, I was listening to a track but wanted to decide manually how often to repeat it before switching to the next one, but it would immediately switch to the next one before I could repeat-play it. That was annoying.

guest

  • Guest
Re: Play inserted silence between tracks?
« Reply #7 on: 18 Dec '23 - 09:42 »
XMPlay doesn't currently have that option. It may be possible to add it but finding a suitable space for it in the options window could be an issue.

Maybe a negative crossfade values could set the gap between tracks?

Dowlphin

  • Posts: 28
Re: Play inserted silence between tracks?
« Reply #8 on: 18 Dec '23 - 12:28 »
It's a static value, so I assume not. (Although I am not sure what the settings "wait for decay" and "manual changes" do.)
(BTW,  just discovered "Auto-loop any track ending with sound, and that one is clever! Should have turned that one on long ago.)
It would have to do silence detection ideally at end and start (which the aforementioned function seems close to) and then add a fixed, chosen amount of silence after discarding that silence bit.

guest

  • Guest
Re: Play inserted silence between tracks?
« Reply #9 on: 19 Dec '23 - 10:32 »
Drop-down list with two options: "Crossfade", "Gap" could also be used.

Ian @ un4seen

  • Administrator
  • Posts: 26172
Re: Play inserted silence between tracks?
« Reply #10 on: 19 Dec '23 - 18:01 »
Here's an update for you to try:

   www.un4seen.com/stuff/xmplay.exe

As well as a "gap" setting, it also adds a "fade-out" setting that fades-out the old track while starting the new one at full volume (this used to be available in a "CrossFadeOut" XMPLAY.INI setting). Note it won't exclude any padding that the files may already contain. Please report any problems (it hasn't been tested much yet).

Dowlphin

  • Posts: 28
Re: Play inserted silence between tracks?
« Reply #11 on: 19 Dec '23 - 20:42 »
OK, the overlapping fadeout can sound quite beautiful, so I'll probably experiment with it in the future. Definitely a nice feature. The gap feature so far works in a WIP kind of way. The playtime after end of the track should probably behave like CD players do and show a negative value counting down until the new track begins.

The silence detection would still have to be added to the gap feature to actually lead to the desired amount of silence between music. This would be an extension of the logic of "auto-loop any track ending with sound", since there the player can detect whether it ends on silence or not. (Although analyzing the amount of silence is probably a more complicated logic.)

What does the function "Wait for end to decay - never/always/single track" do? I tried to add/remove that one to the gap feature, but didn't notice a difference.
Also, what does the "manual" slider right to the time setting slider do?

guest

  • Guest
Re: Play inserted silence between tracks?
« Reply #12 on: 20 Dec '23 - 04:57 »
This SID:
https://hvsc.csdb.dk/MUSICIANS/E/Electronic_Speech_Systems/Commodore_Speech_Demo.sid
contains subsongs with short durations of approximately 1 second. When they are played consecutively with a gap,
the displayed playback time position starts to jump and grow after a while instead of resetting to zero when the next subsong starts.
Additionally, when subsongs are separated in the playlist, some of them are skipped during playback with a gap.

Dowlphin

  • Posts: 28
Re: Play inserted silence between tracks?
« Reply #13 on: 20 Dec '23 - 05:36 »
I also just had another interesting case with the test version: I made a loop out of a piece that ends and starts at the zero line but with no silence around it, so kinda like when you make a cut exactly between beats. And the loop-when-no-silence mode didn't pick up on that and so didn't loop it. It's admittedly a tricky edge case, and I guess since some tracks actually do have zero silence, it would require advanced profiling to get closer to an accurate judgment. So it's probably alright the way it is, but on the other hand, what looped segment does not make a cut at zero? It could lead to clicking at the transition. So if one wanted to apply intelligent detection based on how amplitude and such behaves towards the end of the track, one could do that. But it would probably not be worth the hassle.
XMPlay already is a best-of example, one of those apps that are designed in a smart way, making use convenient, and the active development based on feedback makes it pure excellence.
(I am using kind of an XMPlay equivalent on Linux and I cannot even get it to do the basic key controls well, and other stuff is so unintuitive.)

guest

  • Guest
Re: Play inserted silence between tracks?
« Reply #14 on: 20 Dec '23 - 11:18 »
Can a finished track be active during a gap (its title could then, for example, flash)? It could then be restarted with the Home key.

Ian @ un4seen

  • Administrator
  • Posts: 26172
Re: Play inserted silence between tracks?
« Reply #15 on: 20 Dec '23 - 18:02 »
What does the function "Wait for end to decay - never/always/single track" do? I tried to add/remove that one to the gap feature, but didn't notice a difference.
Also, what does the "manual" slider right to the time setting slider do?

The "Wait for end to decay" option applies to decoders and DSP (when "including DSP" is enabled) that have the XMPIN_FLAG_TAIL and XMPDSP_FLAG_TAIL flag set, respectively. It extends the length of a track (if necessary) until the sound (eg. final notes or effect tail) has fully decayed rather than ending abruptly at the normal end position. I think only the MIDI plugin and built-in reverb effect currently have those flags set.

I also just had another interesting case with the test version: I made a loop out of a piece that ends and starts at the zero line but with no silence around it, so kinda like when you make a cut exactly between beats. And the loop-when-no-silence mode didn't pick up on that and so didn't loop it. It's admittedly a tricky edge case, and I guess since some tracks actually do have zero silence, it would require advanced profiling to get closer to an accurate judgment. So it's probably alright the way it is, but on the other hand, what looped segment does not make a cut at zero? It could lead to clicking at the transition. So if one wanted to apply intelligent detection based on how amplitude and such behaves towards the end of the track, one could do that. But it would probably not be worth the hassle.

The "ending with sound" detection shouldn't depend on the final sample being non-0, so please upload an affected file to have a look at here:

   ftp.un4seen.com/incoming/

Can a finished track be active during a gap (its title could then, for example, flash)? It could then be restarted with the Home key.

By default, XMPlay loads the next track while the old one is still playing to avoid any delays (eg. for gapless playback), but it's possible to disable that by adding "NoPreload=1" to your XMPLAY.INI file. Trying that now, it doesn't seem to work very well with the new gap option, so I'll have to look into that. I'll also look into deducting any silence at the end of the old track from the gap. And fix the issue affecting that SID file.

Dowlphin

  • Posts: 28
Re: Play inserted silence between tracks?
« Reply #16 on: 20 Dec '23 - 18:51 »
It's fine. I checked the waveform of the affected track and it has decaying signal energy towards the end, quite like a regular, non-looped tune could end if it simply didn't feature any silence. (If the original file allowed putting the cut somewhere else to create a loop, I could have done that.)
XMPlay is convenient enough that I can quickly switch loop modes as I like.

Ian @ un4seen

  • Administrator
  • Posts: 26172
Re: Play inserted silence between tracks?
« Reply #17 on: 21 Dec '23 - 17:31 »
Here's an update for you to try:

   www.un4seen.com/stuff/xmplay.exe

It should deduct any silence at the end of the old track from the gap (but won't deduct any silence at the start of the new track as it's unknown at that point), and the time display should now countdown the gap. It should also fix the issue with the SID file above (and others like it). Please report any problems, as it still hasn't been tested much yet.

Dowlphin

  • Posts: 28
Re: Play inserted silence between tracks?
« Reply #18 on: 21 Dec '23 - 18:20 »
Nice. It doesn't actually seem to go by mathematically perfect silence, because when I set 10 seconds, it often counts only 7 or 8 down after reaching perfect silence, but it seems to go by mostly inaudible track signal at the end when cutting it off, which has a better averaging effect to maintain perceptual consistency. (Although how to best tweak that threshold is a fuzzy matter. I have a track that ends in cymbals decaying, and until almost the very end they are still an audible hiss but are counted as silence. So the silence threshold could probably be a tiny bit more on the exclusive side, because the cymbals track has sound until the very end but the player counts 5 seconds of silence there.)

Here is the cymbals-ending track for experimenting. (It is from the Youtube audio library.) Tell me when you got it, then I can remove the link again.
(link obsolete)

You said it doesn't know the silence of the next track's beginning yet. Would such a read-ahead be difficult to code? I assume it is a different difficulty level than just gapless loop where it is the same track it is processing. Also shouldn't be necessary since tracks almost always begin with a negligible amount of silence.
« Last Edit: 22 Dec '23 - 19:25 by Dowlphin »

guest

  • Guest
Re: Play inserted silence between tracks?
« Reply #19 on: 22 Dec '23 - 04:21 »
Can a finished track be active during a gap (its title could then, for example, flash)? It could then be restarted with the Home key.

By default, XMPlay loads the next track while the old one is still playing to avoid any delays (eg. for gapless playback), but it's possible to disable that by adding "NoPreload=1" to your XMPLAY.INI file. Trying that now, it doesn't seem to work very well with the new gap option, so I'll have to look into that.

With the "NoPreload=1", XMPlay still loads the next track at the beginning of the gap.


Ian @ un4seen

  • Administrator
  • Posts: 26172
Re: Play inserted silence between tracks?
« Reply #20 on: 22 Dec '23 - 15:03 »
Nice. It doesn't actually seem to go by mathematically perfect silence, because when I set 10 seconds, it often counts only 7 or 8 down after reaching perfect silence, but it seems to go by mostly inaudible track signal at the end when cutting it off, which has a better averaging effect to maintain perceptual consistency. (Although how to best tweak that threshold is a fuzzy matter. I have a track that ends in cymbals decaying, and until almost the very end they are still an audible hiss but are counted as silence. So the silence threshold could probably be a tiny bit more on the exclusive side, because the cymbals track has sound until the very end but the player counts 5 seconds of silence there.)

Here is the cymbals-ending track for experimenting. (It is from the Youtube audio library.) Tell me when you got it, then I can remove the link again.
http://f.dowlphin.de/Airport_Lounge_Disco_Ultralounge.mp3

I've got the file now, so you can remove it. The "silence" threshold is currently -30dB. I'll see if that can be tweaked a bit. Let me know if you have any suggestions.

With the "NoPreload=1", XMPlay still loads the next track at the beginning of the gap.

Yes, I see the "NoPreload" option will actually only partially help you in this case. It will prevent the next track loading before the old one has finished playing, but the next track will still be loaded before the gap begins. I think it has to be this way because XMPlay doesn't know if a gap should be added until it has successfully loaded the next track.

Dowlphin

  • Posts: 28
Re: Play inserted silence between tracks?
« Reply #21 on: 22 Dec '23 - 19:33 »
The file I provided should be a good basis for setting the silence threshold. Since the cymbal can be heard until the end, albeit faintly, the player should probably either go by mathematical silence or only a realistic degree that falls within the background noise level, i.e. where a track is not actually intended to still contain music signal but might not be a perfect mathematical silence. I.e. VERY close to actual perfect silence would be worth a try, especially since some tracks might natively have a low amplification so one would crank the volume up and then hear faint subtleties easily.
If my analysis is correct, the file ends on a passage of roughly -33 dB.

guest

  • Guest
Re: Play inserted silence between tracks?
« Reply #22 on: 28 Dec '23 - 11:06 »
Manual changes slider is active, but has no effect in gap mode.

Ian @ un4seen

  • Administrator
  • Posts: 26172
Re: Play inserted silence between tracks?
« Reply #23 on: 29 Dec '23 - 16:13 »
Yes, the gap option doesn't currently apply to manual changes, as I didn't think it would ever be wanted then. Do you have a case where it is wanted?

Ian @ un4seen

  • Administrator
  • Posts: 26172
Re: Play inserted silence between tracks?
« Reply #24 on: 2 Jan '24 - 18:03 »
The file I provided should be a good basis for setting the silence threshold. Since the cymbal can be heard until the end, albeit faintly, the player should probably either go by mathematical silence or only a realistic degree that falls within the background noise level, i.e. where a track is not actually intended to still contain music signal but might not be a perfect mathematical silence. I.e. VERY close to actual perfect silence would be worth a try, especially since some tracks might natively have a low amplification so one would crank the volume up and then hear faint subtleties easily.
If my analysis is correct, the file ends on a passage of roughly -33 dB.

I don't think a perfect silence (or close to) threshold would work well because it could be triggered by a slightly noisy recording. I also don't think it's a bad thing for the tail end of a fade-out (like in your example file) to be considered part of the gap, as a gap after a fade-out is likely to seem longer? Still, here's an update with the threshold lowered slightly to -33 dB.

   www.un4seen.com/stuff/xmplay.exe