def uds_contour(data):
	"""
	Returns the for "up-down-stay" contour (UDS) of a given list of MIDI tones. Normalized
	to start at 0.

	:param list data: a list of MIDI tones.
	:return: a numpy array of the UDS contour of the given data.
	:rtype: numpy.array

	>>> midis = [47, 42, 45, 51, 51, 61, 58]
	>>> uds_contour(midis)
	[0, -1, 1, 1, 0, 1, -1]
	"""
	out = [0]
	i = 1
	while i < len(data):
		prev = data[i - 1]
		curr = data[i]

		if curr > prev:
			out.append(1)
		elif curr < prev:
			out.append(-1)
		elif curr == prev:
			out.append(0)

		i += 1

	return out