raise i (N (l,o,a,h,d)) = N (succ' i l, o + octChange, a - offset, h, d)
  where notesToOctBorder = fromIntegral . length . takeWhile (/=B) . iterate (succ' 1) $ l -- num notes before octave number changes
        nonOctaveNotes = i `mod` 7 -- number of notes that are not part of straight octave increases
        numOctavesAdded = i `div` 7 -- number of octaves added
        octaveBorderCrossed = nonOctaveNotes > notesToOctBorder -- do we cross the octave border?
        oneSteps = fromIntegral . length . filter (`elem`[C,F]) . map (`succ'` l) $ [1..nonOctaveNotes] -- how many one steps in the non octave part?
        offset = oneSteps + 2*(nonOctaveNotes - oneSteps) + 12*numOctavesAdded -- the total offset
        octChange = numOctavesAdded + if octaveBorderCrossed then 1 else 0 -- total octave change
raise i (N (l,o,a,h,d)) = N (succ' i l, o + octChange, a - offset, h, d)
  where notesToOctBorder = fromIntegral . length . takeWhile (/=B) . iterate (succ' 1) $ l -- num notes before octave number changes
        nonOctaveNotes = i `mod` 7 -- number of notes that are not part of straight octave increases
        numOctavesAdded = i `div` 7 -- number of octaves added
        octaveBorderCrossed = nonOctaveNotes > notesToOctBorder -- do we cross the octave border?
        oneSteps = fromIntegral . length . filter (`elem`[C,F]) . map (`succ'` l) $ [1..nonOctaveNotes] -- how many one steps in the non octave part?
        offset = oneSteps + 2*(nonOctaveNotes - oneSteps) + 12*numOctavesAdded -- the total offset
        octChange = numOctavesAdded + if octaveBorderCrossed then 1 else 0 -- total octave change
raise i (N (l,o,a,h,d)) = N (succ' i l, o + octChange, a - offset, h, d)
  where notesToOctBorder = fromIntegral . length . takeWhile (/=B) . iterate (succ' 1) $ l -- num notes before octave number changes
        nonOctaveNotes = i `mod` 7 -- number of notes that are not part of straight octave increases
        numOctavesAdded = i `div` 7 -- number of octaves added
        octaveBorderCrossed = nonOctaveNotes > notesToOctBorder -- do we cross the octave border?
        oneSteps = fromIntegral . length . filter (`elem`[C,F]) . map (`succ'` l) $ [1..nonOctaveNotes] -- how many one steps in the non octave part?
        offset = oneSteps + 2*(nonOctaveNotes - oneSteps) + 12*numOctavesAdded -- the total offset
        octChange = numOctavesAdded + if octaveBorderCrossed then 1 else 0 -- total octave change