AppleScript doesn't have anything automatic like that. It would be up to you to keep track of what the previous value was, compare/update to what it is now, and take the appropriate action. You don't mention how the script is called or any state you are keeping, but your snippet would be something like:
property previous : missing value -- keep track of the previous value
if previous is missing value then set previous to item 3 of message -- initial value
-- other stuff
if item 1 of message = 176 then
if item 2 of message = 97 then
set change to (item 3 of message) - previous -- get any difference
if change < 0 then set change to -change -- absolute value
if change is not 0 and change = 1 then -- or whatever threshold comparison
set previous to item 3 of message -- update
tell application "System Events"
key code 126
-- other stuff
end tell
end if
end if
end if
I don't have MidiPipe to test, but if the script won't keep persistent properties, you will need to do something like read from a file or use NSUserDefaults
to keep the value of the previous
variable between runs.