Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Sound Loop Problem

Subject: Sound Loop Problem

From: Husam Aldahiyat

Date: 7 Mar, 2011 11:33:03

Message: 1 of 3

>> w = 12000;
>> t = linspace(0,2*pi,900);
>> t(end) = [];
>> y = .1*cos(w*t);

>> sound(y);

This play a high pitched beep sound. But when I loop it like this:

>>sound(y); sound(y)

I don't get a continuous sound, as there is some sort of pause in the middle. I thought it has to do with the sound() function loading but then I tried this:

>> sound(repmat(y,1,2));

And still, a break in the middle.

I would like to obtain a (y) that wouldn't break in case of a loop. I don't want to change the value of (t) whenever I want a shorter/longer sound, which should only be done through looping (y).

How can I do this?

Subject: Sound Loop Problem

From: Bruno Luong

Date: 7 Mar, 2011 12:01:30

Message: 2 of 3

"Husam Aldahiyat" wrote in message <il2fpf$ipg$1@fred.mathworks.com>...
> >> w = 12000;
> >> t = linspace(0,2*pi,900);
> >> t(end) = [];
> >> y = .1*cos(w*t);
>
> >> sound(y);
>
> This play a high pitched beep sound. But when I loop it like this:
>
> >>sound(y); sound(y)
>
> I don't get a continuous sound, as there is some sort of pause in the middle. I thought it has to do with the sound() function loading but then I tried this:
>
> >> sound(repmat(y,1,2));
>
> And still, a break in the middle.
>
> I would like to obtain a (y) that wouldn't break in case of a loop. I don't want to change the value of (t) whenever I want a shorter/longer sound, which should only be done through looping (y).
>
> How can I do this?

You can't just concatenate soundwave brutally like that and hope it goes well. It introduces a discontinuity, so infinity bandwidth frequency error and DAC of your sound card won't like it very much.

This has little to do with Matlab.

Bruno

Subject: Sound Loop Problem

From: Husam Aldahiyat

Date: 7 Mar, 2011 12:55:08

Message: 3 of 3

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message e middle.
>
>
*
>
> Bruno

Yes, I'd like help from someone with sound engineering knowledge. I restarted my computer and this played a continuous sound (don't know why it didn't work before):

>> w = 12000;
>> t = linspace(0,2*pi,900);
>> t(end) = [];
>> y = .1*cos(w*t);
>> sound(repmat(y,1,2));

But

>> sound(y); sound(y)

Still presents a break, probably due to sound() loading.

But I solved my original problem of creating a loopable short sound that results in a continuous longer sound when concatenated. I won't use

>> sound(y); sound(y)

In my objective, but instead take this sound to my iphone app code and loop it there using something that imitates repmat(). Should work.

Thanks for the help.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us