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

Bezier curves for automation tracks #2466

Closed
wants to merge 6 commits into from

Conversation

codythecoder
Copy link

Based on this issue, I think having bezier curves in LMMS would make automation tracks a lot more powerful, and much faster to do certain types of curves.

@tresf
Copy link
Member

tresf commented Nov 26, 2015

Some notes...

  1. The compile is failing
  2. Please squash your commit history
  3. Why are the mingw scripts changed in this? Can you please explain or remove?

@softrabbit
Copy link
Member

Looks like the windows builds are failing, that's what you get when you remove the execute bit on build scripts...

@codythecoder
Copy link
Author

I've fixed the compile problems. I must've accidentally done something to the windows build scripts so I just copied the master branch's code over.
I'm not sure how to squash my commit history. I think I squashed it a bit, but now things aren't working and I'm not sure what to do. When I type git rebase -i HEAD~4 it shows much more than 4 commits, and not the ones I want. If someone could help with this or point me in the right direction that would be great.

@tresf
Copy link
Member

tresf commented Dec 23, 2015

@codythecoder first, backup the files you've changed.

Then rewind your branch. One way to do this is a git reset --hard abcdefg where abcdefg is a commit hash from the past that you'd have in your fork.

Next, fast-forward your branch to have the latest from upstream.

Last, re-apply your changes manually (commit them, force push them). Once they're on your fork, this PR will be updated automatically.

That's not to say your existing commits can't be resurrected, but a bad rebase is hard to unwind, sometimes it's easier to just start from scratch. 👍

@codythecoder
Copy link
Author

Can someone help me figure out what's going on with the build fails? It's giving me warnings about packages not being authenticated, but I'm not sure how to fix this or what I could have done to cause this. After this is solved, it should be ready to merge with master.

@zonkmachine
Copy link
Member

make clean?

@tresf
Copy link
Member

tresf commented Jan 25, 2016

Can someone help me figure out what's going on with the build fails?

@codythecoder, I re-started the Travis-CI builds. I don't think the errors are related to your commit specifically. Let's see if they're in better shape in a few minutes here.

@codythecoder
Copy link
Author

Cool, so that works now. I just realized that I still have to change one thing, which I just have to test and commit, so that will be done in a few minutes.

@codythecoder
Copy link
Author

Ok, that's all ready :)

@zonkmachine
Copy link
Member

Build failed again. I restarted it but it wouldn't work anyway...

@tresf
Copy link
Member

tresf commented Jan 25, 2016

Yeah, Travis is having some technical difficulties. There's a GPG key here which is unreachable at the moment, causing some dependencies to fail, thus false-positively failing the tests.

This missing Canonical/Ubuntu GPG key is affecting all builds which are Ubuntu-derived (QT4, QT5, Win32, Win64). Apple isn't affected since it uses Homebrew for all of its dependencies. Ubuntu 12.04 ("Precise") isn't EOL until April 2017 so the mirrors should be up for another 15 months. Simply re-running the Travis build process again a bit later will likely resolve this. 👍

@tresf
Copy link
Member

tresf commented Jan 25, 2016

Travis-CI is passing. 👍

@codythecoder
Copy link
Author

I'm all done with this, when can we get this merged?

@grejppi
Copy link
Contributor

grejppi commented Jan 28, 2016

@codythecoder Is it intentional that when you move a point its handles will reset?

@codythecoder
Copy link
Author

@grejppi Yes, when I wrote it, it was intentional. Getting the dragging to work was one of the first things I had to do, and due to how point dragging is normally done, I thought it would be impossible to get the control points to move along with the automation point, and I just forgot about it.
After a bit of looking around, I think it might be possible to get the control points to move with the automation point in a way that feels more natural. I'll spend a couple of days to see if I can find a way to get this up.

@codythecoder
Copy link
Author

I've got it to drag the control points along with the automation points, I think that's everything, but if people could test it while I fix the conflicts, that would be great.

@zonkmachine
Copy link
Member

This pull request has merge conflicts and needs to be rebased against current master.

