Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Fruity Slicer #158

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Conversation

ashduino101
Copy link

This adds a plugin data parser for the generator plugin Fruity Slicer.

pyflp/plugin.py Outdated
"""The BPM (beats per minute) of the sample."""

pitch_shift = _NativePluginProp[int]()
"""Pitch shift, in cents. Linear, 1:1.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linear and 1:1 is the same thing. Remove 1:1.

I plan on creating a glossary section in my docs which explains all these terms.

Copy link
Owner

@demberto demberto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the changes mentioned, you alsoe need to:

  • Import and add FruitySlicer here
  • Add a test preset and add unit tests for it.

If you feel that one of the existing or a new construct adapter can be used, let me know.

pyflp/plugin.py Outdated

| Type | Value | Representation |
|---------|--------|--------------------------|
| Min | -20000 | 25% / 60 bpm to 240 bpm |
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a shorter 60-240 BPM for all 3 of them

pyflp/plugin.py Outdated
animate = _NativePluginProp[bool]()
"""Whether to highlight the slices as they are played."""

starting_note = _NativePluginProp[int]()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shorter name start_note

),
"fade_in" / c.Int32ul,
"fade_out" / c.Int32ul,
"file_path" / c.PascalString(c.Int8ul, "utf-8"),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a VarInt prefixed string. If 2 bytes are used to encode a path having >127 characters then its definitely VarInt prefixed.

pyflp/plugin.py Outdated
/ c.PrefixedArray(
c.Int32ul,
c.Struct(
"name" / c.PascalString(c.Int8ul, "utf-8"),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checked these, the file path does seem to be a u8, but interestingly, the slice name field seems to be a bit unusual. The name is capped at 257 bytes, but it uses a different size format that seems to adapt to the actual length of the string. From what I can tell, the first byte is either the length of the string or 0xFF to indicate that the length is actually defined by the next four bytes (a u32). For example, hex 40 would indicate a string of 64 bytes, and the size field would only take up one byte. However, hex ff01010000 would indicate a string of 257 bytes, and the size field would take up five bytes, the first simply defining the next four as the size. I haven't checked, and it doesn't really matter for this purpose, but it might be possible that this could extend to a u64 as well using the same pattern. Perhaps an adapter (AdaptiveInteger?) could be implemented for this?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is legit weird. Whatever could have stopped IL from using a VarInt instead? An adapter isn't enough here. We need a Construct subclass here.
Also are you sure about the file path? Windows allows path names upto 32767 characters with the 260 limitation removed. It might be that the file_path uses the same encoding as slice name

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file path does seem to be limited to 255 characters, but it gets weirder -- attempting to load a sample with a longer path results in FL Studio itself crashing with the memory error free(): invalid next size (normal). I tested this in both FL 20 and 21 with the same result. It's probably safe to say that the path is a u8, but if you can't reproduce this, I'm not sure what's going on here.

Copy link
Owner

@demberto demberto Jul 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get no such error in FL Studio 20.8.3.2304 - either while loading, or saving the project, or even re-opening the project.
image
This is how the file path was serialised, in the form of old 8.3 format using the ~1 hack.

The full path is:

F:\ABCABCABCABCABCABCABCABCABCABCABCABCABCBACBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBBABCBBCBABCBC\ABCABCABCABCABCABCABCABCABCABCABCABCABCBACBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBBABCBBCBABCBC\ABCABCABCABCABCABCABCABCABCABCABCABCABCBACBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBABCBBABCBBCBABCBC\DJAY...

There is a setting on Windows to remove the 260 limitation. Have you enabled it?
https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do have enabled, but I believe the reason it was crashing may have been due to Wine (I run Linux). With a unique file path of 259 characters, it seemed to use the same format as the slice names (the data field was FF 03 01 00 00). I assume maybe it shortens paths that are 260 characters or longer, but keeps paths that are longer than 260 characters the same, where this obscure format is only used for paths between 255 and 259 characters.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright the length doesn't matter here, our construct will just need to check if the FF marker exists (and parse the next 4 bytes if it does).

pyflp/plugin.py Outdated
),
),
"animate" / c.Flag,
"starting_note" / c.Int32ul,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shorter name start_note

@demberto demberto changed the title Fruity Slicer plugin parser feat: Fruity Slicer Jul 2, 2023
@demberto demberto marked this pull request as draft July 2, 2023 11:24
@demberto demberto added enhancement New feature or request plugin-native FL Studio native generators and effects labels Jul 2, 2023
@demberto demberto added this to the 2.3.0 milestone Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request plugin-native FL Studio native generators and effects
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants