Thursday, November 21, 2024

Altering The Timestamp In Perseus IQ .WAV Files

Three or four years ago I got into SDR receivers. I don't own a Perseus, but I do own and use an Airspy HF+ Discovery, an SDRPlay RSP1a, and an SDRPlay RSPdx.

Perseus IQ .WAV files can be found on the internet or compatible ones can be created by several SDR receiver programs. One of those programs is the HDSDR program. Even if you don't own a Perseus receiver (the hardware), you can use the free Perseus demo (version 5) to play the .WAV files.

Perseus V5 demo from MicroTelecom

These IQ files are fairly typical .WAV riff files. Within the file header is a special field which specifies the date/time of the recording. The Perseus receiver software picks this up and uses it in its display of the recording.

Occasionally someone has the need to change the time of the recording, possibly because their computer clock was off when the recording was made. This can be easily done if you don't mind some byte twiddling in a hex editor.

Altering The Timestamp (2 ways)

Both methods require a manual procedure, one easy and one a little more detailed. I've tested both and they work.

The starting date/time timestamp field is contained within the Perseus .WAV file header. It's found at hexadecimal location x34 and is 4 bytes long. It is the Epoch time for the start date/time. Epoch time is the number of seconds since January 1, 1970 at midnight AM: 00:00:00 GMT. No ending timestamp seems to be used, rather they use the actual length of the audio file to calculate the end time.

We must change this 4 byte starting timestamp field at location x34. That would be bytes 34, 35, 36, and 37.

There are two methods to change this timestamp. Follow along, looking at the screenshot below.

Method 1, the easier method. You need:

1. The freeware hex editor program HxD. HxD is a nice freeware one for Windows that I use.

https://mh-nexus.de/en/hxd/

Start your hex editor HxD and open the Perseus .WAV file. With your mouse, select the 4 bytes starting at hex location x34 (34,35,36,37). In the lower right panel look for the item named "time_t (32 bit)". You will see that HxD has converted the 4 byte value at hex x34 and displayed the date/time conversion in plain text right there.

Each of the items in the right panel can be modified. Here's how to modify the date/time item:

Only after selecting the 4 bytes starting at hex location x34, make your changes to the date/time in the "time_t (32 bit)" item, then press ENTER. HxD will calculate the 32 bit Epoch time value and replace the one at location x34.

Save the file. HxD will also save a backup of the old file for backup purposes.

You are done except for renaming the file, see below after Method 2.

Method 2, the harder geek method. You need:

1. The freeware hex editor program HxD. HxD is a nice freeware one for Windows that I use.

https://mh-nexus.de/en/hxd/

2. Access to an Epoch timestamp converter (available online).

https://www.epochconverter.com

3. Access to a decimal to hexadecimal converter or a programmer's decimal-hexadecimal calculator.

https://www.rapidtables.com/convert/number/decimal-to-hex.html

Start your hex editor HxD and open the Perseus .WAV file. With your mouse, select the 4 bytes starting at hex location x34 (34,35,36,37). In the lower right panel look for the item named "time_t (32 bit)". You will see that HxD has converted the 4 byte value at hex x34 and displayed the date/time conversion in plain text right there.

Write down your new start date and time. Go to the Epoch timestamp converter site (or another if you prefer) and enter the date/time you have chosen. Convert that date/time to the new Epoch time. You will get a big number. For example, for 11-21-2024 0450 GMT (NOV 21, 2024 @ 04:50:00 GMT), the Epoch time is 1732164600.

Again, one Epoch time converter site is: https://www.epochconverter.com

Now, we must convert this number to a 4 byte (8 digit) hexadecimal value.

Go to the hexadecimal converter site and in the decimal field type the Epoch time number. In our example it was "1732164600" for 11-21-2024 0450 GMT.

Using our example, you will get the hexadecimal value: 673EBBF8

The Perseus .WAV file requires this value to be in what programmers call "little-endian format", that is, low value to high value. The value above is in "big-endian format", or high to low value.

We simply need to mirror the hexadecimal number we have. Mirror 673EBBF8, getting F8BB3E67.

We now need to plug in our example number F8BB3E67 into the .WAV file at hex location x34.

Back in your hex editor HxD, set your cursor at hex location x34 (left click just to the left of the location x34 byte itself) and type the new value, F8BB3E67, into the main hex display replacing the 4 bytes starting at hex location x34.

Save the file. HxD will also save a backup of the old file for backup purposes.

Renaming The File

It's not necessary for the Perseus SDR receiver software, but to maintain clarity, rename the .WAV file to the new start time. And since you know the length of the file in minutes, also add the new end time too.

If you have multiple .WAV files, i.e., when a time period is longer than 15 minutes, be sure to change the start time in each file (_001, _002, _003, etc).

That's it. If I get some time at some point, I'll code up a little program to do all this automatically.