Skip to main content
added 104 characters in body
Source Link
Michael Seifert
  • 15.3k
  • 35
  • 72

If you have the two lines separately like this, you can use sampled audio to turn each Sound into a waveform. Then you can simply add the two waveforms together to "mix" them.

rh = Sound@MapThread[SoundNote[#1, #2, "Piano"] &, {note1, time1}]
lh = Sound@MapThread[SoundNote[#1, #2, "Piano"] &, 
  {Join[ConstantArray[None, 4], (note1 - 12) /. {None - 12 -> None}], 
     Join[ConstantArray[b, 4], time1]}]

{rhaudio, lhaudio} = PadRight[First@*AudioData /@ {rh, lh}];
(* Note that the two clips are of different lengths;  
   PadRight pads the end of the shorter one with silence *)

Audio[rhaudio + lhaudio]

This yields an audio clip with the left hand coming in one quarter-note note early. I think the 4s in the definition of the left-hand line should be 6s instead (since this piece is in $\mathbf{\genfrac{}{}{0pt}{1}{3}{4}}$ time and there are 6 eight notes per bar.)

If you have the two lines separately like this, you can use sampled audio to turn each Sound into a waveform. Then you can simply add the two waveforms together to "mix" them.

rh = Sound@MapThread[SoundNote[#1, #2, "Piano"] &, {note1, time1}]
lh = Sound@MapThread[SoundNote[#1, #2, "Piano"] &, 
  {Join[ConstantArray[None, 4], (note1 - 12) /. {None - 12 -> None}], 
     Join[ConstantArray[b, 4], time1]}]

{rhaudio, lhaudio} = PadRight[First@*AudioData /@ {rh, lh}];
(* Note that the two clips are of different lengths;  
   PadRight pads the end of the shorter one with silence *)

Audio[rhaudio + lhaudio]

This yields an audio clip with the left hand coming in one quarter-note early. I think the 4s in the definition of the left-hand line should be 6s instead.

If you have the two lines separately like this, you can use sampled audio to turn each Sound into a waveform. Then you can simply add the two waveforms together to "mix" them.

rh = Sound@MapThread[SoundNote[#1, #2, "Piano"] &, {note1, time1}]
lh = Sound@MapThread[SoundNote[#1, #2, "Piano"] &, 
  {Join[ConstantArray[None, 4], (note1 - 12) /. {None - 12 -> None}], 
     Join[ConstantArray[b, 4], time1]}]

{rhaudio, lhaudio} = PadRight[First@*AudioData /@ {rh, lh}];
(* Note that the two clips are of different lengths;  
   PadRight pads the end of the shorter one with silence *)

Audio[rhaudio + lhaudio]

This yields an audio clip with the left hand coming in one quarter note early. I think the 4s in the definition of the left-hand line should be 6s instead (since this piece is in $\mathbf{\genfrac{}{}{0pt}{1}{3}{4}}$ time and there are 6 eight notes per bar.)

Source Link
Michael Seifert
  • 15.3k
  • 35
  • 72

If you have the two lines separately like this, you can use sampled audio to turn each Sound into a waveform. Then you can simply add the two waveforms together to "mix" them.

rh = Sound@MapThread[SoundNote[#1, #2, "Piano"] &, {note1, time1}]
lh = Sound@MapThread[SoundNote[#1, #2, "Piano"] &, 
  {Join[ConstantArray[None, 4], (note1 - 12) /. {None - 12 -> None}], 
     Join[ConstantArray[b, 4], time1]}]

{rhaudio, lhaudio} = PadRight[First@*AudioData /@ {rh, lh}];
(* Note that the two clips are of different lengths;  
   PadRight pads the end of the shorter one with silence *)

Audio[rhaudio + lhaudio]

This yields an audio clip with the left hand coming in one quarter-note early. I think the 4s in the definition of the left-hand line should be 6s instead.