I’m writing a small utility program in C aimed at adding loop points to PCM WAV files.
As I find it really effective, I would like to use Audacity as an audio editor.
As far as I know, Audacity does not allow for saving WAV files with embedded loop points, but it allows for exporting labels as a text file, which could be as much as I need.
The problem is that the exported text files express labels’ position as floating point values representing the number of seconds from the beginning of the track. I fear that converting those floating point time values to integer sample values could lead to precision loss, and to click noises due to that lack of precision.
So, what am I asking here? I need a way to “persuade” Audacity to export labels directly as sample position instead of time position. Is it possible?
I use the last versione of Audacity available for Windows XP.
Assuming that your sample rate is 48kHz or less, there are enough digits that you can simply multiply the floating point time values and round to the nearest integer and it will be sample accurate.
I presume that you are aware that Windows XP is obsolete and no longer receives security fixes for any new vulnerabilities.
You: “Assuming that your sample rate is 48kHz or less, there are enough digits that you can simply multiply the floating point time values and round to the nearest integer and it will be sample accurate.”
I’m used to dealing with 44.100kHz sample rates, and the program I’m putting together is for personal use, so-- good news, many thanks!
You: “I presume that you are aware that Windows XP is obsolete and no longer receives security fixes for any new vulnerabilities.”
I’m aware, but it doesn’t matter, as the PC I use as a DAW doesn’t even have a modem and is NEVER EVER connected to the web. I have to say that XP, on that particular hardware, has proved its reliability through the years (almost decades, actually) and is way faster and less RAM-hungry than any newer Microsoft OS. Ah, I have to add that changing OS would mean the need to change most of the musical software I’m using, and probably some of the periferals as well, so I’m happy with my current gear, both software and hardware.
I have a new question. You wrote “multiply the floating point time values and round to the nearest integer”. “Round”, not “truncate”, ok?
I’m sure that you know, but as an example:
ROUND: 1.1=1 1.7=2
TRUNCATE: 1.1=1 1.999999=1
Yes. Round to nearest integer.
By convention, the tie=breaker rule is that .5 rounds up, but it is extremely unlikely that you will see a value of .500000
Ok, round. Thanks again.
I’m going to include math.h in my project in order to use round(), or just:
double time = 0.546532; // just an example
unsigned long sample = time + 0.5; // just another example