Skip to content

Commit

Permalink
Use sample_rate for determining duration
Browse files Browse the repository at this point in the history
  • Loading branch information
linkyndy committed Jul 11, 2024
1 parent 9db8b73 commit ce1d586
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/parsers/wav_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def unpack_fmt_chunk(io, chunk_size)
def file_info(fmt_data, data_size)
# NOTE: Each sample includes information for each channel
sample_frames = data_size / (fmt_data[:channels] * fmt_data[:bits_per_sample] / 8) if fmt_data[:channels] > 0 && fmt_data[:bits_per_sample] > 0
duration_in_seconds = data_size / fmt_data[:byte_rate].to_f if fmt_data[:byte_rate] > 0
duration_in_seconds = sample_frames / fmt_data[:sample_rate].to_f if sample_frames && fmt_data[:byte_rate] > 0
FormatParser::Audio.new(
format: :wav,
num_audio_channels: fmt_data[:channels],
Expand Down

0 comments on commit ce1d586

Please sign in to comment.