Re: [seq24-users] [patch] resize events (req. for approval)
Brought to you by:
rcbuse
|
From: <seq...@li...> - 2005-12-21 18:32:58
|
don't like my patch?
ok this is really dirty coding:
+ int first_ev = 0x7fffffff;
+ int last_ev = 0x00000000;
but how do I find first and last selected events more quickly (or more cleanly)?
btw, since would be better to have both options, I think we can do: when SHIFT is pressed call my hacked grow_selected() function, otherwise call the original grow_selected(), so users won't get surprises.
I'm going to make this change and eventually resubmit the patch.
please, if you are interested, give me some feedback.
I sent this patch not for the glory. I simply needed a place to store the (little) work I did for *my* needs.
if no-one is interested in testing, nor you Rob aren't interested in inserting my code into seq24, I can simply keep this modified tree of seq24 on my hdd, so I would be more free to modify this software, and I don't need to complain about anithing...
hoping I am not wasting my time...
--
Federico
seq...@li... ha scritto:
> I made some tweaking on sequence.cpp
>
> basically I needed a stretch function, because I don't like playing
> keyboard following a metronome, so I have to record some "freestyle"
> notes and then stretch to the song tempo.
>
> since I have no idea on how to implement this as a NEW function, i
> hacked the old sequence::grow_selected() function.
>
> compiling with -DMIDDLEBTN_RESIZE_EVENTS should activate this hack
>
> i hope could be usefoul to someone else, and that will be some way
> inserted in the official release
>
> happy sequencing ;)
>
>------------------------------------------------------------------------
>
>--- seq24-0.7.0/src/sequence.cpp 2005-08-23 06:37:46.000000000 +0200
>+++ seq24-0.7.0_ff0/src/sequence.cpp 2005-11-16 20:00:28.000000000 +0100
>@@ -857,8 +857,75 @@ sequence::move_selected_notes( long a_de
> }
>
>
>+#define MIDDLEBTN_RESIZE_EVENTS
>+#ifdef MIDDLEBTN_RESIZE_EVENTS
>
>+/* resize selected block */
>+void
>+sequence::grow_selected( long a_delta_tick )
>+{
>+ event *on, *off, new_on, new_off;
>+
>+ lock();
>+
>+ list<event>::iterator i;
>+
>+ int old_len = 0, new_len = 0;
>+ int first_ev = 0x7fffffff;
>+ int last_ev = 0x00000000;
>+
>+ for ( i = m_list_event.begin(); i != m_list_event.end(); i++ ){
>+ if ( (*i).is_selected() &&
>+ (*i).is_note_on() &&
>+ (*i).is_linked() ){
>+
>+ on = &(*i);
>+ off = (*i).get_linked();
>
>+ if (on->get_timestamp() < first_ev) {
>+ first_ev = on->get_timestamp();
>+ }
>+ if (off->get_timestamp() > last_ev) {
>+ last_ev = off->get_timestamp();
>+ }
>+ }
>+ }
>+
>+ old_len = last_ev - first_ev;
>+ new_len = old_len + a_delta_tick;
>+ float ratio = float(new_len)/float(old_len);
>+
>+ if(new_len > 1) {
>+
>+ for ( i = m_list_event.begin(); i != m_list_event.end(); i++ ){
>+ if ( (*i).is_selected() &&
>+ (*i).is_note_on() &&
>+ (*i).is_linked() ){
>+
>+ on = &(*i);
>+ off = (*i).get_linked();
>+
>+ /* copy & scale event */
>+ new_on = *on;
>+ new_on.unselect();
>+ new_on.set_timestamp( long((on->get_timestamp() - first_ev) * ratio) + first_ev );
>+ new_off = *off;
>+ new_off.unselect();
>+ new_off.set_timestamp( long((off->get_timestamp() - first_ev) * ratio) + first_ev );
>+
>+ add_event( &new_on );
>+ add_event( &new_off );
>+ }
>+ }
>+
>+ remove_selected();
>+ verify_and_link();
>+ }
>+
>+ unlock();
>+}
>+
>+#else
>
> /* moves note off event */
> void
>@@ -905,6 +972,8 @@ sequence::grow_selected( long a_delta_ti
> unlock();
> }
>
>+#endif // MIDDLEBTN_RESIZE_EVENTS
>+
>
> void
> sequence::increment_selected( unsigned char a_status, unsigned char a_control )
>
>
|