scale={"D4","E4","F4","G4","A4","B4","C5","D5"};

upanddown=Join[scale,Reverse[scale]];

downandup=Join[Reverse[scale],scale];

keytones={scale[[4]]};

tdupanddown=Join[keytones,Reverse[keytones]];

tddownandup=Join[Reverse[keytones],keytones];

midi=Sound[{SoundNote[#,1,"Organ"]&/@scale,SoundNote[None,1],SoundNote[#,3,"Organ"]&/@upanddown,SoundNote[None,1],SoundNote[#,3,"Organ"]&/@downandup,SoundNote[None,1],SoundNote[#,2,"Organ"]&/@upanddown,SoundNote[None,1],SoundNote[#,2,"Organ"]&/@downandup,SoundNote[None,1],SoundNote[#,1,"Organ"]&/@upanddown,SoundNote[None,1],SoundNote[#,1,"Organ"]&/@downandup,SoundNote[None,1],SoundNote[#,2,"Organ"]&/@tdupanddown,SoundNote[None,1],SoundNote[#,2,"Organ"]&/@tddownandup,SoundNote[None,1],SoundNote[keytones,3,"Organ"]}]

Export["~/Desktop/"<>InputString[]<>".mid",midi];