2 * This file is part of DisOrder.
3 * Copyright (C) 2004, 2005, 2007 Richard Kettlewell
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 /** @file plugins/tracklength-wav.c
19 * @brief Compute track lengths for WAV files
21 #include "tracklength.h"
24 long tl_wav(const char *path) {
26 int err, sample_frame_size;
29 if((err = wav_init(f, path))) {
30 disorder_error(err, "error opening %s", path);
33 sample_frame_size = (f->bits + 7) / 8 * f->channels;
34 if(sample_frame_size) {
35 const long long n_samples = f->datasize / sample_frame_size;
36 duration = (n_samples + f->rate - 1) / f->rate;