@tresf
Copy link
Member

tresf commented Apr 5, 2016

test it while I fix the conflicts, that would be great.

This pull request has merge conflicts and needs to be rebased against current master.

😆

@zonkmachine
Copy link
Member

test it while I fix the conflicts, that would be great.

    This pull request has merge conflicts and needs to be rebased against current master.

😆

Still, it's well within my usual margin of error...

but if people could test it

It crashes for me. Both rebased and in present form. I'll try and add some debug data later.

@zonkmachine
Copy link
Member

Crashes when I click in the autmation pattern.

ASSERT failure in QVector<T>::operator[]: "index out of range", file /usr/include/qt4/QtCore/qvector.h, line 359
Aborted (core dumped)

Backtrace

(gdb) bt
#0  0x00007fb04102ecc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007fb0410320d8 in __GI_abort () at abort.c:89
#2  0x00007fb043798c92 in qt_message_output(QtMsgType, char const*) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#3  0x00007fb043798ff9 in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#4  0x00007fb043799804 in qFatal(char const*, ...) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#5  0x00000000004e4fe5 in QVector<float>::operator[] (this=0x346f788, i=1) at /usr/include/qt4/QtCore/qvector.h:359
#6  0x00000000004de5bc in AutomationPattern::setDragValue (this=0x7fb037d7fea0, _time=..., _value=50,6000023, _quant_pos=true)
    at /home/zonkmachine/builds/lmms/lmms/src/core/AutomationPattern.cpp:344
#7  0x00000000005b3f80 in AutomationEditor::mousePressEvent (this=0x2c7ada0, mouseEvent=0x7fff826a08f0)
    at /home/zonkmachine/builds/lmms/lmms/src/gui/editors/AutomationEditor.cpp:561
#8  0x00007fb04407138b in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#9  0x00007fb044021e2c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#10 0x00007fb0440285dd in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#11 0x00007fb0438a54dd in QCoreApplication::notifyInternal(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#12 0x00007fb044027d93 in QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool) ()
   from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#13 0x00007fb04409c9eb in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#14 0x00007fb04409c289 in QApplication::x11ProcessEvent(_XEvent*) () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#15 0x00007fb0440c3b32 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#16 0x00007fb0408e0e04 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#17 0x00007fb0408e1048 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#18 0x00007fb0408e10ec in g_main_context_iteration () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#19 0x00007fb0438d27a1 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#20 0x00007fb0440c3be6 in ?? () from /usr/lib/x86_64-linux-gnu/libQtGui.so.4
#21 0x00007fb0438a40af in QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#22 0x00007fb0438a43a5 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#23 0x00007fb0438a9b79 in QCoreApplication::exec() () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#24 0x00000000004d8170 in main (argc=1, argv=0x7fff826a13b8) at /home/zonkmachine/builds/lmms/lmms/src/core/main.cpp:807
(gdb)

@codythecoder
Copy link
Author

@zonkmachine I'll have a look at that after I finish with the conflicts, since there's a chance it'll just fix itself automatically. What system are you running it on?

@zonkmachine
Copy link
Member

@zonkmachine I'll have a look at that after I finish with the conflicts, since there's a chance it'll just fix itself automatically.

Sorry! I should have mentioned that this was done rebased. Maybe I should wait to test it more until you've updated so we're working on the same source? I'll try and get some data from 1f25d1c instead.

What system are you running it on?

Linux Mint 17.3

@zonkmachine
Copy link
Member

I'll try and get some data from 1f25d1c instead.

Same result.

AutomationPattern::setDragValue (this=0x7fcededf62a0, _time=..., _value=0,559000015, _quant_pos=true)

The _time=... looks like it should have a value.

Edit: Version 1.1.90-g1f25d1c (Linux/x86_64, Qt 4.8.6, GCC 4.8.4)

@codythecoder
Copy link
Author

I think I know where the error is coming from, so I'll see if I can get it to crash for me when I have some time. My guess is that setDragValue is being called from mousePressEvent and for some reason is not being passed the time, so I'll check that out.

