Filter löschen
Filter löschen

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 Ansichten (letzte 30 Tage)
% 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)

Antworten (0)

Kategorien

Mehr zu Audio I/O and Waveform Generation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by