Skip to content

✨ Possible to change length, position and offset of an audio sample #97

Closed

Description

@jubabrut

Describe the feature

When I try to change position or length of an audio clip in the Playlist, with that code

tracks = [track for track in project.arrangements.current.tracks]
tracks[2].__getitem__(0).position = 100

I have this error
pyflp.exceptions.PropertyCannotBeSet: Event(s) () was / were not found

It will be interesting to be able to change the position, the length and the offset of an audio clip

image

What version of PyFLP are you using?

last commit (27th oct 22)

Screenshots, Additional info

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. self-assigned this
    on Oct 27, 2022
  2. demberto commented on Oct 27, 2022

    @demberto
    Owner

    While actually I have not implemented this, the exception was a result of a bug in here:

    PyFLP/pyflp/_descriptors.py

    Lines 121 to 129 in 5034910

    @final
    def __set__(self, instance: Any, value: T):
    if self._readonly:
    raise PropertyCannotBeSet(*self._ids)
    event = self._get_event(instance)
    if event is not None:
    self._set(event, value)
    raise PropertyCannotBeSet(*self._ids)

    This was quite a big bug making nearly everything unsettable. This reminds me of testing the setters as well.

  3. demberto commented on Oct 27, 2022

    @demberto
    Owner

    Technically it is settable via the huge PlaylistEvent but that needs low-level API knowledge

  4. added this to the PyFLP 2.0.0 milestone on Oct 27, 2022
  5. demberto commented on Oct 27, 2022

    @demberto
    Owner

    Done, implemented in latest commits. New release comming soon 🎉

  6. jubabrut commented on Oct 27, 2022

    @jubabrut
    Author

    Thanks
    perfect it works too
    what is the difference between the length and the offset (end minus start) ?

    Moreover I don't understant the "end value"
    because I created the smallest audio clip possible

    image

    And this is the offset value
    offset : (0, 1084851705)
    length : 1

  7. demberto commented on Oct 27, 2022

    @demberto
    Owner

    Start Offset:

    start_offset

    Length is the length of the item as it is visible to you in the playlist.
    End offset is the internal position from the end of a sample or a pattern. Now you might think that start_offset + length is enough for that, why another field?

    And the answer to this is, I don't know myself 😄 FLP is a weird format.

  8. demberto commented on Oct 27, 2022

    @demberto
    Owner

    @jubabrut Will it possible for you to test PyFLP and find out bugs and suggest new ideas like these? Doing so will be a great help for me and will fasten the release cycle. A stable version will be ready sooner 🤗

  9. jubabrut commented on Oct 28, 2022

    @jubabrut
    Author

    Do you know how the offset value is construct ?
    Right now I don't fina logic with a value like 1174289603

    Did you notice a full audio clip offset are (-1082130432, -1082130432), so weird

    For the moment I try PyFLP and discover all features, that's why I find some bugs on different functionnalities.
    But yes I wiil try to pass more time on this project in order to help you to increase the release cycle and find bugs.

    What is your goal with this library? Because it is a huge work
    For me my wish list will be to be able to generate music with AI but it seems complicated today to created channel, pattern, etc. directly with the program

  10. demberto commented on Oct 28, 2022

    @demberto
    Owner

    Do you know how the offset value is construct ? Right now I don't fina logic with a value like 1174289603

    Did you notice a full audio clip offset are (-1082130432, -1082130432), so weird

    I need to take a look at it, maybe its incorrectly parsed, maybe it is a float, maybe it is not an absolute value at all.

    What is your goal with this library? Because it is a huge work

    At first, I aim to make all existing structures parseable and editable. I try to find the representations of various quantities like the TimeStretching.time feature you had problems with. That is the hardest part.

    I am also looking at the ability to clone or add certain entities like channels or MIDI notes for example. Once things like channels can be cloned, you can play with the values and modify them to your liking.

    Some particular areas needing work are:

    • MIDI and Internal controllers
    • Patterns
    • Automation clips

    I generally try to add features when I am genuinely sure that the integrity of existing data is not compromised. PyFLP guarantees to not touch the data you didn't modify. FL studio on the other hand, rewrites everything from scratch, since it knows how the format works entirely.

    PyFLP is not an FL Studio replacement. It can most certainly be used in project file converters and real-world DAWs that aim to support FLP format (if they ever get written in Python 😄)

  11. jubabrut commented on Oct 28, 2022

    @jubabrut
    Author

    Ok because I really don't understand how to use offset value.
    Look at this example, that has no sense
    PyFLP test 4.zip

    image

    Track 0
    1536 ==> length
    (-1082130432, -1082130432)
    Difference: 0 ==> end - start
    
    Track 1
    384
    (0, 1134572607)
    Difference: 1134572607
    
    Track 2
    384
    (1134572607, 1142961215)
    Difference: 8388608
    
    Track 3
    384
    (1142961215, 1148210782)
    Difference: 5249567
    
    Track 4
    384
    (1148210782, 1151349637)
    Difference: 3138855
    

    About TimeStretching.time it is interesting because in fact I searched a solution by using Python, to solve a problem I have with FL Studio. (A bug is open by Image Line because strange behovior happens when you switch a sample with different BPM. Position, length and offset change randomly).

  12. demberto commented on Oct 28, 2022

    @demberto
    Owner

    (A bug is open by Image Line because strange behovior happens when you switch a sample with different BPM. Position, length and offset change randomly).

    FL has grappled with timing issues since eternity 😄

    Ok because I really don't understand how to use offset value.

    I think its interpreted incorrectly (might be a float, might be PPQ dependant, dunno). But atleast the start, end values seem to match up with the arrangement. I will take a look at this. You will have better luck if you look at the individual bytes instead of these integers, use int.to_bytes(value, 4, "little")

  13. jubabrut commented on Oct 28, 2022

    @jubabrut
    Author

    I really don't understand how to use to_bytes
    it gives me something like

    Track 1
    b'\x00\x00\x00\x00'
    b'?4\xa0C'
    
    Track 2
    b'?4\xa0C'
    b'?4 D'
    
    Track 3
    b'?4 D'
    b'^NpD'
    
  14. demberto commented on Oct 28, 2022

    @demberto
    Owner

    Yes sorry I meant

    tuple(int.to_bytes(value, 4, "little"))

    which will give you something like

    (1, 2, 3, 4)

    Now you get 4 numbers instead of one and maybe it can help you find out some relation between the arrangement and them.
    Although I don't think there's anything useful out of these numbers, maybe they represent a quantity I don't know about.

  15. jubabrut commented on Oct 29, 2022

    @jubabrut
    Author

    do other python libraries provide the same result for offsets?

  16. demberto commented on Oct 29, 2022

    @demberto
    Owner

    Wdym? There are no other Python libraries which can parse FLPs to the best of my knowledge. This implementation of playlist item offsets is from MonadGroup's FLParser which parses it as a float or uint32 as well.
    I think i initially parsed it as float as well and got similar results. The playlist items are locked to the resolution of the PPQ (unlike automation points, which are completely free), so I think float would be too accurate for that and waste space

  17. jubabrut commented on Oct 29, 2022

    @jubabrut
    Author

    I was just thinking about FLParser but I didn't test that library
    Thanks again for the time and your patience.

  18. jubabrut commented on Oct 29, 2022

    @jubabrut
    Author

    From my first constatation, the offsets values indicate the time where to cut the sample, by not taking account the arrangement, the general bpm or the time stretching.
    See below it is the same samples (the second one is time stretched) but cuted on the same location as the first one.
    And the offset end values are the same.

    It is an element to reply to the difference between offset and length.

    So I need to found a relation between
    offset end 1138116901
    the real cut at: 0,42857143 seconds (exactly in my example)

    image

  19. demberto commented on Oct 29, 2022

    @demberto
    Owner

    Interesting, I am converting this to a discussion

  20. Repository owner locked and limited conversation to collaborators on Oct 29, 2022
  21. converted this issue into a discussion #98 on Oct 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions