Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When generating a Sound object by using Sound primitives, like:

sound = Sound[ListWaveform[{{1, 1}, {1.496, .7}, {2.501, .3}}, 265, 1]];

how can I get the sample ("amplitude") data which is produced by the Sound primitive at a given sample rate?

Obviously one could export sound to a wav file and re-import it, but how to do it directly? Or let's say: what is the Rasterize function for Sounds, the inverse of ListPlay?

Sorry for this rather simple question, but I have been looking for some time and could not find anything.

share|improve this question

Your example evaluates to a SampledSoundFunction[f , n , r ], which

is a sound primitive that represents a sound whose amplitude sampled r times a second is generated by applying the function f to successive integers from 1 to n.

You could extract that function and see if it gives you what you're looking for:

sound = Sound[ ListWaveform[{{1, 1}, {1.496, .7}, {2.501, .3}}, 265, 1] ];

enter image description here

func = Cases[sound, _SampledSoundFunction, Infinity][[1]];

Print["rate = " <> ToString@(rate = func[[3]] )]

rate = 8192

f = func[[1]]
Plot[f[x], {x, 0, rate}]

enter image description here

NMaximize[f[x], x]

{0.859436, {x -> 4.94378}}

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.