Start
Set N, HMS, D, P, par,
Generate HM harmony vector by formula (4)
Calculate
t = 0
While t ≤ T do
For j = 1 to D do
  If rand ≤ P then
    
   If rand ≤ par then
    
   End if
  Else
  End if
End for
If then
End if
t = t + 1
End while
Output
Algorithm 3: Pseudocode of the HS algorithm.