Unvisualize Parsons code Introduction

The Parsons code is just a simple way to describe pitch variations in a piece of music, whether a note is higher or lower than the previous one.

Even if you suck at remembering tunes, you can still pretty much remember if a note goes up or down, thus the Parsons code can help you to identify a music using a search engine.



Description

Each variation is represented by a single character, which is one of the following:


R if the note is the same than the previous one (stands for "Repeat")
U if the note is higher than the previous one (stands for "Up")
D if the note is lower than the previous one (stands for "Down")


The initial note is written as *.



Example

Here is an example of Parsons code (beginning of "Ode to Joy"):

*RUURDDDDRUURDR


You can actually visualize it, like this:

      *-*                    
     /   \                   
    *     *                  
   /       \                 
*-*         *         *-*    
             \       /   \   
              *     *     *-*
               \   /         
                *-*          


We'll call that a contour from now on.

The rules for drawing such countours are considered self-explained by the above example.





Challenge

Now comes the real challenge.

Write a program that, given a contour as input, outputs its corresponding Parsons code.

You are not asked to draw the contour, but the opposite actually.
From the contour, find the original Parsons code.



Rules


The usual rules for code golfing apply
The shortest program in number of bytes wins
The input is a contour, and the output shall be a valid Parsons code
Details about extra whitespace for the input are irrelevant, do whatever works best for you
You are not allowed to hardcode, one way or another, parts of the output and / or the program using extra whitespace because of the previous rule


Notes


This might be useful for testing
The corresponding Parsons code for * is *
An empty string is not a valid contour
A Parsons code always starts with *
CJam, 21 bytes
qN/:.e&gt;(o2%:i&quot;DRXU&quot;f=

Fold the lines (:) by vectorizing (.) a character-wise maximum operation e&gt;. Since there is only one non-space character in each column, this one will be the result, as space has a smaller ASCII code than all printable non-space characters.
Unshift and print the first asterisk (o, then map every other (2%) remaining char to UDR using modular indexing.
Old solution (29 bytes)
'*qN/z2%'*f#0+2ew);::-&quot;RDU&quot;f=

qN/ gets input lines. z transposes this character matrix. 2% drops every odd row. '*f# finds the index of the asterisk in each row. 0+2ew); gets all successive pairs of indices. ::- computes their differences, and &quot;RDU&quot;f= maps them to letters (via modular indexing: 0 → R, 2 → U, -2 ≡ 1 → D). The leading '* prepends the asterisk.
EDIT: I changed 2ew to 0+2ew); to work around CJam not handling ew (successive slices) on lists that are too short. This makes the code work for the input string *.
Try it here, or watch it in action: