Group Abstract Group Abstract

Message Boards Message Boards

4
|
9.7K Views
|
5 Replies
|
13 Total Likes
View groups...
Share
Share this post:

Playing sound with non-constant sample rate

5 Replies

Here another version using Play. Imagine you got an analytic function:

f[t_] := Sin[440 2 Pi t Sin[10 t]]

It is easy to play it:

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

enter image description here

Now if you do not have function but just irregularly sampled data:

data = {#, f[#]} & /@ {0}~Join~RandomReal[1, 10000]~Join~1;
Short[data]
(*{{0,0},{0.366519495348991`,0.749201172621884`}, ....,{0.19676826435559214`,-0.8154545405493382`}}*)

you can recreate sound closely using Interpolation given that sampling is detailed:

g = Interpolation[data, InterpolationOrder -> 0];
Play[g[t], {t, 0, 1}]

enter image description here

Note sound is different but close enough.

POSTED BY: Vitaliy Kaurov
POSTED BY: David Reiss

Another approach here is to use TimeSeriesResample on the timeseries...

POSTED BY: David Reiss

David & Vitaly,

Thank you very much for your suggestions, I have been using David's solution in the above post. Unfortunately, the solution proposed by Vitaly below was taking far too long given that I have datasets that are approx 21000000 points long.

Following on from this method, is there a way to obtain the SpectrogramArray of this? I cannot work out how to ensure that the non-uniform spacing of the points is considered.

Many thanks,

Daniel

Resampling? These are uneven events:

t = Sort[RandomReal[10 Pi, 1000]];
v = Sin[t Sin[t]];
ts = TimeSeries[v, {t}];

And this resamples evenly:

ListPlay[ts[Range[.1, 9.9 Pi, .01]]]

enter image description here

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