4
$\begingroup$

After importing a sound file, how can I generate a time series (preferably as an $n\times 1$ matrix) which gives the intensity at equal time intervals?

$\endgroup$
5
$\begingroup$

Let the imported sound be

sound = ExampleData[{"Sound", "JetSound"}]

One can extract the SampledSoundList with

sound[[1]]

This example has 2 channels and a sampling rate of 44100 Hz, as can be seen not only in the sound object box, but also from

Length@sound[[1, 1]]

2

sound[[1, 2]]

44100

To get the list of the amplitudes of the first channel one can use

channel1Amp = sound[[1, 1, 1]];

and generate a plot of these amplitudes using

ListPlot[channel1Amp, PlotRange -> All, Frame -> True]

Channel1Amplitudes

The amplitudes of the second channel are

channel2Amp = sound[[1, 1, 2]];

Downsampling

Downsampling the first channel by a factor of 5

channel1AmpDS = Downsample[channel1Amp, 5];

ListPlot[channel1AmpDS, PlotRange -> All, Frame -> True]

downsampledChannel1

There is also Upsample and the more general ArrayResample that can be used to change the sampling rate.

$\endgroup$
  • $\begingroup$ Can you please tell me how to change the sampling rate? $\endgroup$ – Sankhadip Chakraborty Jun 22 '15 at 13:59
  • $\begingroup$ @SankhadipChakraborty The question in your comment isn't very specific. Please check the edit of my answer. Hope you didn't mean something like newSound = sound; newSound[[1, -1]] = 10000; newSound. $\endgroup$ – Karsten 7. Jun 22 '15 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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