converting a frequency to audible tone?

5 views (last 30 days)
IRFANA
IRFANA on 29 Oct 2014
Edited: Star Strider on 29 Oct 2014
hey can you help me...i got a frequency by applying fft to a signal and selecting max peak of it..can i convert that frequency to an audible tone? While i was searching through, i got a code like this but it is not working .
Fs = 1000;
nSeconds = 5;
frequency = 100;
y1 = 100*sin(linspace(0, nSeconds*frequency*2*pi, round(nSeconds*Fs)));
aud1 = audioplayer(y1, Fs);
frequency = 200;
y2 = 100*sin(linspace(0, nSeconds*frequency*2*pi, round(nSeconds*Fs)));
aud2 = audioplayer(y2, Fs);
% overlapping sound impossible
sound(y1, Fs);
pause(1)
sound(y2, Fs);
% overlapping sound possible
play(aud1);
pause(1);
disp('can compute here');
play(aud2);
pause(1);
stop(aud1);
pause(1);
stop(aud2);
end
.plz reply

Answers (2)

Image Analyst
Image Analyst on 29 Oct 2014
Here's my demo code on how to make a sound.

Star Strider
Star Strider on 29 Oct 2014
Edited: Star Strider on 29 Oct 2014
I don’t know what you mean by ‘is not working’. You can play one sound at a time or both simultaneously in stereo. I found that using the sound function worked well, and audioplayer and play did also.
Creating and playing a stereo sound with your vectors:
y12 = [y1; y2]'; % Create Stereo
sound(y12,Fs)
If you want to hear the full effect, introduce a time offset in both signals. This will start by playing the right channel, then both channels, then the left channel:
y12 = [zeros(1,1000) y1; y2 zeros(1,1000)]';
sound(y12,Fs)

Tags

Community Treasure Hunt

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

Start Hunting!