Jamie,
You can easily turn your code into a multiline function:
myfunction[s1_, s2_, distfunc_, band_] :=
Module[{xcorrs1, xcorrs2, d1, d2, dist}, {xcorrs1, xcorrs2} =
CanonicalWarpingCorrespondence[s1, s2,
Automatic, {"SlantedBand", band},
Method -> {"MatchingInterval" -> Automatic},
DistanceFunction -> distfunc]; d1 = Part[s1, xcorrs1];
d2 = Part[s2, xcorrs2];
dist = CanonicalWarpingDistance[s1, s2,
Automatic, {"SlantedBand", band},
Method -> {"MatchingInterval" -> Automatic},
DistanceFunction -> distfunc]; {dist, d1, d2}]
However, this will not help you compile it. The compiler will not support functions such as CanonicalWarpingDistance and CanonicalWarpingCorrespondence. In Version 12 they announced that they will enable compiling of functions like this, however, I have no idea when they will add support for those two functions. At the Wolfram conference 2018 they announced that you will be able to do this. I would ask technical support for a timetable (and a V12 release date). I assume that you would need to have your C code either link to a MMA library or communicate with a running kernel to do built-in functions like that.
One other option is to recode those two routines using elemental functions and then compile it with the new compiler when it is released. The existing compiler is very limited.
Regards,
Neil