@codythecoder codythecoder reopened this Apr 6, 2016
@codythecoder
Copy link
Author

Oops I pressed the wrong button 😄

@tresf
Copy link
Member

tresf commented Apr 19, 2016

It's green. It had some validation issues with some packages. Had to kick start it a few times. (You're right not your fault.)

@codythecoder
Copy link
Author

@tresf cool 👍 now I guess it's just wait to see if any more problems arise?

@tresf
Copy link
Member

tresf commented Apr 19, 2016

@zonkmachine can merge if he's comfortable with it and has tested it. 👍

@zonkmachine
Copy link
Member

New crash. I got it when looping a BBTrack over four bars and modulating the cutoff on a 3osc with a bezier curve.

(gdb) bt
#0  0x00007ffff410ecc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff41120d8 in __GI_abort () at abort.c:89
#2  0x00007ffff684fc92 in qt_message_output(QtMsgType, char const*) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#3  0x00007ffff684fff9 in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#4  0x00007ffff6850804 in qFatal(char const*, ...) () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#5  0x00000000004e5511 in QVector<float>::operator[] (this=0x7fffbe0c2b90, i=1) at /usr/include/qt4/QtCore/qvector.h:355
#6  0x00000000004df3cd in AutomationPattern::valueAt (this=0x7fffeaed5ae0, v=..., offset=117)
    at /home/zonkmachine/builds/lmms/lmms/src/core/AutomationPattern.cpp:502
#7  0x00000000004decfc in AutomationPattern::valueAt (this=0x7fffeaed5ae0, _time=...)
    at /home/zonkmachine/builds/lmms/lmms/src/core/AutomationPattern.cpp:440
#8  0x00000000004e21f2 in AutomationPattern::processMidiTime (this=0x7fffeaed5ae0, time=...)
    at /home/zonkmachine/builds/lmms/lmms/src/core/AutomationPattern.cpp:807
#9  0x0000000000605584 in AutomationTrack::play (this=0x7fffeaed1ca0, _start=..., _frames=41, _frame_base=215, _tco_num=-1)
    at /home/zonkmachine/builds/lmms/lmms/src/tracks/AutomationTrack.cpp:85
#10 0x0000000000547811 in Song::processNextBuffer (this=0xc43950) at /home/zonkmachine/builds/lmms/lmms/src/core/Song.cpp:394
#11 0x00000000005238ec in Mixer::renderNextBuffer (this=0xbc6460) at /home/zonkmachine/builds/lmms/lmms/src/core/Mixer.cpp:397
#12 0x00000000005252b3 in Mixer::fifoWriter::run (this=0xe2b3a0) at /home/zonkmachine/builds/lmms/lmms/src/core/Mixer.cpp:1014
#13 0x00007ffff685a32f in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#14 0x00007ffff7bc4182 in start_thread (arg=0x7fffbe0c3700) at pthread_create.c:312
#15 0x00007ffff41d247d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
(gdb) 

bezier2fullbacktrace.txt.zip

@codythecoder
Copy link
Author

@zonkmachine If you save and load does it still crash? If it does, could you send the file to me and I can check it out. Also, could you copy this code into its spot in float AutomationPattern::valueAt( timeMap::const_iterator v, int offset ) const and tell me the last couple of numbers it prints before it crashes?

    // to make up for their range being limited.
    if ( !m_controlPoints.contains( v.key() ) )
        printf("0\n");
    printf("1\n");
    int targetX1 = ( m_controlPoints[v.key()][0] - v.key() ) * 2;
    printf("2\n");
    int targetX2 = ( 3 * (v+1).key() - 2 * m_controlPoints[(v+1).key()][0] - v.key() );
    // The y values are the actual y values. Maybe this should be doubled, 
    // but it doesn't seem necessary to me.
    float targetY1 = m_controlPoints[v.key()][1];
    float targetY2 = 2*(v+1).value() - m_controlPoints[(v+1).key()][1];
    printf("3\n");

    // To find the y value on the curve at a certain x, we first have to find the t (between 0 and 1) that gives the x

@zonkmachine
Copy link
Member

If you save and load does it still crash?

Yes

If it does, could you send the file to me and I can check it out.

beziernewcrash-01.mmp.zip

Also, could you copy this code into its spot in float AutomationPattern::valueAt( timeMap::const_iterator v, int offset ) const and tell me the last couple of numbers it prints before it crashes?

It counts 1 2 3 and never prints 0. It most often crash on 1 not as often on 2 and rarely on 3.

@codythecoder
Copy link
Author

Sorry for the silence, uni and whatnot got in the way.

If you go back to float AutomationPattern::valueAt( timeMap::const_iterator v, int offset ) const and paste the following code, what numbers (if any) does it crash on?

    // to make up for their range being limited.
    if (m_controlPoints[(v+1).key()].size() != 2)
        printf("size: %i\n", m_controlPoints[(v+1).key()].size());
    printf("1\n");
    int targetX1 = ( m_controlPoints[v.key()].at(0) - v.key() ) * 2;
    printf("2\n");
    int targetX2 = ( 3 * (v+1).key() - 2 * m_controlPoints[(v+1).key()].at(0) - v.key() );
    // The y values are the actual y values. Maybe this should be doubled,
    // but it doesn't seem necessary to me.
    float targetY1 = m_controlPoints[v.key()].at(1);
    float targetY2 = 2*(v+1).value() - m_controlPoints[(v+1).key()].at(1);
    printf("3\n");

    // To find the y value on the curve at a certain x, we first have to find the t (between 0 and 1) that gives the x

@zonkmachine
Copy link
Member

Hi, finally got the time to sit down and try this but unfortunately it works well... 😒
I can't make it crash no longer. Not with your master or when I rebase it to latest master.

@codythecoder
Copy link
Author

It's only in programming that it can be unfortunate when something works 😄 I'll push these changes anyway, maybe someone else'll have the same problem later, and hopefully this'll fix anything that would've crashed.

@zonkmachine
Copy link
Member

zonkmachine commented Aug 8, 2016

Version 1.1.90-2a4cd96 (Linux/x86_64, Qt 4.8.6, GCC 4.8.4)

zonkmachine@zonkmachine:~/builds/lmms/lmms/build$ ./lmms 
Notice: could not set realtime priority.
VST sync support disabled in your configuration
ASSERT failure in QVector<T>::at: "index out of range", file /usr/include/qt4/QtCore/qvector.h, line 351
Aborted (core dumped)

👍 Crashed when manipulating one of the control points. Just looping the track worked well.

full backtrace

