time recording problem with matlab

조회 수: 4 (최근 30일)
ta helpers
ta helpers 2016년 5월 7일
편집: Dana Alsalman 2016년 5월 7일
hello,
I am trying to record my voice using the codes below:
% Before starting, we will use the following commands
clear all % clear all workspace variables
close all % close all open figures
clc % clear command window
% Speech synthesis (recording and saving audio signal) and loading into
% matlab
% Input paramters (default values)
fs= 16000; % sample frequency
nobits = 8; % number of bits per sample
nochannels = 1; % number of channels (mono)
x = audiorecorder(fs, nobits, nochannels);
get(x);
x = audiorecorder;
disp('Start speaking.')
recordblocking(x, 3);
disp('End of Recording.');
% Play audio signal
play(x);
% Save data (double precision array)
x = getaudiodata(x);
% Save recorded signal as an audio file with "wav" extention (type of file)
audiowrite ('x.wav', x,fs)
% Codes to asnwer questions (1-4) of (5.Problem Statement)
% 1. Code to find sample rate of the audio signal
% Read (download) audio file into matlab
[x,fs] = audioread('x.wav');
for some reasons, the recorded audio file is less than 3 seconds and when I play it using real player it only last for 1.5 seconds,
The strange thing is that the codes and recorded signal are working properly with Fs= 8000 Hz. Could anyone help me with this issue?
Thank a lot and I really appreciate quick response as I have to submit my project tomorrow.
  댓글 수: 1
Jan
Jan 2016년 5월 7일
Your question is funny. You try to push the voluntary helpers, because you started to solve the problems very late. ;-) Of course, I have been almost too late many times also, but I did not publish this in the forum.

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

채택된 답변

Jan
Jan 2016년 5월 7일
편집: Jan 2016년 5월 7일
What is the meaning of these lines:
x = audiorecorder(fs, nobits, nochannels);
get(x);
x = audiorecorder;
You create an audiorecorder object, get its properties but do neither display or use them. Then get(x) is only a waste of time? And inthe next line you overwrite the obejct by a new audiorecorder object, which uses the default values?
The default frequency of the audiorecorder obejct is 8000Hz. Do you recognize this value? It could be a solution, simply to remove the strange lines:
get(x);
x = audiorecorder;
;-) Note: Strange commands have strange effects. If the program produces stranger results than it should, avoid strange commands.
  댓글 수: 1
Dana Alsalman
Dana Alsalman 2016년 5월 7일
편집: Dana Alsalman 2016년 5월 7일
Jan Simon. Thanks a lot sir, I was able to solve the problem. I really appreciate it if you can also help me write the matlab codes to find the bandwidth and the Nyquist rate of my signal

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

추가 답변 (0개)

카테고리

Help CenterFile 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!

Translated by