Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: How to detect audio gap at end of file (Read 2387 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How to detect audio gap at end of file

Hello, my hi-fi equipment does not support gapless for FLAC files. When I find two files with gap between them I merge the two files and solve the problem.

But my FLAC music collection is very large. Do you know any application that tells me if a FLAC file is GAP at the end?

I want to program a small script that search FLAC files. If the file has GAP then merge the file with the following file.

Thanks.

Re: How to detect audio gap at end of file

Reply #1
FLAC is gapless by design.  What equipment do you have that does not support this?

 

Re: How to detect audio gap at end of file

Reply #2
It sounds like your player cannot play two files without creating a space in between them. You want to detect if the sound level drops below approximately -80 dB at the end of a file, and if it does not, then merge with the next. This should be possible to do, but you will have to write it yourself. It is not a common problem; no one has solved it yet. SoX may help, but the trick will be how to look at only the last second of audio and test its volume level... I'm not sure what tools are available to analyze audio this way.

Re: How to detect audio gap at end of file

Reply #3
Possibly you should consider to convert every album/CD to single "image with cuesheet"? Likely your player does not support cuesheets, so that it means you will have to play the full album from the beginning to the end. But if you do not have a monster collection - and do not tweak tags all too often - you may keep a version as one-file-per-track and a version with one-file-per-album. If you have one folder per album, conversion is easy with CUETools.

Or, start using a computer for playback :-o   Yeah, what equipment do you have?

Re: How to detect audio gap at end of file

Reply #4
Quote
Yeah, what equipment do you have?

Sony STR-DN860. I connect my USB hard drive where I have all my music and I use my tablet to navigate and choose the music I want to hear. It's very comfortable.

Quote
Possibly you should consider to convert every album/CD to single "image with cuesheet"?

I've been thinking about doing that, but my hi-fi equipment also does not support FLAC+CUE.

Quote
You want to detect if the sound level drops below approximately -80 dB at the end of a file, and if it does not, then merge with the next.

I'll start working with this idea.

Thanks!


Re: How to detect audio gap at end of file

Reply #5
Sony STR-DN860.

Ah. According to http://www.hifi-forum.de/viewthread-274-823.html (posting #3), there is some app that can feed it a gapless stream. but not, it seems, over USB. 

BTW, on the product webpage, Sony promises that it can handle Hi-rez "The Way The Artists Truly Intended". So obviously, the artist intends you to listen to ridiculous bitrates with lots of HF noise you cannot hear - and two seconds gaps interrupting your live albums. Way.To.Go, Sony.

Re: How to detect audio gap at end of file

Reply #6
Quote
SoX may help

Yeah! (With minor bugs). Thanks to this article: How To Find (and Delete) Silent Audio Files

1. I cut the last second (or 0.5 seconds) of the song:

Code: [Select]
sox input.flac output.flac trim -0.5

2. I check the statistics of the song:

Code: [Select]
sox output.flac -n stat

$ sox output.flac -n stat
Samples read:             96000
Length (seconds):      0.500000
Scaled by:         2147483647.0
Maximum amplitude:     0.000041
Minimum amplitude:    -0.000043
Midline amplitude:    -0.000001
Mean    norm:          0.000006
Mean    amplitude:    -0.000000
RMS     amplitude:     0.000008
Maximum delta:         0.000052
Minimum delta:         0.000000
Mean    delta:         0.000010
RMS     delta:         0.000012
Rough   frequency:        23214
Volume adjustment:    23237.141

3. I'm only interested this part: "Maximum amplitude"

I have tested several songs, and many end up with 0.00000, but for other songs do not reach this value. I have chosen to use the maximum value 0.1. If the value is greater, I think that has GAP

I am now working on a script to automate the task.

Re: How to detect audio gap at end of file

Reply #7
Other users have reported your receiver is not able to play gapless via USB. Have you tested this solution with a true "gapless" album?

https://en.wikipedia.org/wiki/Gapless_album

Re: How to detect audio gap at end of file

Reply #8
Quote
Have you tested this solution with a true "gapless" album?

Some time ago I wrote a small script in python to join semiautomatically songs (You have to indicate which songs want to join, and the program does the rest). For example, for "The Dark Side of the Moon" what I have is the following:

  • 0001_0005-pink_floyd-speak_to_me_breathe_on_the_run_ETC.flac
  • 0006_0010-pink_floyd-money_us_and_them_ETC.flac

Now using sox , Can I detect automatically that songs have problems gap?:

Code: [Select]
MAXIMUM AMPLITUDE: AUDIO FILE
0.278582: 0001-pink_floyd-speak_to_me.flac
0.532053: 0002-pink_floyd-breathe.flac
0.093828: 0003-pink_floyd-on_the_run.flac
0.019794: 0004-pink_floyd-time.flac
0.006516: 0005-pink_floyd-the_great_gig_in_the_sky.flac
0.177891: 0006-pink_floyd-money.flac
0.495937: 0007-pink_floyd-us_and_them.flac
0.389682: 0008-pink_floyd-any_colour_you_like.flac
0.668178: 0009-pink_floyd-brain_damage.flac
0.000042: 0010-pink_floyd-eclipse.flac

It seems to be more complicated. Songs 5 and 10 have very low "Maximum amplitude":

Code: [Select]
0.006516: 0005-pink_floyd-the_great_gig_in_the_sky.flac
0.000042: 0010-pink_floyd-eclipse.flac

But the "Maximum amplitude" of the song 4 is also very low:

Code: [Select]
0.019794: 0004-pink_floyd-time.flac

Quote
I have chosen to use the maximum value 0.1

I was wrong. I have to keep looking at that "Maximum amplitude" or others values used for gapless albums.

Thanks!