Group Abstract Group Abstract

Message Boards Message Boards

Change amplitude of the audio generated by Play?

Posted 10 years ago

How to change the amplitude of the audio generated by the command "Play[Sin[4402Pi*t],{t,0,10}]"? What options deal with this issue? Thanks...

POSTED BY: John Steigerwalt
4 Replies
POSTED BY: John Steigerwalt

Well, the particular example you give is a bit boring, because the two sin functions have have the same frequency (sorry for this incorrect way of expressing this...), but this would work:

Play[2 Sin[440 2 Pi t] 20 Sin[440 2 Pi t], {t, 0, 1}]

So the idea is that you multiply the sine functions and not the Play functions. Play produces a nice "sound object" which a graphical interface and all. What you are doing is multiplying the output of that.

Cheers,

Marco

POSTED BY: Marco Thiel

Thanks for your response. What I don't understand is why the following two Play commands seem to respond with the same volume sound: Play[2Sin[4402Pit],{t,0,1}] Play[20Sin[4402Pit],{t,0,1}] I want to combine several amplitude waveforms each with its own volume coefficient.

POSTED BY: John Steigerwalt

Well, what have you tried? The most obvious thing would be to try and multiply the Sin with some sort of time dependent amplitude such as:

Play[1/(t + 1)*Sin[440 2 Pi*t], {t, 0, 10}]

which works just fine.

enter image description here

Of course you can multiply by any time dependent amplitude:

Play[Cos[2 Pi t]*Sin[440 2 Pi*t], {t, 0, 10}]

enter image description here

Cheers,

Marco

This might also be useful:

Play[Evaluate[Sin[440 2 Pi*t] Evaluate[Which @@ Evaluate[Flatten[{#[[1]] <= t <= #[[2]], 1./RandomInteger[{2, 10}]} & /@ Transpose[{Range[0, 9], Range[1, 10]}]]]]], {t, 0, 10}]

enter image description here

POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard