1. A computer-readable medium having computer executable instructions for generating a musical output from a musical input, said computer executable instructions comprising steps for: receiving a first sequence of notes and a first set of characteristics defining those notes; receiving a database which includes a set of one or more sequences of notes and a second set of characteristics defining those notes, said second set of characteristics including audio samples corresponding to those notes; identifying a set of potential match candidates from the database for each note of the first sequence of notes; computing a cost for each potential match candidate by comparing the characteristics defining each potential match candidate with the corresponding characteristics of the first sequence of notes; computing a transition cost from each match candidate for a given note to each match candidate for the following note; identifying a globally optimal path through the potential match candidates relative to the sequence of the first sequence of notes by finding a path having a best cost path in terms of the costs for each potential match candidate and the cost of the transitions for that path; and constructing a musical output by sequentially concatenating the potential match candidates corresponding to the globally optimal path.