How can i calculate the total duration of the audio ?
24 次查看(过去 30 天)
显示 更早的评论
I have binary data for example:
binary_data = [2 0 2 0 -2 0 2 0 0 -2 -2 0 0 -2 -2 0]
% time between samples
sampling_period = 1/44100
% Time period (2 "bits" per second)
final = int(len(binary_data)/2)
%ts = np.arange(0, final, sampling_period)
fs = 44100
fc = 800 % in Hz
How to calculate mathematically the total time duration of the generate audio from this binary data ?
% Total duration says duration = 280 #seconds
Could anyone please tell me the relation ?
1 个评论
dpb
2022-5-7
T=(N-1)/fs; % total time length
where N is number of samples. Which can be seen to be so from
t=[0:N-1]/fs; % the sampled times for N samples
回答(1 个)
Pooja Kumari
2023-9-29
Dear Jay,
It is my understanding that you are facing issues with calculating the total time duration mathematically of the generated audio from the given binary data. Calculate the total time duration of the generated audio from the given binary data, you can refer to the below code in MATLAB:
%Calculate the number of samples in the binary data givent Time period (2 "bits" per second):
num_samples = length(binary_data)/2;
%Calculate the time duration of each sample:
sample_duration = 1/fs; % Sampling period
% Calculate the total time duration and
total_duration = num_samples * sample_duration;
In this case, the total duration will be in seconds since the sample duration is in seconds and the number of samples is the total number of elements in the binary data.
I hope this helps!
Regards,
Pooja Kumari
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!