How to reconstruct a sound with data in MATLAB?

22 ビュー (過去 30 日間)
Lucio
Lucio 2011 年 7 月 20 日
Hi all! I have in matlab a vector with different pressures (2501 exactly) for one frequency (1856hz) that have been recorded with a microphone. Thus, I'm asking if I can go back and reconstruct the sound so I can hear it. Someone suggested to me to do it with Soudforge, but I don't know how to pass from matlab to soundforge. Can you help me, please? Thank you !

回答 (5 件)

Jan
Jan 2011 年 7 月 20 日
What format do your pressure values have? Assuming they have a range from -N to N (e.g. "max(abs(pressure))")
sound(pressure / N, 1856)
  4 件のコメント
Daniel Shub
Daniel Shub 2011 年 7 月 21 日
If the pressure waveform has a large DC offset scaling by N will not work so well,
Jan
Jan 2011 年 7 月 21 日
@Daniel: Correct. If there is any DC offset, it must be removed. I've associated a offset free signal according to the term 'pressure', which has no DC by definition.
@Lucio: If the sound card have problems, use RESAMPLE to onvert it to a standard frequency like 8000 or 8192Hz.

サインインしてコメントする。


Sean de Wolski
Sean de Wolski 2011 年 7 月 20 日
like
doc sound %?
be more specific what you mean by "reconstruct".
  1 件のコメント
Lucio
Lucio 2011 年 7 月 21 日
Hear the sound.

サインインしてコメントする。


Vieniava
Vieniava 2011 年 7 月 20 日
Try this:
fs=8000;
soundsc( pressure-mean(pressure), fs)
You should know sampling frequency used in data collecting - here I assumed typical 8kHz.
  2 件のコメント
Lucio
Lucio 2011 年 7 月 21 日
And my pressure data where should I put it? And can I hear the sound on matlab?
Jan
Jan 2011 年 7 月 21 日
Your pressure data are expected to be the values of the variable called "pressure". Perhaps you forgot to mention the format your pressure data??
You cannot hear the sound "on Matlab", but in the speakers of headphone of your computer. Just try it.

サインインしてコメントする。


Daniel Shub
Daniel Shub 2011 年 7 月 21 日
It is not totally clear what you are starting with: Assuming x is your pressure waveform and is an array 2501x1 samples and the samples were acquired at a rate of 1856 samples per second. If the sample rate is in fact 1856, then unless your soundcard is connected to a lowpass filter, you will get all sorts of audible aliasing if you present the sound with a sample rate of 1856. The solution is to upsample the pressure waveform and present it at a higher sample rate. To do this you can do:
y = resample(x, round(44.1e3/1856), 1);
to get a signal with a sample rate of round(44.1e3/1856)*1856. To then present the sound with an arbitrary level you can do:
soundsc(y-mean(y), round(44.1e3/1856)*1856);
You need to remove the mean value for the scaling to work properly. Some microphones have large bias voltages and this will swamp the small deviations in pressure/voltage that you want to hear.
To get the actual level you need to know the sensitivity of your microphone, the maximum output voltage of your soundcard, the sensitivity of your transducer (headphones/speakers), and the gain of any amplifiers or attenuators.
  3 件のコメント
Daniel Shub
Daniel Shub 2011 年 7 月 21 日
Unless you are studying the Nyquist theorem in your lab, then sampling a 1856 Hz signal at 133 Hz does not make any sense. You need to sample at at least twice the frequency of the highest frequency signal.
Lucio
Lucio 2011 年 7 月 21 日
Yes I know that, but I didn't the recording, another team did it, and I only have the data, and they said they recorded it with a sample frequency of 133hz. Or maybe I can choose another frequency under that so the rendrering could be better, but I still don't know how to do it, event theorically :(

サインインしてコメントする。


Daniel Shub
Daniel Shub 2011 年 7 月 21 日
It appears that the sampling rate is 133 Hz and the signal frequency is 1856 Hz. This means the signal will be aliased to a frequency less than 66.5 Hz. Unless you have a very good transducer (e.g., headphones or speaker), you will not be able to hear this signal. A better approach would be to use the signal to amplitude modulate a higher frequency carrier. Assuming your pressure signal is "x."
fs = round(44.1e3/133)*133;
x = x-mean(x);
x = x./sqrt(sum(x.^2));
x = resample(x, round(44.1e3/133), 1);
soundsc(x.*sin(2*pi*8e3*((0:(length(x)-1))/fs)), fs);
  1 件のコメント
Lucio
Lucio 2011 年 7 月 21 日
Oh thank you, I'll tray it and let you know the results ;)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAudio I/O and Waveform Generation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by