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 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
% 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 commentaires
Walter Roberson
le 13 Nov 2023
Modifié(e) : Walter Roberson
le 13 Nov 2023
I observe the same behaviour on my (intel) Mac.
Testing, if I use audioDeviceWriter then I do get sound output.
Réponses (0)
Voir également
Catégories
En savoir plus sur Audio I/O and Waveform Generation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!