We propose an automated composing system for sub-melodies focusing especially on pitch and rhythm. We constructed the system using a Hidden Markov Model (HMM). In a composing experiment, we obtained various melodies depending on the song set used for learning, and the results suggest that this system can learn the features of song sets that are selected while considering music genres, music culture, or nuances of composers.