Skip to content

Vampi's FM Tools

vgm2opm and others

Technical discussion which is not directly related to VGM files. Talk about Hardware and Software.

Moderator: Staff

Post by vampirefrog »

I am now having questions about EG times. In "Inside X68000" there are two tables describing EG times (for a 4MHz clock), and in the YM2151 user manual there is one table describing the same things, but for a 3.579545MHz clock.

In the "Inside X68000" text, there is a formula:
t = (10^4.202682)/(2^RATEH)*(1/(1+0.25*RATEL))*3.58/4.00
The last multiplication and division is obviously an adaptation from the "normal" YM2151 clock of 3.579545MHz rounded up to 3.58, to the 4MHz X68000 clock.

They also mention that the other values in the EG tables are just multiplied by a factor.

My questions are:

- Where is the value 4.202682 coming from, and why is it a power of 10? 10 ^ 4.202682 = 15947.110.
- For example, in the first table, dividing the 4th column by the second column gives a roughly constant 13.8219. Where does that come from?
- The next table divided by the second column in the first table gives ratios of roughly 0.56164 and 2.79452. Where do these come from?

Here is the jp text:
EG の表の値はほぼ指数関数となっています。0~100%のアタック時間tは, RATEの上 位4ビットと下位2ビット(表の2番目, 3番目の数値)を使って計算されます。上位4ビッ トを RATEH, 下位2ビットを RATEL とすると,
t = (10^4.202682)/(2^RATEH)×(1/(1+0.25×RATEL))×3.58/4.00
で表されます。その他の時間は、この値にたんに係数をかけるだけで算出することができます。 OPMの時間の分解能の限界のために, tが小さくなってくると,この式で計算した値からずれ てしまいますので注意してください。
eg-000.png
eg-001.png
eg-002.png
eg-003.png
ym2151-019.png

Code: Select all

●表......3 EG の各レート設定値と時間(0~100 %)

アタック                 ファーストディケイ/セカンド
                        ディケイ/リリース

AR×2+KS     時間(ms)     XR×2+KS    時間(ms)
                        RR×4+2+KS

 0:  0 0    無限大        0:  0 0    無限大
 1:  0 1    恭限大        1:  0 1    無限大
 2:  0 2    無限大        2:  0 2    無限大
 3:  0 3    無限大        3:  0 3    無限大
 4:  1 0    7136.33      4:  1 0    98637.69
 5:  1 1    5709.06      5:  1 1    78910.15
 6:  1 2    4757.55      6:  1 2    65758.46
 7:  1 3    4077.90      7:  1 3    56364.40
 8:  2 0    3568.16      8:  2 0    49318.84
 9:  2 1    2854.53      9:  2 1    39455.07
10:  2 2    2378.78     10:  2 2    32879.23
11:  2 3    2038.95     11:  2 3    28182.20
12:  3 0    1784.08     12:  3 0    24659.42
13:  3 1    1427.27     13:  3 1    19727.54
14:  3 2    1189.38     14:  3 2    16439.61
15:  3 3    1019.48     15:  3 3    14091.09
16:  4 0    892.04      16:  4 0    12329.71
17:  4 1    713.63      17:  4 1    9863.77
18:  4 2    594.69      18:  4 2    8219.81
19:  4 3    509.74      19:  4 3    7045.55
20:  5 0    446.02      20:  5 0    6164.86
21:  5 1    356.82      21:  5 1    4931.89
22:  5 2    297.35      22:  5 2    4109.90
23:  5 3    254.87      23:  5 3    3522.77
24:  6 0    223.01      24:  6 0    3082.42
25:  6 1    178.41      25:  6 1    2465.94
26:  6 2    148.68      26:  6 2    2054.95
27:  6 3    127.43      27:  6 3    1761.38
28:  7 0    111.51      28:  7 0    1541.22
29:  7 1    89.20       29:  7 1    1232.97
30:  7 2    74.34       30:  7 2    1027.48
31:  7 3    63.72       31:  7 3    880.59
32:  8 0    55.75       32:  8 0    770.60
33:  8 1    44.60       33:  8 1    616.48
34:  8 2    37.16       34:  8 2    513.74
35:  8 3    31.86       35:  8 3    440.35
36:  9 0    27.88       36:  9 0    385.31
37:  9 1    22.30       37:  9 1    308.25
38:  9 2    18.58       38:  9 2    256.83
39:  9 3    15.93       39:  9 3    220.17
40: 10 0    13.94       40: 10 0    192.65
41: 10 1    11.15       41: 10 1    154.12
42: 10 2    9.29        42: 10 2    128.43
43: 10 3    7.97        43: 10 3    110.09
44: 11 0    6.97        44: 11 0    96.33
45: 11 1    5.58        45: 11 1    77.06
46: 11 2    4.65        46: 11 2    64.22
47: 11 3    3.98        47: 11 3    55.04
48: 12 0    3.48        48: 12 0    48.16
49: 12 1    2.78        49: 12 1    38.53
50: 12 2    2.33        50: 12 2    32.11
51: 12 3    1.99        51: 12 3    27.52
52: 13 0    1.91        52: 13 0    24.08
53: 13 1    1.53        53: 13 1    19.27
54: 13 2    1.27        54: 13 2    16.06
55: 13 3    1.09        55: 13 3    13.77
56: 14 0    1.00        56: 14 0    12.04
57: 14 1    0.81        57: 14 1    9.63
58: 14 2    0.67        58: 14 2    8.03
59: 14 3    0.57        59: 14 3    6.88
60: 15 0    0.47        60: 15 0    6.02
61: 15 1    0.47        61: 15 1    6.02
62: 15 2    0.47        62: 15 2    6.02
63: 15 3    0.00        63: 15 3    6.02

Code: Select all

●表.........4 EG D各一下設定值時間(10~90%)

アタック                 ファーストディケイ/セカンド
                        ディケイ/リリース

AR×2+KS     時間(ms)     XR×2+KS    時間(ms)
                        RR×4+2+KS

 0:  0 0    無限大        0:  0 0    無限大
 1:  0 1    無限大        1:  0 1    無限大
 2:  0 2    無限大        2:  0 2    無限大
 3:  0 3    無限大        3:  0 3    無限大
 4:  1 0    4008.07      4:  1 0    19942.60
 5:  1 1    3206.45      5:  1 1    15954.08
 6:  1 2    2672.05      6:  1 2    13295.07
 7:  1 3    2290.32      7:  1 3    11395.78
 8:  2 0    2004.04      8:  2 0    9971.30
 9:  2 1    1603.23      9:  2 1    7977.05
10:  2 2    1336.02     10:  2 2    6647.53
11:  2 3    1145.16     11:  2 3    5697.88
12:  3 0    1002.02     12:  3 0    4985.65
13:  3 1    801.62      13:  3 1    3988.52
14:  3 2    668.01      14:  3 2    3323.77
15:  3 3    572.59      15:  3 3    2848.95
16:  4 0    501.01      16:  4 0    2492.83
17:  4 1    400.81      17:  4 1    1994.26
18:  4 2    334.01      18:  4 2    1661.88
19:  4 3    286.29      19:  4 3    1424.47
20:  5 0    250.50      20:  5 0    1246.41
21:  5 1    200.40      21:  5 1    997.13
22:  5 2    167.01      22:  5 2    830.94
23:  5 3    143.15      23:  5 3    712.23
24:  6 0    125.26      24:  6 0    623.21
25:  6 1    100.20      25:  6 1    498.57
26:  6 2    83.50       26:  6 2    415.47
27:  6 3    71.57       27:  6 3    356.12
28:  7 0    62.62       28:  7 0    311.60
29:  7 1    50.10       29:  7 1    249.28
30:  7 2    41.75       30:  7 2    207.74
31:  7 3    35.78       31:  7 3    178.04
32:  8 0    31.32       32:  8 0    155.80
33:  8 1    25.05       33:  8 1    124.64
34:  8 2    20.87       34:  8 2    103.86
35:  8 3    17.89       35:  8 3    89.03
36:  9 0    15.65       36:  9 0    77.90
37:  9 1    12.52       37:  9 1    62.32
38:  9 2    10.44       38:  9 2    52.83
39:  9 3    8.95        39:  9 3    44.52
40: 10 0    7.83        40: 10 0    38.95
41: 10 1    6.27        41: 10 1    31.16
42: 10 2    5.22        42: 10 2    25.96
43: 10 3    4.48        43: 10 3    22.26
44: 11 0    3.91        44: 11 0    19.48
45: 11 1    3.13        45: 11 1    15.58
46: 11 2    2.61        46: 11 2    12.98
47: 11 3    2.24        47: 11 3    11.12
48: 12 0    1.96        48: 12 0    9.74
49: 12 1    1.57        49: 12 1    7.79
50: 12 2    1.31        50: 12 2    6.49
51: 12 3    1.12        51: 12 3    5.57
52: 13 0    0.98        52: 13 0    4.87
53: 13 1    0.78        53: 13 1    3.89
54: 13 2    0.65        54: 13 2    3.26
55: 13 3    0.55        55: 13 3    2.78
56: 14 0    0.52        56: 14 0    2.43
57: 14 1    0.42        57: 14 1    1.95
58: 14 2    0.36        58: 14 2    1.62
59: 14 3    0.30        59: 14 3    1.39
60: 15 0    0.24        60: 15 0    1.22
61: 15 1    0.24        61: 15 1    1.22
62: 15 2    0.24        62: 15 2    1.22
63: 15 3    0.00        63: 15 3    1.22

