(1) Record the best harmony in the HM, and its index is represented by
(2) for to do
(3)  // memory consideration
(4)  if then
(5)   
(6)  else
(7)   Generate a random integer number
(8)   
    // pitch adjustment for the pitch chosen randomly
(9)   if then
(10)   // discrete genetic mutation
(11)   end if
(12)  end if
(13) end for
Algorithm 3: The procedure of improvising a new harmony of DGHS.