# Play[ ] takes very long to play a custom sound

I am using

Play[f[t], {t,0,30}]


to play sound defined by f(t), which is 30 seconds long. It is taking a very long time to evaluate this expression (10 minutes and counting). What are the limitations of Play that might make it take so long?

If it is relevant, my function f(t) is a piecewise sequence of sine waves strung together, each about 2 seconds long.

• How long does this take? Play[Sin[t], {t, 0, 30}] Mar 29, 2016 at 6:22
• No time at all... Mar 29, 2016 at 6:26
• Then I suppose interpolating a Table[] of your piecewise fuction should work. Mar 29, 2016 at 6:32
• What do you mean by interpolating a table? Mar 29, 2016 at 6:37

f[t_] = Piecewise[{{Sin[t + 0.2], 2 > t >= 0}, {Sin[t - 0.4],
4 >= t >= 2}}];
Plot[f@t, {t, 0, 4}, PlotRange -> All] int[t_] = Interpolation[Table[{t, f@t}, {t, 0, 4, 0.01}]]@t;
Plot[int@t, {t, 0, 4}, PlotRange -> All] Play[int@t, {t, 0, 4}] EDIT

Easier way:

Sound[{Play[Sin[t+1], {t, 0, 2}], Play[Sin[t-1], {t, 0, 2}]}]