Why do negative numbers on audio sample rate not play...in reverse?

In Windows Media Player, if you set the speed for a negative number, it would reverse/rewind the file. QuickTime had a similar feature. So does scrubbing in Edison by FL Studio 12 or scrubbing in Audacity (But not working when using the Change Speed effect). Moving the slider leftward would slow it, pause it, and start to reverse, eventually rewind quickly. So I decided to try converting a WAV with sample rate in the negative, to see if it would play backward. Some programs can still show waveforms but can’t move; the sound is refusing to move, and even if it does let me click to seek (But NOT hitting rewind or fast-forward), it won’t play. Others give me an error message. If there is a player, that supports negative sample rates to play backwards, is it free, and can I download it if it is? The file I attached in the 7Z file is a WAV file with a negative sample-rate. If you open it in some programs, it reads “-11025Hz” instead of “11025Hz” Could you tell me or give an explanation of why this didn’t work, and why it also doesn’t work in the playbackRate() command on most browsers, and Anime Studio Debut 6 FPS as well? Do the math, Forward example; 0:10+0:01=0:11. Reverse example; 0:10-0:01=0:09. Calculations show this should work. Why not? Why does playback not work? What do you think “:rewind:” means? Yes, I could flip the beginning and ending, but what is up with this erroneous phenomenon? If you don’t believe me, open the file in the attachment. It’s sample-rate is -11025Hz. Could someone tell me if an app that is compatible with reversed WAV files exists? And if there is a downloadable browser with the ability to reverse speed/time by putting playbackRate() in the negative, which ones do? If it is discontinued, what latest browser had it? I’m just wondering, and asking why computers won’t sometimes comprehend negative values…Thank you for explaining.

“Because reverse is slower than forward; reverse is below stopping time.” (I made up that quote, do you like it?)
negative-sample-rate-for-reverse.7z (292 KB)

According to the MP3 specification, valid sample rates are shown in this table:

MPEG-1     MPEG-2     MPEG-2.5

  -           -       8000 Hz
  -           -       11025 Hz
  -           -       12000 Hz
  -        16000 Hz     -
  -        22050 Hz     -
  -        24000 Hz     -
32000 Hz      -         -
44100 Hz      -         -
48000 Hz      -         -

The sample rate must be defined at the start of each MP3 frame as a two bit number:

Sampling rate frequency index (values are in Hz)

bits    MPEG1   MPEG2   MPEG2.5
00      44100   22050   11025
01      48000   24000   12000
10      32000   16000   8000
11      reserv. reserv. reserv.

WAV format is similar, but more complex. It uses 4 bytes to define the sample rate, and a further 4 bytes to define the data rate (average bytes per second). The “average bytes per second” = sample rate x number of channels x bytes per sample. The sample rate must therefore be positive according to the format specification.

Format specifications do not define what a player should do with invalid files.

If you want to make a track play backwards in Audacity, apply the “Reverse” effect.

The software has to “know” in-advance if a number is signed (possibly negative) or unsigned (always positive). That’s because the most significant bit of a signed binary value represents the +/- sign whereas with an unsigned (always positive) value it’s just the most significant bit. So of course, with an extra bit you can “count higher” with unsigned values/variables.

In the [u]WAV file header[/u] the sample rate is a 4-byte value (32-bits) starting at byte #24 and the software knows where to look in a WAV file. I assume the sample rate is expected to be unsigned and positive.

The standard format for signed binary is [u]Two’s Complement[/u] which is kind-of screwy, but in two’s complement there is no negative zero which doesn’t make sense anyway. And, you can’t simply ignore the sign bit… If you (somehow) enter a negative sample rate the sign-bit will be read as a 1 and you’ll get a ridiculous sample rate in the GHz range!

For example, Consider a 4-bit* value:
0000 = 0 decimal
0001 = 1 decimal
0010 = 2 decimal
0011 = 3 decimal
0100 = 4 decimal
0101 = 5 decimal
0110 = 6 decimal
0111 = 7 decimal
1000 = 8 or -8 decimal
1001 = 9 or -7 decimal
1010 = 10 or -6 decimal
1011 = 11 or -5 decimal
1100 = 12 or -4 decimal
1101 = 13 or -3 decimal
1110 = 14 or -2 decimal
1111 = 15 or -1 decimal



\

  • 4-bit signed values are not commonly used. Usually signed numbers are 16 or 32-bit integers (which can also be unsigned).

Looking at it another way, a sound card can only play samples in the order that it gets them. Telling a sound card to play samples in the reverse order makes no sense because it cannot play a sample until it receives it.

In your “negative-sample-rate-for-reverse” file, the 4 bytes for sample rate are FF FF D4 EF (Hex), which is -11025 if you treat the binary number as “signed 32-bit integer”, or 4294956271 if you treat it as “unsigned 32-bit integer”. Interestingly, MediaInfo treats it as unsigned:

Audio
Format : PCM
Format settings : Unsigned
Codec ID : 1
Duration : 35 s 25 ms
Bit rate mode : Constant
Bit rate : 88.2 kb/s
Channel(s) : 1 channel
Sampling rate : 4295 MHz
Bit depth : 8 bits
Stream size : 377 KiB (100%)

Here’s your file, corrected to be a valid WAV file and plays in reverse:

That makes sense. The reason I stored the music backward is not to audibly play backward, but for the reason like converting 44100 to 11025 and resampling (Which changes the size of the file), so it was stored backward to play in reverse again, sounding normal (Double negative). So yeah, What you said makes sense, some programs get it confused and read it differently;

000=0
001=1
010=2
011=3
100=4 or -4
101=5 or -3
110=6 or -2
111=7 or -1

That makes that clear, but that doesn’t explain why WMP and QT let you play it backward; I guess that is because extra computer data is added to tell it, “When Negative, Reverse And Change To This Speed”, or “Jump back X many times, Y far for Z unit-of-time”?

And what about browsers, when I set speed “playbackRate()” to negative, does it not work is it for the same reason?

Hi Winston,
Not to be a nuisance or anything like that … just could not pass up the mercy of a programmer

That makes that clear, but that doesn’t explain why WMP and QT let you play it backward

Respectfully, ZARDOZ