sound() function playback ends after a few seconds

I am using the 2011a student edition on a new MacBook Pro.
When I use the sound() function, the sound playback stops at 10 seconds, regardless of the input vector size.
For example, the following simple script should play a sound for about 20 seconds, but it stops after 10 seconds on my Mac. Any help would be appreciated.
clc; clear all;
a = linspace(0, 1, 200000);
d = linspace(1, 0.5, 200000);
s = linspace(0.5, 0.1, 200000);
r = linspace(0.1, 0, 200000);
adsr = [a d s r];
plot(adsr);
f = 500;
fs = 44100;
n = 0:length(adsr)-1;
x = sin(2 * pi * f * n / fs);
y = x.*adsr;
plot(y);
sound(3 * y, fs);

 採用された回答

Daniel Shub
Daniel Shub 2011 年 10 月 1 日

0 投票

This is a known bug with a fix provided by TMW

1 件のコメント

MatlabUser
MatlabUser 2011 年 10 月 1 日
THANK YOU!
Evidently there's a bug in 2011a for Mac and Linux. The fix on that webpage did the trick.

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

その他の回答 (1 件)

bym
bym 2011 年 9 月 30 日

0 投票

try:
x = sin(2 * pi * f * n ./ fs); % note./

3 件のコメント

Walter Roberson
Walter Roberson 2011 年 9 月 30 日
That isn't going to help. fs is a scalar constant, and mrdivide ( / ) by a scalar constant is the same as rdivide ( ./ ) by the same constant.
bym
bym 2011 年 9 月 30 日
doh! must be a platform issue then, the above script seems to work on my computer (windows XP Matlab 2008b)
David Young
David Young 2011 年 10 月 1 日
It sounds for 20s for me also. Windows 7 64-bit, Matlab 2011a.

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by