Skip to main content
simplified the console.log with 4 values
Source Link
Bavi_H
  • 306
  • 1
  • 4
t = 123.4;

v = 100 * t;

b1 = (v >> 12) & 15;
b2 = (v >> 8) & 15;
b3 = (v >> 4) & 15;
b4 = v & 15;

console.log(b1 + "  " +, b2 + "  " +, b3 + "  " +, b4);
t = 123.4;

v = 100 * t;

b1 = (v >> 12) & 15;
b2 = (v >> 8) & 15;
b3 = (v >> 4) & 15;
b4 = v & 15;

console.log(b1 + "  " + b2 + "  " + b3 + "  " + b4);
t = 123.4;

v = 100 * t;

b1 = (v >> 12) & 15;
b2 = (v >> 8) & 15;
b3 = (v >> 4) & 15;
b4 = v & 15;

console.log(b1, b2, b3, b4);
major re-write: explaining binary; only values 0-15 are useful; reformatted example to match new byte numbers and style in updated question; added Javascript bitwise math
Source Link
Bavi_H
  • 306
  • 1
  • 4

I would suggest turning on each bit individually and see what tempo value is displayed. In other words, for each byte, test values 1, 2, 4, 8, 16, 32, and 64 while keeping the other bytes zero. Do the displayed tempo values double each time you double the byte value?

Binary

Because MIDI data bytes can only containare 7 bits, when an 8meaning they can have decimal values from 0 to 127.

In a 7-bit byte needsbinary number:

  • the bit on the right represents a decimal value of 1.
  • the next bit to the left represents a decimal value of 2.
  • the next bits to the left represent decimal values of 4, 8, 16, 32, and 64.

Decimal values from 0 to 127 can be sent in a System Exclusive message, manufacturers sometimes just put 4 bitsexpressed in one data byte and the other 4seven bits in the next data byte. So this, where each bit is one kind of pattern to look fora 0 or 1.

binary   decimal
0000001  1 = 1
0000010  2 = 2
0000011  3 = 2 + 1
0000100  4 = 4
0000101  5 = 4 + 1
0000110  6 = 4 + 2
0000111  7 = 4 + 2 + 1
0001000  8 = 8
0001001  9 = 8 + 1
...
1111111  127 = 64 + 32 + 16 + 8 + 4 + 2 + 1

Pattern

From the results you described, one hypothesis I have is thatsuspect the turntable only cares about the lowest 4 bits in each byte. In other words, only the bits with decimal values of 1, 2, 4, and 8 will have an effect on the tempo display. This means only byte values 0 to 15 are useful.

I suspect the turntable is using the following pattern:

byte5:B1 1 2B2 4 8
B3  B4  tempo: .01 .02display
 0   0   0   0   .0400     .08
0
byte4: 0   0   0   1   .01      "
 0   0   0   2 4 8 .02      "
tempo: 0   0   0   3   .1603      "
 0   0   0   4   .3204      "
 0   0   0   5   .6405  1    "
 0   0   0   6   .2806      "
 0   0   0   7   .07      "
byte3: 10 2 4 0   0   8
tempo: 2  .5608  5    "
 0   0   0   9   .1209      "
 0   0   0  10   .2410  20   .481
 0   0   0  11   .11      "
byte2: 10 2 4 80   0  12   .12      "
tempo: 400   0   0  13   .9613  81    "
 0   0   0  14   .9214  163    "
 0   0   0  15   .8415  327    "
 0   0   1   0   .6816      "
 0   0   1   1   .17      "
byte1: 0   0   1   2   .18      "
tempo: 6550   0   1   3   .3619      "
 0   0   1   4   .20     .2
...

