-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does it work? #1
Comments
I was opening the .pcm files directly with Audacity. There could be an issue with byte order? I don't recall testing 32 bit FLACs. Note this isn't well tested. I basically wrote it and then moved onto other projects. |
Thank you. This info is very helpful. |
16 bit flac files work great. I import them into Audacity as: 24 bit flac files almost sound good but there are "scratches". Settings same as above. I tried changing order of bytes saved to disk in FLACWriteLongIntAsBytes but it didn't get me anywhere. I use Lazarus on Windows (so it's Intel with Little endian). Perhaps you use a Big endian processor? |
I just tried a 24 bit file and got the same result, it plays at the correct speed and volume, and you can hear the music but there is additional static. The overall waveform in Audacity looks mostly the same. I will have a look into it. I was using an Intel Mac when I wrote the software (using an M1 Mac now). I wrote it out BigEndian as that is the 'standard' network byte order. |
Just an update: I used Audacity to convert a FLAC to raw PCM to compare with flac-pascal's output. Audacity only supports exporting in little endian I've just rearranged them manually below. There is a difference even in the first stereo sample pair. Here are the first few samples (3 bytes per line):
Note these are small differences and most likely not caused by endianness. I wrote a short program to test the reading and writing functions from flac-pascal ( The interesting thing is that the first sample for each channel is a "warm-up" sample for the LPC decoder (e.g. not encoded). Also there is no channel decorrelation, so there is no further processing on the sample. So for the right channel, flac-pascal reads in Because it is the first sample, which is unencoded, and there is no channel decorrelation, it makes it a bit easier to track down, but will take some time... |
Thank you for taking the time considering you moved on to other projects. Much appreciated! It will be a very useful library for Lazarus/Delphi because there doesn't seem to be any alternative in pure Pascal. |
It looks like Audacity is doing some processing on the data. I used ffmpeg and the first 3.36 seconds is identical to flac-pascal but is different after that. I am using the first track from this Linn recording of Handel's messiah: https://www.linnrecords.com/recording-handel-messiah-dublin-version-1742 It starts with 3 seconds of silence, although it isn't completely silent and flac-pascal decodes those first 297,077 samples correctly. I used this ffmpeg command to produce the raw PCM:
And this command to find the first difference:
This could be a little trickier to hunt down. Although I did find one bug in the Verbatim decoding (it should use Line 546 in 9472162
|
Maybe this "near-silence" is not a good sample to test? Kinda seems like flac-pascal is truncating/changing the values which don't fit into 16bit. |
Hi, any progress? :) |
I tried it under Lazarus but it didn't convert FLAC to PCM properly. I tested on 2 different FLAC files. I used your original FLACWriteLongIntAsBytes function and then I replaced it with a simplified one:
FLAC1: 48 kHz, mono, 32bits/sample
FLAC2: 44.1 kHz, stereo, 32bits/sample
Then I used FFMPEG to convert .pcm to .wav:
ffmpeg.exe -f u32le -ar 48000 -ac 1 -i test1.pcm -ar 48000 -ac 1 out1.wav
ffmpeg.exe -f u32le -ar 44100 -ac 2 -i test2.pcm -ar 48000 -ac 1 out2.wav
The number of samples, sample rate, bits per second returned by streamInfoBlock is correct.
The output .wav file has correct duration- same as original. It even kinda sounds similar but with a lot of "scratches".
Maybe I am using ffmpeg incorrectly? Or perhaps this library doesn't like my FLAC files? Can you upload a FLAC file it works fine with? Or how you convert .pcm to .wav?
The text was updated successfully, but these errors were encountered: