Skip to content

Commit

Permalink
Laying groundwork for data event grab handles.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahlstromcj committed Sep 5, 2023
1 parent ecfcc29 commit c9c62d8
Show file tree
Hide file tree
Showing 10 changed files with 271 additions and 28 deletions.
4 changes: 3 additions & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
TO DO for Seq66 0.99.9
Chris Ahlstrom
2019-04-13 to 2023-09-04
2019-04-13 to 2023-09-05

Misc:

- Open t.midi, start playing, stop, then add more notes. They are
way longer than the snap value!
- When enabling a MIDI Control/Display port, also enable it
automatically. See issue #116.
- Fix and test new record/quantize handling, and verify that
MIDI automation of these displays in the pattern editor.
- Add automation for these and add some to nanomap.ctrl:
Expand Down
8 changes: 7 additions & 1 deletion doc/latex/tex/references.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
% \library Documents
% \author Chris Ahlstrom
% \date 2015-08-31
% \update 2023-06-30
% \update 2023-09-05
% \version $Revision$
% \license $XPC_GPL_LICENSE$
%
Expand Down Expand Up @@ -175,6 +175,12 @@ \section{References}
\url{https://www.rncbc.org/drupal/node/76}.
2008.

\bibitem{piseq}
sferamusic
\emph{HOW-TO: DIY hybrid Sequencer / MIDI USB Hub ....}
\url{https://www.rncbc.org/drupal/node/7://steemit.com/music/@sferamusic/how-to-diy-hybrid-sequencer-midi-usb-hub-aka-piseq-using-raspberry-pi-and-external-midi-controllers-part-1}.
2017.

\bibitem{portmidi}
PortMedia team.
\emph{Platform Independent Library for MIDI I/O.}
Expand Down
25 changes: 23 additions & 2 deletions libseq66/include/midi/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2015-07-24
* \updates 2023-09-01
* \updates 2023-09-05
* \license GNU GPLv2 or above
*
* This module also declares/defines the various constants, status-byte
Expand All @@ -52,6 +52,8 @@

#include "midi/midibytes.hpp" /* seq66::midibyte alias, etc. */

#undef SEQ66_STAZED_SELECT_EVENT_HANDLE /* nowhere near ready! */

/**
* Defines the number of data bytes in MIDI status data.
*
Expand Down Expand Up @@ -584,6 +586,11 @@ class event
return mask_status(m) == EVENT_CONTROL_CHANGE;
}

static bool is_note_on_msg (midibyte m)
{
return m >= EVENT_NOTE_ON || m < EVENT_AFTERTOUCH;
}

/**
* Static test for messages that involve notes only: Note On and
* Note Off, useful in note-event linking.
Expand Down Expand Up @@ -1286,6 +1293,16 @@ class event
return is_selected() && is_note_on();
}

bool is_controller () const
{
return is_controller_msg(m_status);
}

bool is_pitchbend () const
{
return is_pitchbend_msg(m_status);
}

bool is_playable () const
{
return is_playable_msg(m_status) || is_tempo();
Expand All @@ -1297,7 +1314,11 @@ class event
}

bool is_desired (midibyte status, midibyte cc) const;
bool is_desired_ex (midibyte status, midibyte cc) const; /* EXPERIMENT */
#if defined SEQ66_STAZED_SELECT_EVENT_HANDLE
bool is_data_in_handle_range (midibyte target) const;
bool is_desired (midibyte status, midibyte cc, midibyte data) const;
#endif
bool is_desired_ex (midibyte status, midibyte cc) const;

/**
* Some keyboards send Note On with velocity 0 for Note Off, so we
Expand Down
8 changes: 8 additions & 0 deletions libseq66/include/midi/eventlist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,14 @@ class eventlist
midipulse tick_s, midipulse tick_f,
midibyte status, midibyte cc, select action
);
#if defined SEQ66_STAZED_SELECT_EVENT_HANDLE
int select_event_handle
(
midipulse tick_s, midipulse tick_f,
midibyte astatus, midibyte cc,
midibyte data
);
#endif
int select_note_events
(
midipulse tick_s, int note_h,
Expand Down
9 changes: 8 additions & 1 deletion libseq66/include/play/sequence.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2015-07-30
* \updates 2023-08-31
* \updates 2023-09-05
* \license GNU GPLv2 or above
*
* The functions add_list_var() and add_long_list() have been replaced by
Expand Down Expand Up @@ -1708,6 +1708,13 @@ class sequence
(
midibyte status, midibyte cc, bool inverse = false
);
#if defined SEQ66_STAZED_SELECT_EVENT_HANDLE
int select_event_handle
(
midipulse tick_s, midipulse tick_f,
midibyte status, midibyte cc, eventlist::select action
);
#endif

/**
* New convenience function. What about Aftertouch events? I think we
Expand Down
38 changes: 38 additions & 0 deletions libseq66/src/midi/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,44 @@ event::is_desired (midibyte status, midibyte cc) const
return result;
}

#if defined SEQ66_STAZED_SELECT_EVENT_HANDLE

bool
event::is_data_in_handle_range (midibyte target) const
{
static const midibyte delta = 2; /* seq32 provision */
static const midibyte max = c_midibyte_value_max - delta;
midibyte datum = is_one_byte() ? d0() : d1() ;
bool result = target >= delta && target <= max;
if (result)
result = datum >= (target - delta) && datum <= (target + delta);

return result;
}

bool
event::is_desired (midibyte status, midibyte cc, midibyte data) const
{
bool result;
if (is_tempo_status(status))
{
result = is_tempo();
}
else
{
result = mask_status(status) == mask_status(m_status);
if (result && (event::is_controller_msg(status)))
{
result = m_data[0] == cc;
if (result)
result = is_data_in_handle_range(); /* check d0/d1() */
}
}
return result;
}

#endif // defined SEQ66_STAZED_SELECT_EVENT_HANDLE

/**
* We should also match tempo events here. But we have to treat them
* differently from the matched status events.
Expand Down
Loading

0 comments on commit c9c62d8

Please sign in to comment.