# Newly Released Simai to SDT Converter

September 14, 2020•888 words

I've finally published the code for my simai to sdt converter at my github. The rest of this blog post is mostly about my time developing this Python program. Please keep in mind that not much thought has been given to this post so some explanations may be unclear.

The simai chart format was a bit hard to translate to sdt due to two major differences in the two formats:

- Simai allows BPM changes while sdt does not
- Some slide patterns in simai require some additional steps before you find the equivalent slide pattern in sdt

# BPM Changes

A hacky way of solving the first problem is to still write everything in the initial BPM but find the equivalent length of a note or rest in another BPM in the initial BPM of the chart. For example, a chart has an initial BPM of 120 BPM but along the way there's a BPM change of 240 BPM, twice of the initial BPM. How can we get the equivalent length in the initial tempo of 120 BPM of a quarter note in 240 BPM? First, we assume that the tempo is in terms of quarter notes. We simply find the proportion of the initial tempo to the changed tempo and multiply it by the length of the note. So we get 0.25*(120/240) = 0.125. The equivalent length is 0.125 measures.

The sdt format's time signature seems to be in 4/4 so we can be confident in our computation above. For songs with funky time signatures we can use sdt's 4 decimal point measures to compensate for that.

# Slide Patterns

## '^' Pattern

For the second difference, we have to find the direction of the slides before we can find the equivalent slide pattern. An example is simai's "^" slide pattern. It is supposed to connect a start and end position by an arc along the judgement ring. The direction of the arc whether it is clockwise or counter-clockwise is determined by which direction produces a shorter arc. I first approached this problem thinking it's a modular arithmetic problem because I viewed the locations of the buttons as a clock. The simpler approach is to think it as a simple geometric problem.

First is to find the two possible distances (CW and CCW) between the start and end positions. That's simply the absolute value of the difference of end and start position (we'll call the **first difference**), and the absolute value of the difference between the total length and the first difference (we'll call this **other difference**). Next is to find which rotation is associated with which distance. For a clockwise rotation, if the start position is greater than the end position then the first difference must be greater than the other difference; or if the start position is less than the end position, then the first difference must be less than the other difference. If neither satisfies then the shortest arc must be a counter-clockwise rotation.

### Example

Given the slide note `6^3`

, the first difference is |3 - 6| = 3, the other difference is |8 - 3| = 5. Our start position is greater than our end position, and the other difference is greater than the first difference; therefore, the slide goes counter-clockwise. In sdt, a counter-clockwise arc along the judgement ring has a slide pattern value of 2.

## 'V' Pattern

For the simai 'V' slide pattern, we also determine whether the arc goes clockwise or counter-clockwise. This is done by getting the first and second point (not the end point) and find whether it is clockwise or counter-clockwise. We can reuse our simple algorithm above for finding the rotation. In my program, we discard the second point and only use it to find the rotation. Sdt format only allows the second point to be two places away from the starting point unlike simai where the second point can be set.

We can probably get around this in sdt by defining two straight slide: start to second point, second point to end point. The total duration of the two must be equal to the duration of the 'V' slide. The rest note of the second slide must be equal to the duration of the first slide so it will start to move only when the first slide is finished.

### Example

Given the slide note `1V74`

, we find the rotation of the slide by getting the first and second point, 1 and 7. Using the previous algorithm, the first difference and second difference are 6 and 2, respectively. Our second point is greater than our first slide, and the first difference is greater than our second difference; therefore our rotation is counter-clockwise. An equivalent counter-clockwise sdt slide of 'V' is 11.

# Ending thoughts

This post just explains a small part of the conversion that happens between simai to sdt. I've hastily put the Python program together with this blog post, so I hope that people who wants to convert a simai file to sdt can find it useful. In the next post I'll finally discuss about the binary versions of the Maimai chart formats and how to convert to and from the two formats.

Until then, I hope you learned something and I'll see you next time.