Abstract: A method and apparatus for music generation may include steps of receiving any length of input; recognizing pitches and rhythm of the input; generating a first segment of a full music; generating segments other than the first segment to complete the full music; generating connecting notes, chords and beats of the segments of the full music and handling anacrusis; and generating instrument accompaniment for the full music, and comprise a music generating system to realize the steps of music generation.