Module: Awaaz::Properties
- Included in:
- Awaaz
- Defined in:
- lib/awaaz/properties.rb
Overview
Properties of audio
Instance Method Summary collapse
-
#duration(samples, sample_rate) ⇒ Float
Calculates the duration (in seconds) of an audio signal given the number of samples and the sample rate.
Instance Method Details
#duration(samples, sample_rate) ⇒ Float
Note:
The duration is computed as:
samples_count / sample_rate
Calculates the duration (in seconds) of an audio signal given the number of samples and the sample rate.
30 31 32 33 34 35 |
# File 'lib/awaaz/properties.rb', line 30 def duration(samples, sample_rate) samples_count = samples.shape.max return 0.0 if samples_count <= 0 || sample_rate <= 0 samples_count / sample_rate.to_f end |