How can i calculate the total duration of the audio ?

52 visualizaciones (últimos 30 días)
Jay Patel
Jay Patel el 7 de Mayo de 2022
Respondida: Pooja Kumari el 29 de Sept. de 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 comentario
dpb
dpb el 7 de Mayo de 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

Iniciar sesión para comentar.

Respuestas (1)

Pooja Kumari
Pooja Kumari el 29 de Sept. de 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

Categorías

Más información sobre Simulation, Tuning, and Visualization en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by