Just wanna figure out if there is a decent way to add a same option to multiple functions simultaneously.
For example I have a series of SoundNote:
Sound[{SoundNote["D4", {0.4, 0.2}], SoundNote["G4", {0.6, 0.2}], SoundNote["B4", {0.8, 0.2}], SoundNote["D5", {1, 0.2}], SoundNote["A4", {1.2, 0.2}], SoundNote["E4", {1.4, 0.2}], SoundNote["G4", {1.6, 0.2}], SoundNote["A4", {1.8, 0.2}]}]
And now I want to add an option SoundVolume -> 1/2 to the arguments of all functions in the list and make it like:
Sound[{SoundNote["D4", {0.4, 0.2},SoundVolume->1/2], SoundNote["G4", {0.6, 0.2},SoundVolume->1/2], SoundNote["B4", {0.8, 0.2},SoundVolume->1/2], SoundNote["D5", {1, 0.2},SoundVolume->1/2], SoundNote["A4", {1.2, 0.2},SoundVolume->1/2], SoundNote["E4", {1.4, 0.2},SoundVolume->1/2], SoundNote["G4", {1.6, 0.2},SoundVolume->1/2], SoundNote["A4", {1.8, 0.2},SoundVolume->1/2]}]
Is there any way to add the option instead of adding them one by one?
I've tried combining pure functions and Append like this:
Sound[Append[#,SoundVolume->1/2]& /@{SoundNote["D4", {0.4, 0.2}], SoundNote["G4", {0.6, 0.2}], SoundNote["B4", {0.8, 0.2}], SoundNote["D5", {1, 0.2}], SoundNote["A4", {1.2, 0.2}], SoundNote["E4", {1.4, 0.2}], SoundNote["G4", {1.6, 0.2}], SoundNote["A4", {1.8, 0.2}]}]
But it didn't work as it seems like the compiler sees SoundVolume -> 1/2 as an option for Append.
list /. SoundNote[args__] :> SoundNote[args, SoundVolume -> 1/2]. – J. M.'s missing motivation Jun 21 '15 at 09:47SoundVolume->1/2as an option forSoundinstead of an option for every singleSoundNote. – Karsten7 Jun 21 '15 at 09:52SoundNoteusingSetOptions:SetOptions[SoundNote, SoundVolume -> 1/2]. – Karsten7 Jun 21 '15 at 09:54Appendworks in version 10.1.0 under Windows. Which version are you using? – Mr.Wizard Jun 21 '15 at 10:34