Post by vampirefrog »

I've had an idea of categorizing instruments based on their range. For example an instrument used only in the lower octaves is most probably a bass. I could build a histogram of note values and decide based on that. Instruments with pitch bending could be a guitar or violin. Perhaps i could look at the envelopes and decide whether it has a percussive element like a piano, or if it's a slow attack it could be strings. If an instrument is only used on one note it might be a drum. Another clue that it's a piano is no vibrato. But then, there is the FM element... Perhaps some FM connections are specific to some instruments. I guess it would take some existing, already labeled data and some careful analysis.

Post by vampirefrog »

I've renamed the repository and I've made the fmtoy code more reusable like a library, as I'm using it compiled with emscripten on a project.

https://github.com/vampirefrog/fmtoy

Now its main purpose is fmtoy, and I'll split the tools into another repository later, especially vgm2opm.

Also, if anyone is experienced with windows coding, it would be nice if someone helped me port it to windows too, it is fairly clean and shouldn't be hard, although it might benefit from a simple UI.
  • kingcandy Offline
  • Posts: 51
  • Joined: 2019-04-13, 15:38:34

Post by kingcandy »

vampirefrog wrote:I've renamed the repository and I've made the fmtoy code more reusable like a library, as I'm using it compiled with emscripten on a project.

https://github.com/vampirefrog/fmtoy

Now its main purpose is fmtoy, and I'll split the tools into another repository later, especially vgm2opm.

Also, if anyone is experienced with windows coding, it would be nice if someone helped me port it to windows too, it is fairly clean and shouldn't be hard, although it might benefit from a simple UI.
I'd love to have a windows port of your vgm2OPM (and maybe similar extractors to extract to .tfi, .BTI (bambootracker instrument) or any of the other fm tracker formats, also extract ssg instruments into .BTI files.
be a hero and stop coppa now!
http://chng.it/DNc2L8LvLJ

Post by vampirefrog »

I'll get to this at some point, right now I'm rewriting mdxtools.
  • User avatar
  • Orbi Offline
  • Posts: 3
  • Joined: 2016-06-18, 12:56:01

Post by Orbi »

Are these tools still Linux-only? I have Windows 7 so it's impossible for me to use these though I really want to put some YM2151 voices from VGMs into mid2smps. If there exist alternative method please tell me.
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

If you want to do something with mid2smps .... did you already try to load the YM2151 VGMs in 2612edit?
  • User avatar
  • Orbi Offline
  • Posts: 3
  • Joined: 2016-06-18, 12:56:01

Post by Orbi »

ValleyBell wrote:If you want to do something with mid2smps .... did you already try to load the YM2151 VGMs in 2612edit?
I only tried .opm with it because I thought 2612edit only accepts this format specifically for YM2151 data, but loaded .vgm for YM2612/2608 data. Thanks for the tip!

...well, I also wanted to port the voices to Deflemask for YM2151+SEGA PCM setup, so 2612edit won't work for this task obviously.
Post Reply