I am trying to simultaneously playback and record a chirp signal. No sound is coming from my speakers. I pretty much copied the exampled from the matlab docs...
2 ビュー (過去 30 日間)
古いコメントを表示
% Test signal generation
frameSize = 1024;
Fs = 44100;
t = 0:1/Fs:1; % Time vector for 1 second
testSignal = chirp(t, 20, t(end), 20000); % Sweep from 20 Hz to 20 kHz
testSignal = testSignal(:);
% Write the test signal to a WAV file
audiowrite('testChirp.wav', testSignal, Fs);
% Read the test signal from the file
fileReader = dsp.AudioFileReader('testChirp.wav', 'SamplesPerFrame', frameSize);
fs = fileReader.SampleRate;
% Initialize audioPlayerRecorder
aPR = audioPlayerRecorder('SampleRate', fs);
% Initialize file writer for the recorded signal
fileWriter = dsp.AudioFileWriter('recordedOutput.wav', 'SampleRate', fs);
% Play and record the test signal
while ~isDone(fileReader)
audioToPlay = fileReader();
[audioRecorded, nUnderruns, nOverruns] = aPR(audioToPlay);
fileWriter(audioRecorded);
% Handle underruns and overruns
if nUnderruns > 0
fprintf('Audio player queue was underrun by %d samples.\n', nUnderruns);
end
if nOverruns > 0
fprintf('Audio recorder queue was overrun by %d samples.\n', nOverruns);
end
end
% Release system objects
release(fileReader)
release(fileWriter)
release(aPR)
2 件のコメント
Walter Roberson
2023 年 11 月 13 日
編集済み: Walter Roberson
2023 年 11 月 13 日
I observe the same behaviour on my (intel) Mac.
Testing, if I use audioDeviceWriter then I do get sound output.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Audio I/O and Waveform Generation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!