In this pattern, the smallestThe byte values represent tempo value isvalues in .01. When units, but when the turntable displays the tempo, it appears to just drophides the hundredthslast digit (.09 displays as

This hidden digit explains why turning on multiple bytes doesn't always produce the sum of the tempos displayed by the individual byte values.0 and

B1  B2  B3  B4  tempo  display
 1   0   0   0  40.96   40.9
 0   0   1   0    .16     .1
 1   0   1   0  41.12   41.1

Bitwise math

When only some bits are used, bitwise math is indeed useful.10 displays as

For example, here's some Javascript to convert a tempo to the needed byte values:

t = 123.4;

v = 100 * t;

b1 = (v >> 12) & 15;
b2 = (v >> 8) & 15;
b3 = (v >> 4) & 15;
b4 = v & 15;

console.log(b1 + "  " + b2 + "  " + b3 + "  " + b4);

x & 15 is a bitwise AND, in this case, to keep only the lowest four bits.1) instead of actually rounding

x >> 4 is a (right shift, in this case shifting the value 4 bits to the right, which discards the lowest four bits.04 would display This has the same effect as .0dividing by 16 and .05 would display as .1)discarding the remainder.

On the other hand,Here's some ofJavascript to convert the results you described suggest data byte values of 16to the displayed tempo:

b1 = 3;
b2 = 0;
b3 = 3;
b4 = 4;

b1 = b1 & 15;
b2 = b2 & 15;
b3 = b3 & 15;
b4 = b4 & 15;

v = 16*16*16*b1 + 16*16*b2 + 16*b3 + b4;

t = parseInt(v / 10) / 10;

console.log(t);

In your web browser, 32you can go to about:blank, then press F12 and 64 may have some kind of effect? Maybego to Console to enter these values duplicate the effect of the 1small Javascript calculations. (For your safety, 2enter about:blank in the address box, and 4 values of the next byte to the left? Maybe there is some other patternnever run code from strangers if you don't understand it.)

I would suggest turning on each bit individually and see what tempo value is displayed. In other words, for each byte, test values 1, 2, 4, 8, 16, 32, and 64 while keeping the other bytes zero. Do the displayed tempo values double each time you double the byte value?

Because MIDI data bytes can only contain 7 bits, when an 8-bit byte needs to be sent in a System Exclusive message, manufacturers sometimes just put 4 bits in one data byte and the other 4 bits in the next data byte. So this is one kind of pattern to look for.

From the results you described, one hypothesis I have is that the turntable only cares about the lowest 4 bits in each byte. In other words, only values of 1, 2, 4, and 8 will have an effect on the tempo display.

byte5: 1 2 4 8
tempo: .01 .02 .04 .08

byte4: 1 2 4 8
tempo: .16 .32 .64  1.28

byte3: 1 2 4 8
tempo: 2.56  5.12  10.24  20.48

byte2: 1 2 4 8
tempo: 40.96  81.92  163.84  327.68

byte1: 1
tempo: 655.36

In this pattern, the smallest tempo value is .01. When the turntable displays the tempo, it appears to just drop the hundredths digit (.09 displays as .0 and .10 displays as .1) instead of actually rounding (.04 would display as .0 and .05 would display as .1).

On the other hand, some of the results you described suggest data byte values of 16, 32, and 64 may have some kind of effect? Maybe these values duplicate the effect of the 1, 2, and 4 values of the next byte to the left? Maybe there is some other pattern.

Binary

MIDI data bytes are 7 bits, meaning they can have decimal values from 0 to 127.

In a 7-bit binary number:

  • the bit on the right represents a decimal value of 1.
  • the next bit to the left represents a decimal value of 2.
  • the next bits to the left represent decimal values of 4, 8, 16, 32, and 64.

Decimal values from 0 to 127 can be expressed in seven bits, where each bit is a 0 or 1.

binary   decimal
0000001  1 = 1
0000010  2 = 2
0000011  3 = 2 + 1
0000100  4 = 4
0000101  5 = 4 + 1
0000110  6 = 4 + 2
0000111  7 = 4 + 2 + 1
0001000  8 = 8
0001001  9 = 8 + 1
...
1111111  127 = 64 + 32 + 16 + 8 + 4 + 2 + 1

Pattern

From the results you described, I suspect the turntable only cares about the lowest 4 bits in each byte. In other words, only the bits with decimal values of 1, 2, 4, and 8 will have an effect on the tempo display. This means only byte values 0 to 15 are useful.

I suspect the turntable is using the following pattern:

B1  B2  B3  B4  tempo  display
 0   0   0   0   .00     .0
 0   0   0   1   .01      "
 0   0   0   2   .02      "
 0   0   0   3   .03      "
 0   0   0   4   .04      "
 0   0   0   5   .05      "
 0   0   0   6   .06      "
 0   0   0   7   .07      "
 0   0   0   8   .08      "
 0   0   0   9   .09      "
 0   0   0  10   .10     .1
 0   0   0  11   .11      "
 0   0   0  12   .12      "
 0   0   0  13   .13      "
 0   0   0  14   .14      "
 0   0   0  15   .15      "
 0   0   1   0   .16      "
 0   0   1   1   .17      "
 0   0   1   2   .18      "
 0   0   1   3   .19      "
 0   0   1   4   .20     .2
...

The byte values represent tempo values in .01 units, but when the turntable displays the tempo, it hides the last digit.

This hidden digit explains why turning on multiple bytes doesn't always produce the sum of the tempos displayed by the individual byte values.

B1  B2  B3  B4  tempo  display
 1   0   0   0  40.96   40.9
 0   0   1   0    .16     .1
 1   0   1   0  41.12   41.1

Bitwise math

When only some bits are used, bitwise math is indeed useful.

For example, here's some Javascript to convert a tempo to the needed byte values:

t = 123.4;

v = 100 * t;

b1 = (v >> 12) & 15;
b2 = (v >> 8) & 15;
b3 = (v >> 4) & 15;
b4 = v & 15;

console.log(b1 + "  " + b2 + "  " + b3 + "  " + b4);

x & 15 is a bitwise AND, in this case, to keep only the lowest four bits.

x >> 4 is a right shift, in this case shifting the value 4 bits to the right, which discards the lowest four bits. This has the same effect as dividing by 16 and discarding the remainder.

Here's some Javascript to convert the byte values to the displayed tempo:

b1 = 3;
b2 = 0;
b3 = 3;
b4 = 4;

b1 = b1 & 15;
b2 = b2 & 15;
b3 = b3 & 15;
b4 = b4 & 15;

v = 16*16*16*b1 + 16*16*b2 + 16*b3 + b4;

t = parseInt(v / 10) / 10;

console.log(t);

In your web browser, you can go to about:blank, then press F12 and go to Console to enter these small Javascript calculations. (For your safety, enter about:blank in the address box, and never run code from strangers if you don't understand it.)

Source Link
Bavi_H
  • 306
  • 1
  • 4

I would suggest turning on each bit individually and see what tempo value is displayed. In other words, for each byte, test values 1, 2, 4, 8, 16, 32, and 64 while keeping the other bytes zero. Do the displayed tempo values double each time you double the byte value?

Because MIDI data bytes can only contain 7 bits, when an 8-bit byte needs to be sent in a System Exclusive message, manufacturers sometimes just put 4 bits in one data byte and the other 4 bits in the next data byte. So this is one kind of pattern to look for.

From the results you described, one hypothesis I have is that the turntable only cares about the lowest 4 bits in each byte. In other words, only values of 1, 2, 4, and 8 will have an effect on the tempo display.

byte5: 1 2 4 8
tempo: .01 .02 .04 .08

byte4: 1 2 4 8
tempo: .16 .32 .64  1.28

byte3: 1 2 4 8
tempo: 2.56  5.12  10.24  20.48

byte2: 1 2 4 8
tempo: 40.96  81.92  163.84  327.68

byte1: 1
tempo: 655.36

In this pattern, the smallest tempo value is .01. When the turntable displays the tempo, it appears to just drop the hundredths digit (.09 displays as .0 and .10 displays as .1) instead of actually rounding (.04 would display as .0 and .05 would display as .1).

On the other hand, some of the results you described suggest data byte values of 16, 32, and 64 may have some kind of effect? Maybe these values duplicate the effect of the 1, 2, and 4 values of the next byte to the left? Maybe there is some other pattern.