zonkmachine@zonkmachine:~/builds/lmms/lmms/build$ gdb ./lmms core 
...
[New LWP 6148]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
bCore was generated by `./lmms'.
Program terminated with signal SIGABRT, Aborted.
#0  0x00007fae71e96c37 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56  ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007fae71e96c37 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007fae71e9a028 in __GI_abort () at abort.c:89
#2  0x00007fae74600c92 in qt_message_output (msgType=msgType@entry=QtFatalMsg, 
    buf=0x7fae3001fa98 "ASSERT failure in QVector<T>::at: \"index out of range\", file /usr/include/qt4/QtCore/qvector.h, line 351")
    at global/qglobal.cpp:2383
#3  0x00007fae74600ff9 in qt_message(QtMsgType, const char *, typedef __va_list_tag __va_list_tag *) (msgType=msgType@entry=QtFatalMsg, 
    msg=0x7fae7476ea48 "ASSERT failure in %s: \"%s\", file %s, line %d", ap=ap@entry=0x7fae3b7949e8) at global/qglobal.cpp:2429
#4  0x00007fae74601804 in qFatal (msg=<optimized out>) at global/qglobal.cpp:2612
#5  0x00000000004e9e49 in QVector<float>::at (this=0x7fae3b794b80, i=1) at /usr/include/qt4/QtCore/qvector.h:351
#6  0x00000000004e3cff in AutomationPattern::valueAt (this=0x7fae68be6fa0, v=..., offset=24)
    at /home/zonkmachine/builds/lmms/lmms/src/core/AutomationPattern.cpp:504
#7  0x00000000004e362e in AutomationPattern::valueAt (this=0x7fae68be6fa0, _time=...)
    at /home/zonkmachine/builds/lmms/lmms/src/core/AutomationPattern.cpp:442
#8  0x00000000004e6b2a in AutomationPattern::processMidiTime (this=0x7fae68be6fa0, time=...)
    at /home/zonkmachine/builds/lmms/lmms/src/core/AutomationPattern.cpp:810
#9  0x000000000060cac4 in AutomationTrack::play (this=0x7fae68be6da0, _start=..., _frames=252, _frame_base=4, _tco_num=-1)
    at /home/zonkmachine/builds/lmms/lmms/src/tracks/AutomationTrack.cpp:85
#10 0x000000000054c28b in Song::processNextBuffer (this=0x1ef1fd0) at /home/zonkmachine/builds/lmms/lmms/src/core/Song.cpp:395
#11 0x000000000052864c in Mixer::renderNextBuffer (this=0x1e76660) at /home/zonkmachine/builds/lmms/lmms/src/core/Mixer.cpp:415
#12 0x000000000052a0e5 in Mixer::fifoWriter::run (this=0x1eef580) at /home/zonkmachine/builds/lmms/lmms/src/core/Mixer.cpp:1081
#13 0x00007fae7460b32f in QThreadPrivate::start (arg=0x1eef580) at thread/qthread_unix.cpp:349
#14 0x00007fae75980184 in start_thread (arg=0x7fae3b795700) at pthread_create.c:312
#15 0x00007fae71f5a37d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

@zonkmachine
Copy link
Member

@codythecoder This PR has conflicts (Probably Since 41b930e).

Since it looks like it was mostly I who had issues with this PR, maybe it should be tested by someone else too? I'm off course happy to test anything you throw at me but I'd prefer it as a patch (git diff > codeToTest.patch) rather than instructions on what changes to apply.

@jrcxyz
Copy link

jrcxyz commented Jan 8, 2017

What's the news on this? This would be such an amazing feature!! Glad to see it's still in the works anywho, and thanks for the effort toward something that would be so helpful :D 🍡

@zonkmachine
Copy link
Member

What's the news on this?

That you just volonteered to test this PR. 😃

@codythecoder
Copy link
Author

News of this has been that I've been busy (and not to mention lazy) but it's probably time I finish it once and for all 😁

The only known problems remaining are: moving the control points while playing through the track will occasionally cause it to crash, and now of course it has merge conflicts.

I'll see what I can get done by the end of the week, but if you can find any other errors that's also good.

@PhysSong
Copy link
Member

PhysSong commented Sep 8, 2017

@codythecoder Are you still here? If you are, could you continue your work?

moving the control points while playing through the track will occasionally cause it to crash

Confirmed. If the OP @codythecoder is not here, maybe I can investigate it and open a new PR.
Anyway, this is great. Thank you for this work.

@codythecoder
Copy link
Author

I'll see what I can do. I'll get you more details once I get the workflow setup on my new computer.

@PhysSong
Copy link
Member

Pro Tip: Try to use QPair for control points, instead of QVector of size 2.
FYI, I've succeed to resolve conflicts and other functions works well.

@PhysSong
Copy link
Member

PhysSong commented May 1, 2018

@codythecoder Are you willing to continue working on this pull request?

@codythecoder
Copy link
Author

codythecoder commented May 2, 2018

I'll have a good look tomorrow, but I imagine so. Otherwise yeah, I'll have to rely on one of you to do it

@PhysSong
Copy link
Member

@codythecoder Then may I continue your work?

@PhysSong
Copy link
Member

Continued in #4674. @codythecoder Thank you for the code!

@PhysSong PhysSong closed this Oct 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants