harmonizing chords on a scale

Michele Verità's icon

hi all, first of all i admit i totally lack in formal music-harmony-theory education, everything i know about it is self taught from what i found on the web and some pubblications..lately i'm trying to build my abstractions to experiment with composition and computer generated music and that what i want to do: choose a scale and a key, set a chord progression (like I IV V I) and make the patch improvise with some harmonic basis on the scale grade; i have clear in mind what i have to do or at least most basic operation for example pseudo-random selection on chordal notes it's quite satysfing..but i have problems when changing scale key..so i post a simple example of a patch that gets chords from a a scale according to the grade, i hope it make sense for you, please can someone tell me if it's the right approach? (i know about Peter Elsea fuzzy tutorials, and this little example requires Lobjects)
any help appreciated
michele