2 * Primitive interface to NAS WAV file operations.
3 * Not really useful for now, I've used it for testing previously.
5 * Copyright (C) 2007 Krzysztof Foltman
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this program; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02111-1307, USA.
23 #include <audio/wave.h>
28 bool load_wave(dsp::dynamic_buffer
<T
> &dest
, const char *file_name
) {
29 WaveInfo
*file
= WaveOpenFileForReading(file_name
);
30 typedef dsp::sample_traits
<T
> st
;
31 if (file
->channels
== st::channels
&& file
->bitsPerSample
== st::bps
) {
32 dest
.resize(file
->numSamples
);
33 WaveReadFile((char *)dest
.data(), dest
.size()*sizeof(T
), file
);
38 fprintf(stderr
, "Sorry, need a %d channels and %d bps, got %d channels and %d bps\n", st::channels
, st::bps
, file
->channels
, file
->bitsPerSample
);
49 void set_wave(T
*_data
, int _size
) {
54 void get_wave(T
*&_data
, int &_size
) {
58 void set_pos(wpos _pos
) {
65 void set_rate(wpos _rate
) {
68 template<class U
>U
get() {
74 unsigned int ipos
= pos
.ipart();
80 result
= pos
.lerp_ptr_lookup_int
<T
, 12, int >(data
);