Hi! I need the code to first encode 3 audios

Hi! I need the code to first encode 3 audios, and then play them as the user indicates, but when the user enters [1 3] the first one is played and then the third one. As I have it, both are played at the same time. thanks.

답변 (1개)

Sai Teja G
Sai Teja G 2023년 8월 31일

0 개 추천

Hi Sebastian,
I assume that you want to play both the sounds simultaneously when the condition meets ‘[1 3]’.
The audios may sound distorted because there is data drop when the audio files are loaded and played, the file size can also influence data drop. You will have to make some compromises with the device properties. You can refer to this sample code to play two sounds simultaneously –
hmfr1 = dsp.AudioFileReader(filename1);
hmfr2 = dsp.AudioFileReader(filename2);
hap = dsp.AudioPlayer('DeviceName','Speakers (SoundMAX Integrated Digital Audio)',...
'SampleRate',hmfr1.SampleRate,'QueueDuration',3);
while ~isDone(hmfr2)
audio1 = step(hmfr1);
step(hap, audio1);
audio2 = step(hmfr2);
step(hap,audio2);
end
For more information refer to the link attached below.
Hope it helps!

카테고리

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

제품

질문:

2022년 6월 6일

답변:

2023년 8월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by