How can i calculate the total duration of the audio ?

50 Ansichten (letzte 30 Tage)
Jay Patel
Jay Patel am 7 Mai 2022
Beantwortet: Pooja Kumari am 29 Sep. 2023
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 Kommentar
dpb
dpb am 7 Mai 2022
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

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Pooja Kumari
Pooja Kumari am 29 Sep. 2023
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

Kategorien

Mehr zu Simulation, Tuning, and Visualization 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