Time intervals between midi commands
My heart beat sensor sends a midi command (127) with every beat via a virtual midi cable.
I want to measure and visually (later acoustically) plot the heart rate over time in max.
I have a button driving the timer and get time intervals in ms (which I convert to HR) in
number every time I hit button. But when I hook up midiin to the button, the button blinks
and sends a bang but timer doesn' work any more. Would sure appreciate some help on this, thanks.

Midiin puts out raw midi data. You have to 'format' this data in any case. Connect 'midiin' to a 'midiparse' object and see what data you get.
thanks, couldn't get anything out of the parser. midiin does trigger a bang out of a button, which hooked to the right port of timer sends the interval between bangs to number but adds them together and I need them
separate.

You can't send only a single int 127 over midi.
midi protocol requires a valid message.
Just a guess, and I haven't thought it through carefully, but is the heart rate sensor sending MIDI note messages with velocities of 127, with a note-off message immediately before each subsequent note-on? Because I think that would result in the [timer] appearing to not work when it's actually timing the gap b/w each note-off and the following note-on. And the number box after[midiin] would show 127, too... I think. Even if that's wrong the first thing I'd check is exactly what's coming out of [midiin].
yes midiin does at times send midi msgs consisting of individual int values, so the timing between those values could theoretically be 0 hence the timer output. If you midiparse first those messages, maybe use threshold 1, maybe select only noteon, i don't know ; it might work better. Try to see what's hapening with print connected to midiin.
Timers are no problem at all, but lacking knowledge of midi protocol, and midiin object.
midiin outputs a stream and not a list which would create a single bang per incoming message.
for each note it is 3 bytes - channel pitch and velocity, means 3 bangs get created
very fast, resulting in timer output 0.
Assuming that really proper midi note messages are sent,
a beginner would use notein object and match note and velocity
to create bang, because it is easier that way.
If one has so much simpathy for midiin object, than either midiparse
or simply thresh, followed by match
here 2 examples assuming midi note is C3 (48)

If that is the ONLY midi message which gets ever received, and does not need to be recognised among other ones, even a simple sel 127 would have worked ...

when i look at the first picture i see a button which receives the midiin-input twice.
or - in regards of what source audio said about midi notes - actually it is receiving 4 messages.
then the time difference measured by timer is mostly 0.0, - that is correct.
Thank you all.
Thank you Source Audio for the explanation on midi input streams, I think that was the problem and I will work on this.
In the meantime I have a workaround with a delay to the left timer input which is perhaps not very elegant but works.
Can someone please tell me how to "connect" the dots in the display to give a solid line?

what is the object used to display the dots ? if it is multislider, i think you cannot make such line. Use plot~ instead (be warned ; it's not that easy to use !...) or maybe function could help too. But first try the style "line scroll" this may be enough for your needs !
line scroll has different display modes, dotted or like regular sliders. the latter is not a line but looks more like a line than dots. :)
thank you, yes it's multislider (only dots or bars, too slow). looking
for something that turns data - not audio - into a scrolling waveform.
will post under a new description
Function, as allready suggested would work.
Here is simulating patch, creating random intervals
You can tweak attributes as you need.
Thanks for taking the time to do that! Works great with metro or button but as soon as I hook up the midi loop it counts beats at increments of 12! Must be what you talked about above with midi sending out multiple beats?
[lcd], sending values as floats plus 3 additional interpolated values in between?
there will be a bunch of medium straight forward jitter-based solutions, too.
we all want waveform~ to work with tapin~, dont we.
As I took a bit time to help you, you should invest a bit time to understand how delay, midiin etc work.
This here from your patch

is simply wrong.
I posted in my 2nd reply screenshots of working solutions, why don't you use that ?
and now to the explanation :
raw midi for note message contains 3 bytes for each note message
being note on or off.
starting with status byte which starts with 144 for note message on channel 1,
145 channel 2 etc, following 2 bytes are note number and velocity.
144 33 127 = midi note 33 with velocity 127 on midi channel 1.
Note off gets sent either as 144 33 0, or 128 33 nn for release velocity type.
If that heart beat detector sends a short midi note on, note off
than you would receive 6 bytes from midiin, and each of them will trigger timer's
right inlet which sets end of measured interval.
delay outputs only on last received byte, but starts new interval measurement.
the fact you trigger the counter 12 times per heart beat means that that detector sends 2 notes per detected beat.
The reason could be badly programmed software, or maybe it has some purpose ?
I hope this infos will help you .
--------
You must monitor and detect what that sensor really sends in order to
create only 1 bang when heart beat gets detected.
connect print to midiin, and watch max console.
Post the result here.
To filter out double sent notes, I would insert delay 200 at the
match output , because 200ms is 300 BPM, and no human would have heart beat
that fast

OK, finally got it! Thanks for your time and patience! My next step is to plot BPM.

That looks nice.
Should not cost much time to add BPM plot
There is one thing you need to change.
I inserted split 0. 1500. because very first output of timer
as well as triggers coming in after a pause will allways be too long.
So to filter them out also for BPM display, connect outlet of split object to expr .
it still makes me wonder what that sensor is sending ....
set split to 150
