Hello,
After opening a wav file (24 bit depth) with the LibSndFile library (and not WAV because I get InexactError when reading some files that are opened well with LibSndFile), the data is in 32 bit format (Q0f31 (alias for Fixed{Int32, 31})
), then if I save the data, which were not modified, I get a larger file because the audio data is in 32 bit and not 24. If I convert the data to 24 bit then I save, I get an errorβ¦
using FileIO
using LibSndFile
using SampledSignals
soundfile = load("original.wav")
soundfile = SampleBuf(PCM24Sample.(soundfile.data), soundfile.samplerate) # Is there a better way to do that?
save("result.wav", soundfile)
soundfile
:
7838720-frame, 2-channel SampleBuf{Q0f31, 2}
177.74875283446713s sampled at 44100.0Hz
ββββββββββββββββββββββββββββββββββββ
ββββ
ββββββββββββββββββββββββββ
ββββββββββββββ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Error:
Errors encountered while save File{DataFormat{:WAV}, String}("test.wav").
All errors:
===========================================
ArgumentError: Package WAV [8149f6b0-98f6-5db9-b78f-408fbbb8ef88] is required but does not seem to be installed:
- Run `Pkg.instantiate()` to install all recorded dependencies.
===========================================
LibSndFile writer error: neither save nor fileio_save is defined
due to MethodError(LibSndFile.subformatcode, (FixedPointNumbers.Q8f23,), 0x00000000000073ea)
Will try next loader.
Of course, if I have WAV installed (not the case in this MWE), I just have the LibSndFile writer error: neither save nor fileio_save is defined
.
The practical goal is not to load and save the file without modifications, of course, it is also to separate channels in case of stereoβ¦
I really donβt know how I can simply convert and save in 24 bit depth (or more generally keep the same βformatβ as original if it is not 16 or 32 bit).
Thank you.