Hi , i have if condition in my code and i want to produce alert sound in wrong case. can i do that ????

 채택된 답변

Daniel Shub
Daniel Shub 2011년 12월 20일

1 개 추천

What about
sound(randn(4096, 1), 8192)

추가 답변 (5개)

Jan
Jan 2011년 12월 20일

9 개 추천

WarnWave = [sin(1:.6:400), sin(1:.7:400), sin(1:.4:400)];
Audio = audioplayer(WarnWave, 22050);
play(Audio);

댓글 수: 4

IceQueen
IceQueen 2015년 10월 21일
Thank you. The beep sounded exactly like the error. I threw your solution in a function and gave it a short name. Thanks!
abderrazak chahid
abderrazak chahid 2017년 8월 31일
It is very helpful, Thank you, Jan
Min Son
Min Son 2019년 6월 28일
Cool sound!
v k
v k 2020년 10월 26일
Need something similar to this, which gives a sound when the Whatsapp message comes, or an incoming SMS. A whooshing or a swishing sound.
What structure of WarnWave will give such a notification sound?

댓글을 달려면 로그인하십시오.

Jan
Jan 2011년 12월 20일

4 개 추천

Data = load('handel.mat');
sound(Data.y, Data.Fs)

댓글 수: 4

Daniel Shub
Daniel Shub 2011년 12월 20일
It seems wrong to me to use hallelujah as an alert sound to the "wrong" case. I think would be cool to probe the system settings for the alert sound and use that. You probably also want to unmute and maximize the volume.
Jan
Jan 2011년 12월 20일
I think, and it's near to Christmas, that Hallelujah is a nice counterbalance, when the workflow is impeded by a problem.
I recommend never to unmute automatically: When my son has fallen asleep, I mute the speakers of my laptop.
Well, I admit, that this was the situation of the last year. Currently: When my son mutes the speakers of my laptop, I fall asleep immediately.
Daniel Shub
Daniel Shub 2011년 12월 20일
I agree, but for alerts you never know.
Benjamin Wong
Benjamin Wong 2020년 11월 6일
this is absolutely briliant

댓글을 달려면 로그인하십시오.

Jan
Jan 2011년 12월 20일

4 개 추천

This calls the message sound of the operating system:
beep

댓글 수: 2

Daniel Shub
Daniel Shub 2011년 12월 20일
I had forgotten about beep.
Paul Hoffrichter
Paul Hoffrichter 2020년 10월 16일
beep beep beep
Nice and succinct. Thanks.

댓글을 달려면 로그인하십시오.

Daniel Shub
Daniel Shub 2011년 12월 20일

1 개 추천

So here is an absolutely ugly Windows XP hack that gets the SystemExclamation sound from the registry and replaces environment variables with the correct values and then plays the sound.
[~, tempStr] = system('reg query HKEY_CURRENT_USER\AppEvents\Schemes\Apps\.Default\SystemExclamation\.Current');
[~, valueStart] = regexp(tempStr, 'REG_EXPAND_SZ ');
soundStr = tempStr(valueStart+1:(end-1));
envVarSymbol = strfind(soundStr, '%');
while length(envVarSymbol) >= 2
soundStr = [soundStr(1:(envVarSymbol(1)-1)), ...
getenv(soundStr((envVarSymbol(1)+1):(envVarSymbol(2)-1))), ...
soundStr((envVarSymbol(2)+1):end)];
envVarSymbol = strfind(soundStr, '%');
end
[x, Fs] = wavread(soundStr);
sound(x, Fs)
I need to think about this idea more. Interfaces really should be playing system sounds (yuk, who actually has system sounds set to on) at the appropriate times.

댓글 수: 2

v k
v k 2020년 10월 26일
'wavread' incorrect.
v k
v k 2020년 10월 26일
replaced by 'audioread'.

댓글을 달려면 로그인하십시오.

hajer
hajer 2011년 12월 20일

0 개 추천

thank you everyone . i have alert sound but my problem how i can call it . Now knew the solution .I'm happy to help me.

카테고리

도움말 센터File Exchange에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기

태그

질문:

2011년 12월 20일

댓글:

2020년 11월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by