Convert audio samples to seconds or milliseconds at any sample rate, or turn a duration back into a sample count, with clock time and PCM data size.
- All Unit Converters
- Samples To ms Calculator
- Hz To ms Calculator
- Seconds To Frames Converter
- Frame Rate Calculator
- Audio File Size Calculator
Calculator Functions
| Function | What it does | What it requires |
|---|---|---|
| Duration from sample count | Converts a number of audio samples to seconds, milliseconds and clock time | Requires the count basis, the sample count, the sample rate and the channel count |
| Sample count from duration | Converts a length of time to a number of audio samples | Requires the count basis, the audio duration, the sample rate and the channel count |
The count basis is either frames (samples per channel) or total interleaved sample values, which is frames multiplied by the channel count. The sample rate is entered in kHz or Hz and starts at 44.1 kHz, and the channel count starts at 2. Duration is entered in seconds, milliseconds or minutes. One optional setting, stored PCM bits per sample (16, 24 or 32), is used only for the size of the uncompressed sample data. Each result also shows the duration of the same frame count at 44.1, 48 and 96 kHz.
Samples to Seconds Formulas
| t | Duration (s) |
| N | Number of frames, which is samples per channel |
| fs | Sample rate per channel (Hz, samples per second). A rate in kHz is multiplied by 1,000 |
Digital audio is sampled at uniform intervals [2], and the sample rate is the number of samples per second [1], so a count of samples divided by the rate is a time in seconds. One frame holds one sample value for each channel.
Duration from sample count
5,000 frames at 44.1 kHz last 5,000 ÷ 44,100 = 0.113379 s, or 113.38 ms. With the interleaved basis the count is divided by the channel count first: 88,200 stereo sample values are 44,100 frames, which is exactly 1 s at 44.1 kHz. One frame at 44.1 kHz lasts 22.676 microseconds.
Sample count from duration
2 s at 48 kHz is 2 × 48,000 = 96,000 frames, or 192,000 interleaved sample values in stereo. A result with a fraction is a timing equivalent, since audio data holds whole frames only.
PCM data size
ch is the channel count. One second of 16-bit stereo audio at 44.1 kHz, the audio CD format [2], is 44,100 × 2 × 16 ÷ 8 = 176,400 bytes, or 0.168 MiB. The bits are the stored size of each sample value, so 24-bit audio kept in a 32-bit container counts as 32 [1].
Limits of This Estimate
- The duration is the length of the block, N ÷ rate. The time from the first sample instant to the last is one sample period shorter, (N − 1) ÷ rate.
- The same sample count lasts a different time at a different sample rate. The calculator does not resample audio.
- The PCM size covers packed sample data only. File headers, metadata, padding and any compression are left out, so it will not match the size of an MP3, AAC or FLAC file.
Sources
- Microsoft, WAVEFORMATEX structure (mmeapi.h): sample rate in samples per second, and PCM bytes per frame as channels × bits per sample ÷ 8
- Library of Congress, Linear Pulse Code Modulated Audio (LPCM): PCM as a signal sampled at uniform intervals, and the 44.1 kHz, 16-bit audio CD format
